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

@ -57,17 +57,20 @@ final class ProperlyDocumentedPublicFunctions : BaseAnalyzer
.functionCallExpression.unaryExpression.primaryExpression
.identifierOrTemplateInstance;
Type newNamedType(N)(N name)
{
Type t = new Type;
t.type2 = new Type2;
t.type2.typeIdentifierPart = new TypeIdentifierPart;
t.type2.typeIdentifierPart.identifierOrTemplateInstance = new IdentifierOrTemplateInstance;
t.type2.typeIdentifierPart.identifierOrTemplateInstance.identifier = name;
return t;
}
// enforce(condition);
if (iot && iot.identifier.text == "enforce")
{
Type tt = new Type;
tt.type2 = new Type2;
tt.type2.typeIdentifierPart = new TypeIdentifierPart;
tt.type2.typeIdentifierPart.identifierOrTemplateInstance =
new IdentifierOrTemplateInstance;
tt.type2.typeIdentifierPart.identifierOrTemplateInstance.identifier =
Token(tok!"identifier", "Exception", 0, 0, 0);
thrown ~= tt;
thrown ~= newNamedType(Token(tok!"identifier", "Exception", 0, 0, 0));
}
else if (iot && iot.templateInstance && iot.templateInstance.identifier.text == "enforce")
{
@ -75,14 +78,7 @@ final class ProperlyDocumentedPublicFunctions : BaseAnalyzer
if (const TemplateSingleArgument tsa = safeAccess(iot.templateInstance)
.templateArguments.templateSingleArgument)
{
Type tt = new Type;
tt.type2 = new Type2;
tt.type2.typeIdentifierPart = new TypeIdentifierPart;
tt.type2.typeIdentifierPart.identifierOrTemplateInstance =
new IdentifierOrTemplateInstance;
tt.type2.typeIdentifierPart.identifierOrTemplateInstance.identifier =
tsa.token;
thrown ~= tt;
thrown ~= newNamedType(tsa.token);
}
// enforce!(Type)(condition);
else if (const TemplateArgumentList tal = safeAccess(iot.templateInstance)