Inline ASM support.

This commit is contained in:
Hackerpilot 2014-08-15 18:31:14 -07:00
parent b1bf15c96d
commit 0ec0598927
12 changed files with 226 additions and 582 deletions

55
analysis/asm_style.d Normal file
View File

@ -0,0 +1,55 @@
// Copyright Brian Schott (Hackerpilot) 2014.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module analysis.asm_style;
import std.stdio;
import std.d.ast;
import std.d.lexer;
import analysis.base;
import analysis.helpers;
/**
* Checks for confusing asm expressions.
* See_also: $(LINK https://issues.dlang.org/show_bug.cgi?id=9738)
*/
class AsmStyleCheck : BaseAnalyzer
{
alias visit = BaseAnalyzer.visit;
this(string fileName)
{
super(fileName);
}
override void visit(const AsmBrExp brExp)
{
if (brExp.asmBrExp !is null)
{
addErrorMessage(brExp.line, brExp.column,
"This is confusing because it looks like an array index. Rewrite a[1] as [a + 1] to clarify.");
}
brExp.accept(this);
}
}
unittest
{
import analysis.config;
StaticAnalysisConfig sac;
sac.asm_style_check = true;
assertAnalyzerWarnings(q{
void testAsm()
{
asm
{
mov a, someArray[1]; // [warn]: This is confusing because it looks like an array index. Rewrite a[1] as [a + 1] to clarify.
}
}
}c, sac);
stderr.writeln("Unittest for AsmStyleCheck passed.");
}

View File

@ -90,13 +90,13 @@ unittest
{
import analysis.config;
StaticAnalysisConfig sac;
sac.builtin_property_name_check = true;
sac.builtin_property_names_check = true;
assertAnalyzerWarnings(q{
class SomeClass
{
void init(); //
int init;
auto init = 10;
void init(); // [warn]: Avoid naming members 'init'. This can confuse code that depends on the '.init' property of a type.
int init; // [warn]: Avoid naming members 'init'. This can confuse code that depends on the '.init' property of a type.
auto init = 10; // [warn]: Avoid naming members 'init'. This can confuse code that depends on the '.init' property of a type.
}
}c, sac);

View File

@ -62,4 +62,7 @@ struct StaticAnalysisConfig
@INI("Checks for methods or properties whose names conflict with built-in properties")
bool builtin_property_names_check;
@INI("Checks for confusing code in inline asm statements")
bool asm_style_check;
}

View File

@ -49,7 +49,7 @@ S after(S)(S value, S separator)
* and make sure they match the warnings in the comments. Warnings are
* marked like so: // [warn]: Failed to do somethings.
*/
void assertAnalyzerWarnings(string code, StaticAnalysisConfig config, string file=__FILE__, size_t line=__LINE__)
void assertAnalyzerWarnings(string code, const StaticAnalysisConfig config, string file=__FILE__, size_t line=__LINE__)
{
import analysis.run;

View File

@ -60,7 +60,7 @@ unittest
{
import analysis.config;
StaticAnalysisConfig sac;
sac.if_else_same_check = true;
sac.length_subtraction_check = true;
assertAnalyzerWarnings(q{
void testSizeT()
{

View File

@ -104,22 +104,22 @@ unittest
// Will warn, because none are const
class Dog
{
bool opEquals(Object a, Object b) // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' should be declared const.
bool opEquals(Object a, Object b) // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' are non-const.
{
return true;
}
int opCmp(Object o) // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' should be declared const.
int opCmp(Object o) // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' are non-const.
{
return 1;
}
hash_t toHash() // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' should be declared const.
hash_t toHash() // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' are non-const.
{
return 0;
}
string toString() // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' should be declared const.
string toString() // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' are non-const.
{
return "Dog";
}

View File

@ -27,6 +27,7 @@ import analysis.duplicate_attribute;
import analysis.opequals_without_tohash;
import analysis.length_subtraction;
import analysis.builtin_property_names;
import analysis.asm_style;
void messageFunction(string fileName, size_t line, size_t column, string message,
bool isError)
@ -58,7 +59,7 @@ void analyze(File output, string[] fileNames, StaticAnalysisConfig config, bool
}
// For a string
string[] analyze(string fileName, ubyte[] code, StaticAnalysisConfig analysisConfig, bool staticAnalyze = true)
string[] analyze(string fileName, ubyte[] code, const StaticAnalysisConfig analysisConfig, bool staticAnalyze = true)
{
import std.parallelism;
@ -98,6 +99,7 @@ string[] analyze(string fileName, ubyte[] code, StaticAnalysisConfig analysisCon
if (analysisConfig.opequals_tohash_check) checks ~= new OpEqualsWithoutToHashCheck(fileName);
if (analysisConfig.length_subtraction_check) checks ~= new LengthSubtractionCheck(fileName);
if (analysisConfig.builtin_property_names_check) checks ~= new BuiltinPropertyNameCheck(fileName);
if (analysisConfig.asm_style_check) checks ~= new AsmStyleCheck(fileName);
foreach (check; checks)
{

View File

@ -287,6 +287,14 @@ class UnusedVariableCheck : BaseAnalyzer
blockStatementIntroducesScope = cs;
}
override void visit(const AsmPrimaryExp primary)
{
if (primary.token != tok!"")
variableUsed(primary.token.text);
if (primary.identifierChain !is null)
variableUsed(primary.identifierChain.identifiers[0].text);
}
void variableDeclared(string name, size_t line, size_t column,
bool isParameter, bool isRef)
{
@ -313,7 +321,7 @@ class UnusedVariableCheck : BaseAnalyzer
{
foreach (uu; tree[$ - 1])
{
if (!uu.isRef)
if (!uu.isRef && tree.length > 1)
addErrorMessage(uu.line, uu.column,
(uu.isParameter ? "Parameter " : "Variable ")
~ uu.name ~ " is never used.");

View File

@ -42,16 +42,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</aliasDeclaration>");
}
override void visit(const AliasInitializer aliasInitializer)
{
mixin (tagAndAccept!"aliasInitializer");
}
override void visit(const AliasThisDeclaration aliasThisDeclaration)
{
mixin (tagAndAccept!"aliasThisDeclaration");
}
override void visit(const AlignAttribute alignAttribute)
{
output.writeln("<alignAttribute align=\"", alignAttribute.intLiteral.text, "\">");
@ -87,29 +77,28 @@ class XMLPrinter : ASTVisitor
output.writeln("</andExpression>");
}
override void visit(const ArgumentList argumentList)
override void visit(const AsmInstruction asmInstruction)
{
mixin (tagAndAccept!"argumentList");
}
override void visit(const Arguments arguments)
{
mixin (tagAndAccept!"arguments");
}
override void visit(const ArrayInitializer arrayInitializer)
{
mixin (tagAndAccept!"arrayInitializer");
}
override void visit(const ArrayLiteral arrayLiteral)
{
mixin (tagAndAccept!"arrayLiteral");
}
override void visit(const ArrayMemberInitialization arrayMemberInitialization)
{
mixin (tagAndAccept!"arrayMemberInitialization");
output.writeln("<asmInstruction>");
if (asmInstruction.hasAlign)
{
output.writeln("<align>");
visit(asmInstruction.identifierOrIntegerOrOpcode);
output.writeln("</align>");
}
if (asmInstruction.asmInstruction !is null)
{
output.writeln("<label label=\"", asmInstruction.identifierOrIntegerOrOpcode.text, "\"/>");
asmInstruction.asmInstruction.accept(this);
}
else if (asmInstruction.identifierOrIntegerOrOpcode != tok!"")
visit(asmInstruction.identifierOrIntegerOrOpcode);
if (asmInstruction.operands !is null)
{
stderr.writeln("operands is not null");
visit(asmInstruction.operands);
}
output.writeln("</asmInstruction>");
}
override void visit(const AssertExpression assertExpression)
@ -138,11 +127,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</assignExpression>");
}
override void visit(const AssocArrayLiteral assocArrayLiteral)
{
mixin (tagAndAccept!"assocArrayLiteral");
}
override void visit(const AtAttribute atAttribute)
{
output.writeln("<atAttribute>");
@ -163,12 +147,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</attribute>");
}
override void visit(const AttributeDeclaration attributeDeclaration)
{
assert (attributeDeclaration !is null);
mixin (tagAndAccept!"attributeDeclaration");
}
override void visit(const AutoDeclaration autoDec)
{
output.writeln("<autoDeclaration>");
@ -183,20 +161,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</autoDeclaration>");
}
override void visit(const BlockStatement blockStatement)
{
output.writeln("<blockStatement>");
blockStatement.accept(this);
output.writeln("</blockStatement>");
}
override void visit(const BodyStatement bodyStatement)
{
output.writeln("<bodyStatement>");
bodyStatement.accept(this);
output.writeln("</bodyStatement>");
}
override void visit(const BreakStatement breakStatement)
{
if (breakStatement.label.type == tok!"")
@ -205,16 +169,6 @@ class XMLPrinter : ASTVisitor
output.writeln("<breakStatement label=\"", breakStatement.label.text, "\"/>");
}
override void visit(const BaseClass baseClass)
{
mixin (tagAndAccept!"baseClass");
}
override void visit(const BaseClassList baseClassList)
{
mixin (tagAndAccept!"baseClassList");
}
override void visit(const CaseRangeStatement caseRangeStatement)
{
output.writeln("<caseRangeStatement>");
@ -235,26 +189,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</caseRangeStatement>");
}
override void visit(const CaseStatement caseStatement)
{
mixin (tagAndAccept!"caseStatement");
}
override void visit(const CastExpression castExpression)
{
mixin (tagAndAccept!"castExpression");
}
override void visit(const CastQualifier castQualifier)
{
mixin (tagAndAccept!"castQualifier");
}
override void visit(const Catches catches)
{
mixin (tagAndAccept!"catches");
}
override void visit(const Catch catch_)
{
output.writeln("<catch>");
@ -271,16 +205,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</classDeclaration>");
}
override void visit(const CmpExpression cmpExpression)
{
mixin (tagAndAccept!"cmpExpression");
}
override void visit(const CompileCondition compileCondition)
{
mixin (tagAndAccept!"compileCondition");
}
override void visit(const ConditionalDeclaration conditionalDeclaration)
{
output.writeln("<conditionalDeclaration>");
@ -314,18 +238,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</conditionalStatement>");
}
override void visit(const Constraint constraint)
{
output.writeln("<constraint>");
constraint.accept(this);
output.writeln("</constraint>");
}
override void visit(const Constructor constructor)
{
mixin (tagAndAccept!"constructor");
}
override void visit(const ContinueStatement continueStatement)
{
if (continueStatement.label.type == tok!"")
@ -353,21 +265,6 @@ class XMLPrinter : ASTVisitor
debugSpecification.identifierOrInteger.text, "\"/>");
}
override void visit(const Declaration declaration)
{
mixin (tagAndAccept!"declaration");
}
override void visit(const DeclarationsAndStatements declarationsAndStatements)
{
mixin (tagAndAccept!"declarationsAndStatements");
}
override void visit(const DeclarationOrStatement declarationOrStatement)
{
mixin (tagAndAccept!"declarationOrStatement");
}
override void visit(const Declarator declarator)
{
output.writeln("<declarator line=\"", declarator.name.line, "\">");
@ -377,21 +274,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</declarator>");
}
override void visit(const DefaultStatement defaultStatement)
{
mixin (tagAndAccept!"defaultStatement");
}
override void visit(const DeleteExpression deleteExpression)
{
mixin (tagAndAccept!"deleteExpression");
}
override void visit(const DeleteStatement deleteStatement)
{
mixin (tagAndAccept!"deleteStatement");
}
override void visit(const Deprecated deprecated_)
{
if (deprecated_.assignExpression !is null)
@ -404,21 +286,6 @@ class XMLPrinter : ASTVisitor
output.writeln("<deprecated/>");
}
override void visit(const Destructor destructor)
{
mixin (tagAndAccept!"destructor");
}
override void visit(const DoStatement doStatement)
{
mixin (tagAndAccept!"doStatement");
}
override void visit(const EnumBody enumBody)
{
mixin (tagAndAccept!"enumBody");
}
override void visit(const EnumDeclaration enumDec)
{
output.writeln("<enumDeclaration line=\"", enumDec.name.line, "\">");
@ -449,27 +316,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</equalExpression>");
}
override void visit(const Expression expression)
{
output.writeln("<expression>");
expression.accept(this);
output.writeln("</expression>");
}
override void visit(const ExpressionStatement expressionStatement)
{
output.writeln("<expressionStatement>");
expressionStatement.accept(this);
output.writeln("</expressionStatement>");
}
override void visit(const FinalSwitchStatement finalSwitchStatement)
{
output.writeln("<finalSwitchStatement>");
finalSwitchStatement.accept(this);
output.writeln("</finalSwitchStatement>");
}
override void visit(const Finally finally_)
{
output.writeln("<finally>");
@ -538,31 +384,6 @@ class XMLPrinter : ASTVisitor
}
override void visit(const ForeachTypeList foreachTypeList)
{
mixin (tagAndAccept!"foreachTypeList");
}
override void visit(const FunctionAttribute functionAttribute)
{
mixin (tagAndAccept!"functionAttribute");
}
override void visit(const FunctionBody functionBody)
{
mixin (tagAndAccept!"functionBody");
}
override void visit(const FunctionCallExpression functionCallExpression)
{
mixin (tagAndAccept!"functionCallExpression");
}
override void visit(const FunctionCallStatement functionCallStatement)
{
mixin (tagAndAccept!"functionCallStatement");
}
override void visit(const FunctionDeclaration functionDec)
{
output.writeln("<functionDeclaration line=\"", functionDec.name.line, "\">");
@ -603,26 +424,6 @@ class XMLPrinter : ASTVisitor
}
}
override void visit(const IdentifierChain identifierChain)
{
mixin (tagAndAccept!"identifierChain");
}
override void visit(const IdentifierList identifierList)
{
mixin (tagAndAccept!"identifierList");
}
override void visit(const IdentifierOrTemplateChain identifierOrTemplateChain)
{
mixin (tagAndAccept!"identifierOrTemplateChain");
}
override void visit(const IdentifierOrTemplateInstance identifierOrTemplateInstance)
{
mixin (tagAndAccept!"identifierOrTemplateInstance");
}
override void visit(const IdentityExpression identityExpression)
{
if (identityExpression.negated)
@ -676,26 +477,6 @@ class XMLPrinter : ASTVisitor
"\" rename=\"", importBind.left.text, "\"/>");
}
override void visit(const ImportBindings importBindings)
{
mixin (tagAndAccept!"importBindings");
}
override void visit(const ImportDeclaration importDeclaration)
{
mixin (tagAndAccept!"importDeclaration");
}
override void visit(const ImportExpression importExpression)
{
mixin (tagAndAccept!"importExpression");
}
override void visit(const IndexExpression indexExpression)
{
mixin (tagAndAccept!"indexExpression");
}
override void visit(const InExpression inExpression)
{
if (inExpression.negated)
@ -711,11 +492,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</inExpression>");
}
override void visit(const InStatement inStatement)
{
mixin (tagAndAccept!"inStatement");
}
override void visit(const Initialize initialize)
{
if (initialize.statementNoCaseNoDefault is null)
@ -788,11 +564,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</keyValuePair>");
}
override void visit(const KeyValuePairs keyValuePairs)
{
mixin (tagAndAccept!"keyValuePairs");
}
override void visit (const LabeledStatement labeledStatement)
{
output.writeln("<labeledStatement label=\"",
@ -812,11 +583,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</lambdaExpression>");
}
override void visit(const LastCatch lastCatch)
{
mixin (tagAndAccept!"lastCatch");
}
override void visit(const LinkageAttribute linkageAttribute)
{
if (linkageAttribute.hasPlusPlus)
@ -836,26 +602,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</memberFunctionAttribute>");
}
override void visit(const MixinDeclaration mixinDeclaration)
{
mixin (tagAndAccept!"mixinDeclaration");
}
override void visit(const MixinExpression mixinExpression)
{
mixin (tagAndAccept!"mixinExpression");
}
override void visit(const MixinTemplateDeclaration mixinTemplateDeclaration)
{
mixin (tagAndAccept!"mixinTemplateDeclaration");
}
override void visit(const MixinTemplateName mixinTemplateName)
{
mixin (tagAndAccept!"mixinTemplateName");
}
override void visit(const Module module_)
{
output.writeln("<?xml version=\"1.0\"?>");
@ -864,11 +610,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</module>");
}
override void visit(const ModuleDeclaration moduleDeclaration)
{
mixin (tagAndAccept!"moduleDeclaration");
}
override void visit(const MulExpression mulExpression)
{
output.writeln("<mulExpression operator=\"", str(mulExpression.operator) ,"\">");
@ -884,41 +625,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</mulExpression>");
}
override void visit(const NewAnonClassExpression newAnonClassExpression)
{
mixin (tagAndAccept!"newAnonClassExpression");
}
override void visit(const NewExpression newExpression)
{
mixin (tagAndAccept!"newExpression");
}
override void visit(const StatementNoCaseNoDefault statementNoCaseNoDefault)
{
mixin (tagAndAccept!"statementNoCaseNoDefault");
}
override void visit(const NonVoidInitializer nonVoidInitializer)
{
mixin (tagAndAccept!"nonVoidInitializer");
}
override void visit(const OrExpression orExpression)
{
mixin (tagAndAccept!"orExpression");
}
override void visit(const OrOrExpression orOrExpression)
{
mixin (tagAndAccept!"orOrExpression");
}
override void visit(const OutStatement outStatement)
{
mixin (tagAndAccept!"outStatement");
}
override void visit(const Parameter param)
{
output.writeln("<parameter>");
@ -934,16 +640,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</parameter>");
}
override void visit(const Parameters parameters)
{
mixin (tagAndAccept!"parameters");
}
override void visit(const Postblit postblit)
{
mixin (tagAndAccept!"postblit");
}
override void visit(const PostIncDecExpression postIncDecExpression)
{
output.writeln("<postIncDecExpression operator=\"",
@ -967,16 +663,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</powExpression>");
}
override void visit(const PragmaDeclaration pragmaDeclaration)
{
mixin (tagAndAccept!"pragmaDeclaration");
}
override void visit(const PragmaExpression pragmaExpression)
{
mixin (tagAndAccept!"pragmaExpression");
}
override void visit(const PreIncDecExpression preIncDecExpression)
{
output.writeln("<preIncDecExpression operator=\"",
@ -985,13 +671,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</preIncDecExpression>");
}
override void visit(const PrimaryExpression primaryExpression)
{
mixin (tagAndAccept!"primaryExpression");
}
// TODO: Register
override void visit(const RelExpression relExpression)
{
output.writeln("<relExpression operator=\"",
@ -1017,21 +696,6 @@ class XMLPrinter : ASTVisitor
}
}
override void visit(const ScopeGuardStatement scopeGuardStatement)
{
mixin (tagAndAccept!"scopeGuardStatement");
}
override void visit(const SharedStaticConstructor sharedStaticConstructor)
{
mixin (tagAndAccept!"sharedStaticConstructor");
}
override void visit(const SharedStaticDestructor sharedStaticDestructor)
{
mixin (tagAndAccept!"sharedStaticDestructor");
}
override void visit(const ShiftExpression shiftExpression)
{
output.writeln("<shiftExpression operator=\"",
@ -1074,46 +738,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</sliceExpression>");
}
override void visit(const Statement statement)
{
mixin (tagAndAccept!"statement");
}
override void visit(const StaticAssertDeclaration staticAssertDeclaration)
{
mixin (tagAndAccept!"staticAssertDeclaration");
}
override void visit(const StaticAssertStatement staticAssertStatement)
{
mixin (tagAndAccept!"staticAssertStatement");
}
override void visit(const StaticConstructor staticConstructor)
{
mixin (tagAndAccept!"staticConstructor");
}
override void visit(const StaticDestructor staticDestructor)
{
mixin (tagAndAccept!"staticDestructor");
}
override void visit(const StaticIfCondition staticIfCondition)
{
mixin (tagAndAccept!"staticIfCondition");
}
override void visit(const StorageClass storageClass)
{
mixin (tagAndAccept!"storageClass");
}
override void visit(const StructBody structBody)
{
mixin (tagAndAccept!"structBody");
}
override void visit(const StructDeclaration structDec)
{
output.writeln("<structDeclaration line=\"", structDec.name.line, "\">");
@ -1123,36 +747,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</structDeclaration>");
}
override void visit(const StructInitializer structInitializer)
{
mixin (tagAndAccept!"structInitializer");
}
override void visit(const StructMemberInitializer structMemberInitializer)
{
mixin (tagAndAccept!"structMemberInitializer");
}
override void visit(const StructMemberInitializers structMemberInitializers)
{
mixin (tagAndAccept!"structMemberInitializers");
}
override void visit(const SwitchStatement switchStatement)
{
mixin (tagAndAccept!"switchStatement");
}
override void visit(const Symbol symbol)
{
mixin (tagAndAccept!"symbol");
}
override void visit(const SynchronizedStatement synchronizedStatement)
{
mixin (tagAndAccept!"synchronizedStatement");
}
override void visit(const TemplateAliasParameter templateAliasParameter)
{
output.writeln("<templateAliasParameter>");
@ -1188,26 +782,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</templateAliasParameter>");
}
override void visit(const TemplateArgument templateArgument)
{
mixin (tagAndAccept!"templateArgument");
}
override void visit(const TemplateArgumentList templateArgumentList)
{
mixin (tagAndAccept!"templateArgumentList");
}
override void visit(const TemplateArguments templateArguments)
{
mixin (tagAndAccept!"templateArguments");
}
override void visit (const EponymousTemplateDeclaration eponymousTemplateDeclaration)
{
mixin (tagAndAccept!"eponymousTemplateDeclaration");
}
override void visit(const TemplateDeclaration templateDeclaration)
{
if (templateDeclaration.eponymousTemplateDeclaration !is null)
@ -1231,71 +805,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</templateDeclaration>");
}
override void visit(const TemplateInstance templateInstance)
{
mixin (tagAndAccept!"templateInstance");
}
override void visit(const TemplateMixinExpression templateMixinExpression)
{
mixin (tagAndAccept!"templateMixinExpression");
}
override void visit(const TemplateParameter templateParameter)
{
mixin (tagAndAccept!"templateParameter");
}
override void visit(const TemplateParameterList templateParameterList)
{
mixin (tagAndAccept!"templateParameterList");
}
override void visit(const TemplateParameters templateParameters)
{
mixin (tagAndAccept!"templateParameters");
}
override void visit(const TemplateSingleArgument templateSingleArgument)
{
mixin (tagAndAccept!"templateSingleArgument");
}
override void visit(const TemplateThisParameter templateThisParameter)
{
mixin (tagAndAccept!"templateThisParameter");
}
override void visit(const TemplateTupleParameter templateTupleParameter)
{
mixin (tagAndAccept!"templateTupleParameter");
}
override void visit(const TemplateTypeParameter templateTypeParameter)
{
mixin (tagAndAccept!"templateTypeParameter");
}
override void visit(const TemplateValueParameter templateValueParameter)
{
mixin (tagAndAccept!"templateValueParameter");
}
override void visit(const TemplateValueParameterDefault templateValueParameterDefault)
{
mixin (tagAndAccept!"templateValueParameterDefault");
}
override void visit(const TernaryExpression ternaryExpression)
{
mixin (tagAndAccept!"ternaryExpression");
}
override void visit(const ThrowStatement throwStatement)
{
mixin (tagAndAccept!"throwStatement");
}
override void visit(const Token token)
{
string tagName;
@ -1325,16 +834,6 @@ class XMLPrinter : ASTVisitor
output.writeln("<", tagName, ">", xmlEscape(token.text), "</", tagName, ">");
}
override void visit(const TraitsExpression traitsExpression)
{
mixin (tagAndAccept!"traitsExpression");
}
override void visit(const TryStatement tryStatement)
{
mixin (tagAndAccept!"tryStatement");
}
override void visit(const Type type)
{
auto app = appender!string();
@ -1357,11 +856,6 @@ class XMLPrinter : ASTVisitor
}
}
override void visit(const TypeSpecialization typeSpecialization)
{
mixin (tagAndAccept!"typeSpecialization");
}
override void visit(const TypeSuffix typeSuffix)
{
if (typeSuffix.star)
@ -1407,16 +901,6 @@ class XMLPrinter : ASTVisitor
}
}
override void visit(const TypeidExpression typeidExpression)
{
mixin (tagAndAccept!"typeidExpression");
}
override void visit(const TypeofExpression typeofExpression)
{
mixin (tagAndAccept!"typeofExpression");
}
override void visit(const UnaryExpression unaryExpression)
{
output.writeln("<unaryExpression>");
@ -1467,31 +951,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</variableDeclaration>");
}
override void visit(const Vector vector)
{
mixin (tagAndAccept!"vector");
}
override void visit(const VersionCondition versionCondition)
{
mixin (tagAndAccept!"versionCondition");
}
override void visit(const VersionSpecification versionSpecification)
{
mixin (tagAndAccept!"versionSpecification");
}
override void visit(const WhileStatement whileStatement)
{
mixin (tagAndAccept!"whileStatement");
}
override void visit(const WithStatement withStatement)
{
mixin (tagAndAccept!"withStatement");
}
override void visit(const XorExpression xorExpression)
{
output.writeln("<xorExpression>");
@ -1507,6 +966,125 @@ class XMLPrinter : ASTVisitor
output.writeln("</xorExpression>");
}
override void visit(const AliasInitializer aliasInitializer) { mixin (tagAndAccept!"aliasInitializer"); }
override void visit(const AliasThisDeclaration aliasThisDeclaration) { mixin (tagAndAccept!"aliasThisDeclaration"); }
override void visit(const ArgumentList argumentList) { mixin (tagAndAccept!"argumentList"); }
override void visit(const Arguments arguments) { mixin (tagAndAccept!"arguments"); }
override void visit(const ArrayInitializer arrayInitializer) { mixin (tagAndAccept!"arrayInitializer"); }
override void visit(const ArrayLiteral arrayLiteral) { mixin (tagAndAccept!"arrayLiteral"); }
override void visit(const ArrayMemberInitialization arrayMemberInitialization) { mixin (tagAndAccept!"arrayMemberInitialization"); }
override void visit(const AsmAddExp asmAddExp) { mixin (tagAndAccept!"asmAddExp"); }
override void visit(const AsmAndExp asmAndExp) { mixin (tagAndAccept!"asmAndExp"); }
override void visit(const AsmBrExp asmBrExp) { mixin (tagAndAccept!"asmBrExp"); }
override void visit(const AsmEqualExp asmEqualExp) { mixin (tagAndAccept!"asmEqualExp"); }
override void visit(const AsmExp asmExp) { mixin (tagAndAccept!"asmExp"); }
override void visit(const AsmLogAndExp asmLogAndExp) { mixin (tagAndAccept!"asmLogAndExp"); }
override void visit(const AsmLogOrExp asmLogOrExp) { mixin (tagAndAccept!"asmLogOrExp"); }
override void visit(const AsmMulExp asmMulExp) { mixin (tagAndAccept!"asmMulExp"); }
override void visit(const AsmOrExp asmOrExp) { mixin (tagAndAccept!"asmOrExp"); }
override void visit(const AsmPrimaryExp asmPrimaryExp) { mixin (tagAndAccept!"asmPrimaryExp"); }
override void visit(const AsmRelExp asmRelExp) { mixin (tagAndAccept!"asmRelExp"); }
override void visit(const AsmShiftExp asmShiftExp) { mixin (tagAndAccept!"asmShiftExp"); }
override void visit(const AsmStatement asmStatement) { mixin (tagAndAccept!"asmStatement"); }
override void visit(const AsmTypePrefix asmTypePrefix) { mixin (tagAndAccept!"asmTypePrefix"); }
override void visit(const AsmUnaExp asmUnaExp) { mixin (tagAndAccept!"asmUnaExp"); }
override void visit(const AsmXorExp asmXorExp) { mixin (tagAndAccept!"asmXorExp"); }
override void visit(const AssocArrayLiteral assocArrayLiteral) { mixin (tagAndAccept!"assocArrayLiteral"); }
override void visit(const AttributeDeclaration attributeDeclaration) { mixin (tagAndAccept!"attributeDeclaration"); }
override void visit(const BaseClass baseClass) { mixin (tagAndAccept!"baseClass"); }
override void visit(const BaseClassList baseClassList) { mixin (tagAndAccept!"baseClassList"); }
override void visit(const BlockStatement blockStatement) { mixin (tagAndAccept!"blockStatement"); }
override void visit(const BodyStatement bodyStatement) { mixin (tagAndAccept!"bodyStatement"); }
override void visit(const CaseStatement caseStatement) { mixin (tagAndAccept!"caseStatement"); }
override void visit(const CastExpression castExpression) { mixin (tagAndAccept!"castExpression"); }
override void visit(const CastQualifier castQualifier) { mixin (tagAndAccept!"castQualifier"); }
override void visit(const Catches catches) { mixin (tagAndAccept!"catches"); }
override void visit(const CmpExpression cmpExpression) { mixin (tagAndAccept!"cmpExpression"); }
override void visit(const CompileCondition compileCondition) { mixin (tagAndAccept!"compileCondition"); }
override void visit(const Constraint constraint) { mixin (tagAndAccept!"constraint"); }
override void visit(const Constructor constructor) { mixin (tagAndAccept!"constructor"); }
override void visit(const Declaration declaration) { mixin (tagAndAccept!"declaration"); }
override void visit(const DeclarationOrStatement declarationOrStatement) { mixin (tagAndAccept!"declarationOrStatement"); }
override void visit(const DeclarationsAndStatements declarationsAndStatements) { mixin (tagAndAccept!"declarationsAndStatements"); }
override void visit(const DefaultStatement defaultStatement) { mixin (tagAndAccept!"defaultStatement"); }
override void visit(const DeleteExpression deleteExpression) { mixin (tagAndAccept!"deleteExpression"); }
override void visit(const DeleteStatement deleteStatement) { mixin (tagAndAccept!"deleteStatement"); }
override void visit(const Destructor destructor) { mixin (tagAndAccept!"destructor"); }
override void visit(const DoStatement doStatement) { mixin (tagAndAccept!"doStatement"); }
override void visit(const EnumBody enumBody) { mixin (tagAndAccept!"enumBody"); }
override void visit(const EponymousTemplateDeclaration eponymousTemplateDeclaration) { mixin (tagAndAccept!"eponymousTemplateDeclaration"); }
override void visit(const Expression expression) { mixin (tagAndAccept!"expression"); }
override void visit(const ExpressionStatement expressionStatement) { mixin (tagAndAccept!"expressionStatement"); }
override void visit(const FinalSwitchStatement finalSwitchStatement) { mixin (tagAndAccept!"finalSwitchStatement"); }
override void visit(const ForeachTypeList foreachTypeList) { mixin (tagAndAccept!"foreachTypeList"); }
override void visit(const FunctionAttribute functionAttribute) { mixin (tagAndAccept!"functionAttribute"); }
override void visit(const FunctionBody functionBody) { mixin (tagAndAccept!"functionBody"); }
override void visit(const FunctionCallExpression functionCallExpression) { mixin (tagAndAccept!"functionCallExpression"); }
override void visit(const FunctionCallStatement functionCallStatement) { mixin (tagAndAccept!"functionCallStatement"); }
override void visit(const IdentifierChain identifierChain) { mixin (tagAndAccept!"identifierChain"); }
override void visit(const IdentifierList identifierList) { mixin (tagAndAccept!"identifierList"); }
override void visit(const IdentifierOrTemplateChain identifierOrTemplateChain) { mixin (tagAndAccept!"identifierOrTemplateChain"); }
override void visit(const IdentifierOrTemplateInstance identifierOrTemplateInstance) { mixin (tagAndAccept!"identifierOrTemplateInstance"); }
override void visit(const ImportBindings importBindings) { mixin (tagAndAccept!"importBindings"); }
override void visit(const ImportDeclaration importDeclaration) { mixin (tagAndAccept!"importDeclaration"); }
override void visit(const ImportExpression importExpression) { mixin (tagAndAccept!"importExpression"); }
override void visit(const IndexExpression indexExpression) { mixin (tagAndAccept!"indexExpression"); }
override void visit(const InStatement inStatement) { mixin (tagAndAccept!"inStatement"); }
override void visit(const KeyValuePairs keyValuePairs) { mixin (tagAndAccept!"keyValuePairs"); }
override void visit(const MixinExpression mixinExpression) { mixin (tagAndAccept!"mixinExpression"); }
override void visit(const MixinTemplateDeclaration mixinTemplateDeclaration) { mixin (tagAndAccept!"mixinTemplateDeclaration"); }
override void visit(const MixinTemplateName mixinTemplateName) { mixin (tagAndAccept!"mixinTemplateName"); } override void visit(const ModuleDeclaration moduleDeclaration) { mixin (tagAndAccept!"moduleDeclaration"); } override void visit(const LastCatch lastCatch) { mixin (tagAndAccept!"lastCatch"); }
override void visit(const NewExpression newExpression) { mixin (tagAndAccept!"newExpression"); }
override void visit(const NonVoidInitializer nonVoidInitializer) { mixin (tagAndAccept!"nonVoidInitializer"); }
override void visit(const Operands operands) { mixin (tagAndAccept!"operands"); }
override void visit(const OrExpression orExpression) { mixin (tagAndAccept!"orExpression"); }
override void visit(const OrOrExpression orOrExpression) { mixin (tagAndAccept!"orOrExpression"); }
override void visit(const OutStatement outStatement) { mixin (tagAndAccept!"outStatement"); } override void visit(const MixinDeclaration mixinDeclaration) { mixin (tagAndAccept!"mixinDeclaration"); }
override void visit(const Parameters parameters) { mixin (tagAndAccept!"parameters"); }
override void visit(const Postblit postblit) { mixin (tagAndAccept!"postblit"); } override void visit(const NewAnonClassExpression newAnonClassExpression) { mixin (tagAndAccept!"newAnonClassExpression"); }
override void visit(const PragmaDeclaration pragmaDeclaration) { mixin (tagAndAccept!"pragmaDeclaration"); }
override void visit(const PragmaExpression pragmaExpression) { mixin (tagAndAccept!"pragmaExpression"); }
override void visit(const PrimaryExpression primaryExpression) { mixin (tagAndAccept!"primaryExpression"); }
override void visit(const ScopeGuardStatement scopeGuardStatement) { mixin (tagAndAccept!"scopeGuardStatement"); }
override void visit(const SharedStaticConstructor sharedStaticConstructor) { mixin (tagAndAccept!"sharedStaticConstructor"); }
override void visit(const SharedStaticDestructor sharedStaticDestructor) { mixin (tagAndAccept!"sharedStaticDestructor"); }
override void visit(const StatementNoCaseNoDefault statementNoCaseNoDefault) { mixin (tagAndAccept!"statementNoCaseNoDefault"); }
override void visit(const StaticAssertDeclaration staticAssertDeclaration) { mixin (tagAndAccept!"staticAssertDeclaration"); }
override void visit(const StaticAssertStatement staticAssertStatement) { mixin (tagAndAccept!"staticAssertStatement"); }
override void visit(const StaticConstructor staticConstructor) { mixin (tagAndAccept!"staticConstructor"); }
override void visit(const StaticDestructor staticDestructor) { mixin (tagAndAccept!"staticDestructor"); }
override void visit(const StaticIfCondition staticIfCondition) { mixin (tagAndAccept!"staticIfCondition"); }
override void visit(const StorageClass storageClass) { mixin (tagAndAccept!"storageClass"); }
override void visit(const StructBody structBody) { mixin (tagAndAccept!"structBody"); }
override void visit(const StructInitializer structInitializer) { mixin (tagAndAccept!"structInitializer"); }
override void visit(const StructMemberInitializers structMemberInitializers) { mixin (tagAndAccept!"structMemberInitializers"); }
override void visit(const StructMemberInitializer structMemberInitializer) { mixin (tagAndAccept!"structMemberInitializer"); }
override void visit(const SwitchStatement switchStatement) { mixin (tagAndAccept!"switchStatement"); }
override void visit(const Symbol symbol) { mixin (tagAndAccept!"symbol"); }
override void visit(const SynchronizedStatement synchronizedStatement) { mixin (tagAndAccept!"synchronizedStatement"); } override void visit(const Statement statement) { mixin (tagAndAccept!"statement"); }
override void visit(const TemplateArgumentList templateArgumentList) { mixin (tagAndAccept!"templateArgumentList"); }
override void visit(const TemplateArguments templateArguments) { mixin (tagAndAccept!"templateArguments"); }
override void visit(const TemplateArgument templateArgument) { mixin (tagAndAccept!"templateArgument"); }
override void visit(const TemplateMixinExpression templateMixinExpression) { mixin (tagAndAccept!"templateMixinExpression"); }
override void visit(const TemplateParameterList templateParameterList) { mixin (tagAndAccept!"templateParameterList"); }
override void visit(const TemplateParameters templateParameters) { mixin (tagAndAccept!"templateParameters"); }
override void visit(const TemplateParameter templateParameter) { mixin (tagAndAccept!"templateParameter"); }
override void visit(const TemplateSingleArgument templateSingleArgument) { mixin (tagAndAccept!"templateSingleArgument"); }
override void visit(const TemplateThisParameter templateThisParameter) { mixin (tagAndAccept!"templateThisParameter"); }
override void visit(const TemplateTupleParameter templateTupleParameter) { mixin (tagAndAccept!"templateTupleParameter"); }
override void visit(const TemplateTypeParameter templateTypeParameter) { mixin (tagAndAccept!"templateTypeParameter"); }
override void visit(const TemplateValueParameterDefault templateValueParameterDefault) { mixin (tagAndAccept!"templateValueParameterDefault"); }
override void visit(const TemplateValueParameter templateValueParameter) { mixin (tagAndAccept!"templateValueParameter"); }
override void visit(const TernaryExpression ternaryExpression) { mixin (tagAndAccept!"ternaryExpression"); }
override void visit(const ThrowStatement throwStatement) { mixin (tagAndAccept!"throwStatement"); }
override void visit(const TryStatement tryStatement) { mixin (tagAndAccept!"tryStatement"); } override void visit(const TemplateInstance templateInstance) { mixin (tagAndAccept!"templateInstance"); }
override void visit(const TypeofExpression typeofExpression) { mixin (tagAndAccept!"typeofExpression"); } override void visit(const TypeSpecialization typeSpecialization) { mixin (tagAndAccept!"typeSpecialization"); } override void visit(const TraitsExpression traitsExpression) { mixin (tagAndAccept!"traitsExpression"); }
override void visit(const Vector vector) { mixin (tagAndAccept!"vector"); }
override void visit(const VersionCondition versionCondition) { mixin (tagAndAccept!"versionCondition"); }
override void visit(const VersionSpecification versionSpecification) { mixin (tagAndAccept!"versionSpecification"); }
override void visit(const WhileStatement whileStatement) { mixin (tagAndAccept!"whileStatement"); }
override void visit(const WithStatement withStatement) { mixin (tagAndAccept!"withStatement"); } override void visit(const TypeidExpression typeidExpression) { mixin (tagAndAccept!"typeidExpression"); }
alias visit = ASTVisitor.visit;
private static string xmlEscape(string s)

@ -1 +1 @@
Subproject commit acb6b43655b1144fbcaf08ec0442a81143cdb569
Subproject commit cef8259a0d9f153bea6ca8c86812e714206ceaed

View File

@ -17,9 +17,13 @@ SRC = main.d\
inifiled/source/*.d
INCLUDE_PATHS = -Ilibdparse/src
VERSIONS =
DEBUG_VERSIONS = -version=std_parser_verbose
all: dmdbuild
debug:
${DMD} -ofdsc ${VERSIONS} ${DEBUG_VERSIONS} ${INCLUDE_PATHS} ${SRC}
dmdbuild:
${DMD} -O -release -inline -ofdscanner ${VERSIONS} ${INCLUDE_PATHS} ${SRC}

View File

@ -3,13 +3,7 @@ rm -f test
rm -f test.o
dmd\
main.d\
stats.d\
imports.d\
highlighter.d\
ctags.d\
astprinter.d\
outliner.d\
*.d\
libdparse/src/std/*.d\
libdparse/src/std/d/*.d\
inifiled/source/*.d\