fix tab and create routine for gen exception type

This commit is contained in:
Basile Burg 2018-05-25 23:36:02 +02:00
parent aa7bdf81c6
commit a0010d6a8a
1 changed files with 38 additions and 42 deletions

View File

@ -51,49 +51,45 @@ final class ProperlyDocumentedPublicFunctions : BaseAnalyzer
postCheckSeenDdocParams(); postCheckSeenDdocParams();
} }
override void visit(const UnaryExpression decl) override void visit(const UnaryExpression decl)
{ {
const IdentifierOrTemplateInstance iot = safeAccess(decl) const IdentifierOrTemplateInstance iot = safeAccess(decl)
.functionCallExpression.unaryExpression.primaryExpression .functionCallExpression.unaryExpression.primaryExpression
.identifierOrTemplateInstance; .identifierOrTemplateInstance;
// enforce(condition); Type newNamedType(N)(N name)
if (iot && iot.identifier.text == "enforce") {
{ Type t = new Type;
Type tt = new Type; t.type2 = new Type2;
tt.type2 = new Type2; t.type2.typeIdentifierPart = new TypeIdentifierPart;
tt.type2.typeIdentifierPart = new TypeIdentifierPart; t.type2.typeIdentifierPart.identifierOrTemplateInstance = new IdentifierOrTemplateInstance;
tt.type2.typeIdentifierPart.identifierOrTemplateInstance = t.type2.typeIdentifierPart.identifierOrTemplateInstance.identifier = name;
new IdentifierOrTemplateInstance; return t;
tt.type2.typeIdentifierPart.identifierOrTemplateInstance.identifier = }
Token(tok!"identifier", "Exception", 0, 0, 0);
thrown ~= tt; // enforce(condition);
} if (iot && iot.identifier.text == "enforce")
else if (iot && iot.templateInstance && iot.templateInstance.identifier.text == "enforce") {
{ thrown ~= newNamedType(Token(tok!"identifier", "Exception", 0, 0, 0));
// enforce!Type(condition); }
if (const TemplateSingleArgument tsa = safeAccess(iot.templateInstance) else if (iot && iot.templateInstance && iot.templateInstance.identifier.text == "enforce")
.templateArguments.templateSingleArgument) {
{ // enforce!Type(condition);
Type tt = new Type; if (const TemplateSingleArgument tsa = safeAccess(iot.templateInstance)
tt.type2 = new Type2; .templateArguments.templateSingleArgument)
tt.type2.typeIdentifierPart = new TypeIdentifierPart; {
tt.type2.typeIdentifierPart.identifierOrTemplateInstance = thrown ~= newNamedType(tsa.token);
new IdentifierOrTemplateInstance; }
tt.type2.typeIdentifierPart.identifierOrTemplateInstance.identifier = // enforce!(Type)(condition);
tsa.token; else if (const TemplateArgumentList tal = safeAccess(iot.templateInstance)
thrown ~= tt; .templateArguments.templateArgumentList)
} {
// enforce!(Type)(condition); if (tal.items.length && tal.items[0].type)
else if (const TemplateArgumentList tal = safeAccess(iot.templateInstance) thrown ~= tal.items[0].type;
.templateArguments.templateArgumentList) }
{ }
if (tal.items.length && tal.items[0].type) decl.accept(this);
thrown ~= tal.items[0].type; }
}
}
decl.accept(this);
}
override void visit(const Declaration decl) override void visit(const Declaration decl)
{ {