Example #1
0
 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;
     }
 }
Example #2
0
        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);
        }
Example #3
0
        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            //check the existence and the semantic of the left value.
            Identifier.CheckSemantics(scope, errors);
            //check the semantick of the expression.
            this.Expr.CheckSemantics(scope, errors);
            if (Identifier is IdNode)
                if (scope.ContainsVarInstance(Identifier.Text) && scope.GetVarInstance(Identifier.Text).ReadOnly)
                    errors.Add(SemanticError.ReadOnlyAssing(Identifier.Text,this));

            if (Expr.ExpressionType.Type == TypesEnumeration.Nil)
            {
                if (!scope.GetType(Identifier.ExpressionType.Name).Nilable)
                    errors.Add(SemanticError.InvalidNilAssignation(Identifier.ExpressionType.Name, this));
            }
            else if (Expr.ExpressionType.Type == TypesEnumeration.Void || scope.GetType(Identifier.ExpressionType.Name).Name != scope.GetType(Expr.ExpressionType.Name).Name)
                errors.Add(SemanticError.WrongType(Identifier.ExpressionType.Name, Expr.ExpressionType.Name, this));
        }
Example #4
0
        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);
        }