public override void CheckSemantics(Scope scope, List<SemanticError> errors) { var varInfo = scope.GetVarInstance(Record.Text); //Verify if the variable exist if (varInfo == null) { errors.Add(SemanticError.UndefinedVariableUsed(this.Record.Text, this)); return; } NextNested.CheckSemantics(varInfo.VariableType, scope, errors); ExpressionType = NextNested.ExpressionType; Record.ILName = scope.GetILVarNames(Record.Text); ILName = scope.GetILVarNames(Record.Text); ExpressionType.ILName = scope.GetILTypeName(ExpressionType.Name); }
public override void CheckSemantics(Scope scope, List<SemanticError> errors) { //Verify if the array exist var varInfo = scope.GetVarInstance(this.ArrayIdentifier.Text); if (varInfo == null) { errors.Add(SemanticError.UndefinedVariableUsed(this.ArrayIdentifier.Text, this)); return; } this.NextNested.CheckSemantics(varInfo.VariableType, scope, errors); ExpressionType = this.NextNested.ExpressionType; ArrayIdentifier.ILName = scope.GetILVarNames(ArrayIdentifier.Text); var arrayInfo = (ArrayInfo) scope.GetType(varInfo.VariableType); NextNested.Index.ILName = scope.GetILTypeName(arrayInfo.ItemsType); ILName = scope.GetILVarNames(ArrayIdentifier.Text); ExpressionType.ILName = scope.GetILTypeName(ExpressionType.Name); }
public override void CheckSemantics(Scope scope, List<SemanticError> errors) { var varInfo = scope.GetVarInstance(Text); if (varInfo == null) errors.Add(SemanticError.UndefinedVariableUsed(Text, this)); else { ExpressionType = scope.GetType(varInfo.VariableType); VariableILName = scope.GetILVarNames(Text); ILName = VariableILName; } }
public override void CheckSemantics(Scope scope, List<SemanticError> errors) { this.LowerValue.CheckSemantics(scope, errors); this.HighestValue.CheckSemantics(scope, errors); if (scope.ContainsType(IteratorName.Text, true)) errors.Add(SemanticError.DefinedVariable(IteratorName.Text, this)); if (this.LowerValue.ExpressionType.Type != TypesEnumeration.Integer) errors.Add(SemanticError.InvalidForExpression("lower", this)); if (this.HighestValue.ExpressionType.Type != TypesEnumeration.Integer) errors.Add(SemanticError.InvalidForExpression("upper", this)); var newScope = new Scope(scope); newScope.AddVar(this.IteratorName.Text, new VariableInfo(this.IteratorName.Text, "int"){ReadOnly = true}); this.Loop.CheckSemantics(newScope, errors); //loop may not return a value if (Loop.ExpressionType.Type != TypesEnumeration.Void) errors.Add(SemanticError.DontReturnExpression("For body", this)); IteratorName.ILName = newScope.GetILVarNames(IteratorName.Text); }
protected Scope CreateFunctionScope(Scope scope, List<SemanticError> errors) { var newScope = new Scope(scope); if (Arguments != null) { Arguments.CheckSemantics(scope, errors); for (int i = 0; Arguments != null && i < Arguments.Count; i++) { newScope.AddVar(Arguments[i].Field.Text, new VariableInfo(Arguments[i].Field.Text, Arguments[i].TypeName.Text)); Arguments[i].ILName = newScope.GetILVarNames(Arguments[i].Field.Text); } } return newScope; }