Beispiel #1
0
 public override void OutAVarDecl(AVarDecl node)
 {
     if (node.GetInit() != null)
     {
         // initializer must be an assigment. Handled by grammar
     }
     base.OutAVarDecl(node);
 }
 public override void OutAVarDecl(AVarDecl node)
 {
     // check init condition if any.
     if (node.GetInit() != null)
     {
         if (mEnv.CurrentScope.Contains(node.GetInit()))
         {
             long value = mEnv.CurrentScope.GetValueOf(node.GetInit());
             mEnv.CurrentScope.SetValueOf(node, value);
         }
         else
         {
             throw new Exception("Unresolveable initcondition");
         }
     }
     base.OutAVarDecl(node);
 }
Beispiel #3
0
        public override void CaseAVarDecl(AVarDecl node)
        {
            // check: variable initializer is a InitExp
            PExp exp = node.GetInit();

            if (exp != null)
            {
                if (exp.GetType() != typeof(AInitExp))
                {
                    Error.Fatal(ErrorType.InvalidInitializer, node.GetName());
                }
            }
            base.CaseAVarDecl(node);
        }