public GrapeMethod(GrapeList<GrapeModifier> modifiers, GrapeType returnType, GrapeIdentifier name, GrapeList<GrapeParameter> parameters, GrapeList<GrapeStatement> body) : base(modifiers) { this.returnType = returnType; this.name = name.Name; this.parameters = parameters.ToList(this).AsReadOnly(); this.body = body.ToList(this).AsReadOnly(); }
internal static GrapeCallExpression Create(GrapeIdentifier identifier, GrapeList<GrapeExpression> parameters, GrapeAccessExpression next) { List<GrapeEntity> children = new List<GrapeEntity>(); children.Add(identifier); children.AddRange(parameters.Enumerate()); GrapeCallExpression result = new GrapeCallExpression(identifier, parameters, next); result.InitializeFromTemplate(identifier); result.InitializeFromChildren(identifier.FileName, children); return result; }
public GrapeClass(GrapeList<GrapeModifier> modifiers, GrapeIdentifier identifier, GrapeOptional<GrapeLiteralExpression<int>> size, GrapeOptional<GrapeSimpleType> inherits, GrapeList<GrapeClassItem> classItems) : base(modifiers) { GrapeLiteralExpression<int> sizeLiteral = size; this.size = (sizeLiteral == null) ? default(int?) : sizeLiteral.Value; this.inherits = inherits; this.classItems = classItems.ToList(this).AsReadOnly(); name = identifier.Name; }
public GrapeFinallyClause(GrapeList<GrapeStatement> statements): base(statements) {}
public GrapeConditionalStatement(GrapeExpression condition, GrapeList<GrapeStatement> statements, GrapeConditionalStatement elseStatement): base(statements) { this.condition = condition; this.elseStatement = (elseStatement != null) && (elseStatement.Statements.Count > 0) ? elseStatement : null; }
public GrapeConditionalStatement(GrapeList<GrapeStatement> statements): this(null, statements, null) {}
public GrapeArrayInitializer(GrapeList<GrapeInitializer> initializers) { this.initializers = initializers.ToList(this).AsReadOnly(); }
protected GrapeClassItem(GrapeList<GrapeModifier> modifiers) { this.modifiers = modifiers.Merge(GrapeModifier.GrapeModifierType.Public); }
public GrapeMethodCall(GrapeMember ofMember, GrapeList<GrapeExpression> parameters) : base(ofMember, new GrapeList<GrapeIdentifier>(ofMember.PopIdentifier())) { this.parameters = parameters; }
public GrapeConstructor(GrapeList<GrapeModifier> modifiers, GrapeIdentifier name, GrapeList<GrapeParameter> parameters, GrapeList<GrapeStatement> body): base(modifiers, name, parameters, body) {}
public GrapeMember(GrapeMember ofMember, GrapeList<GrapeIdentifier> identifiers) { this.ofMember = ofMember; this.identifiers = identifiers.ToList(this); }
public GrapeCatchClause(GrapeSimpleType exceptionType, GrapeIdentifier variableIdentifier, GrapeList<GrapeStatement> statements): base(statements) { this.exceptionType = exceptionType; exceptionVariable = GrapeVariable.Create(exceptionType, variableIdentifier); }
public GrapeArrayType(GrapeList<GrapeIdentifier> nameParts): this(new GrapeSimpleType(nameParts)) {}
public GrapeCatchClause(GrapeSimpleType exceptionType, GrapeList<GrapeStatement> statements): this(exceptionType, null, statements) {}
public GrapeCatchClause(GrapeList<GrapeStatement> statements): this(null, null, statements) {}
protected GrapeStatementWithBlock(GrapeList<GrapeStatement> statements) { this.statements = statements.ToList(this).AsReadOnly(); }
public GrapeMethod(GrapeList<GrapeModifier> modifiers, GrapeIdentifier name, GrapeList<GrapeParameter> parameters, GrapeList<GrapeStatement> body) : this(modifiers, null, name, parameters, body) { }
public GrapeMember(GrapeObject grapeObject, GrapeList<GrapeIdentifier> identifiers) : this((GrapeMember)null, new GrapeList<GrapeIdentifier>(grapeObject, identifiers)) { }
public GrapeSimpleType(GrapeList<GrapeIdentifier> nameParts) { packageName = nameParts.GetPackageName(); typeName = nameParts.GetSimpleName(); }
public GrapeDestructor(GrapeList<GrapeModifier> modifiers, GrapeIdentifier name, GrapeList<GrapeStatement> body): base(modifiers, name, null, body) {}
public GrapeMember(GrapeList<GrapeIdentifier> identifiers) : this((GrapeMember)null, identifiers) { }
private GrapeCallExpression(GrapeIdentifier identifier, GrapeList<GrapeExpression> parameters, GrapeAccessExpression next): base(GrapeAccessExpressionType.Method, identifier, next) { this.parameters = parameters.ToList(this).AsReadOnly(); }
public GrapeImportDeclaration(GrapeList<GrapeIdentifier> packageNameParts) { packageName = packageNameParts.GetFullName(); }
public GrapeField(GrapeList<GrapeModifier> modifiers, GrapeVariable field): base(modifiers) { this.field = field; }
public GrapeSwitchStatement(GrapeExpression expression, GrapeList<GrapeSwitchCase> cases): base() { this.expression = expression; this.cases = cases.ToList(this).AsReadOnly(); }
public bool ValidateNode(object obj) { if (Config.OutputErrors) { GrapeInitStatement s = obj as GrapeInitStatement; if (s != null) { if (s.Type == GrapeInitStatement.GrapeInitStatementType.Base) { GrapeClass c = s.GetLogicalParentOfEntityType<GrapeClass>(); if (c.Inherits == null) { errorSink.AddError(new GrapeErrorSink.Error { Description = "Cannot access base constructor when the current class has no base class.", FileName = s.FileName, Entity = s }); if (!Config.ContinueOnError) { return false; } } GrapeEntity inheritingEntity = astUtils.GetClassWithNameFromImportedPackagesInFile(Config.Ast, typeCheckingUtils.GetTypeNameForTypeAccessExpression(Config, c.Inherits), c.FileName); if (inheritingEntity != null && inheritingEntity is GrapeClass) { string errorMessage = ""; GrapeClass inheritingClass = inheritingEntity as GrapeClass; GrapeMethod method = null; foreach (GrapeEntity entity in inheritingClass.GetChildren()) { if (entity != null && entity is GrapeMethod && ((GrapeMethod)entity).Name == inheritingClass.Name && ((GrapeMethod)entity).Type == GrapeMethod.GrapeMethodType.Constructor) { method = entity as GrapeMethod; break; } } if (method == null) { GrapeList<GrapeModifier> methodModifiers = new GrapeList<GrapeModifier>(new GrapePublicModifier()); GrapeList<GrapeIdentifier> nameParts = new GrapeList<GrapeIdentifier>(new GrapeIdentifier(inheritingClass.Name)); method = new GrapeMethod(methodModifiers, new GrapeSimpleType(nameParts), new GrapeIdentifier(inheritingClass.Name), new GrapeList<GrapeParameter>(), new GrapeList<GrapeStatement>()); method.Parent = inheritingClass; } GrapeModifier.GrapeModifierType modifiers = c.GetAppropriateModifiersForEntityAccess(Config, method); bool valid = accessExpressionValidator.ValidateMethodSignatureAndOverloads(GrapeCallExpression.Create(new GrapeIdentifier(inheritingClass.Name), GrapeList<GrapeExpression>.FromEnumerable(s.Parameters), null), method, modifiers, ref errorMessage); if (!valid) { errorSink.AddError(new GrapeErrorSink.Error { Description = errorMessage, FileName = s.FileName, Entity = s }); if (!Config.ContinueOnError) { return false; } } } else { errorSink.AddError(new GrapeErrorSink.Error { Description = "Cannot find base class '" + typeCheckingUtils.GetTypeNameForTypeAccessExpression(Config, c.Inherits) + "'.", FileName = s.FileName, Entity = s }); if (!Config.ContinueOnError) { return false; } } } else if (s.Type == GrapeInitStatement.GrapeInitStatementType.This) { GrapeClass c = s.GetLogicalParentOfEntityType<GrapeClass>(); GrapeMethod method = null; foreach (GrapeEntity entity in c.GetChildren()) { if (entity != null && entity is GrapeMethod && ((GrapeMethod)entity).Name == c.Name && ((GrapeMethod)entity).Type == GrapeMethod.GrapeMethodType.Constructor) { method = entity as GrapeMethod; break; } } if (method == null) { GrapeList<GrapeModifier> methodModifiers = new GrapeList<GrapeModifier>(new GrapePublicModifier()); GrapeList<GrapeIdentifier> nameParts = new GrapeList<GrapeIdentifier>(new GrapeIdentifier(c.Name)); method = new GrapeMethod(methodModifiers, new GrapeSimpleType(nameParts), new GrapeIdentifier(c.Name), new GrapeList<GrapeParameter>(), new GrapeList<GrapeStatement>()); method.Parent = c; } string errorMessage = ""; GrapeModifier.GrapeModifierType modifiers = c.GetAppropriateModifiersForEntityAccess(Config, method); bool valid = accessExpressionValidator.ValidateMethodSignatureAndOverloads(GrapeCallExpression.Create(new GrapeIdentifier(c.Name), GrapeList<GrapeExpression>.FromEnumerable(s.Parameters), null), method, modifiers, ref errorMessage); if (!valid) { errorSink.AddError(new GrapeErrorSink.Error { Description = errorMessage, FileName = s.FileName, Entity = s }); if (!Config.ContinueOnError) { return false; } } } else { errorSink.AddError(new GrapeErrorSink.Error { Description = "Cannot find initialization type.", FileName = s.FileName, Entity = s }); if (!Config.ContinueOnError) { return false; } } } } return true; }
public GrapeWhileStatement(GrapeExpression condition, GrapeList<GrapeStatement> statements): base(statements) { this.condition = condition; }
public GrapeForEachStatement(GrapeVariable iteratorVariable, GrapeExpression valueExpression, GrapeList<GrapeStatement> statements): base(statements) { this.iteratorVariable = iteratorVariable; this.valueExpression = valueExpression; }