コード例 #1
0
        public override void CaseAVarDecl(AVarDecl node)
        {
            Declaration d = mEnv.CurrentScope.Lookup(node);

            mOutputFile.Add(d);
            base.CaseAVarDecl(node);
        }
コード例 #2
0
        public void Add(AVarDecl var)
        {
            Declaration tv = new Declaration(var, var.GetType(), var.GetName().Text);

            mNamedTypes.Add(var, tv);
            mLookupTable.Add(var.GetName().Text, tv);
        }
コード例 #3
0
 public override void OutAVarDecl(AVarDecl node)
 {
     if (node.GetInit() != null)
     {
         // initializer must be an assigment. Handled by grammar
     }
     base.OutAVarDecl(node);
 }
コード例 #4
0
        public VariableShell(AVarDecl decl, RuntimeEnvironment env)
        {
            Name = decl.GetName().ToString();

            //if (decl.GetInit() != null && env.GetGlobalScope().ContainsExpression(decl.GetInit()))
            //{
            //    Value = env.GetGlobalScope().GetValueOfExpression(decl.GetInit());
            //}
        }
コード例 #5
0
 public bool Contains(AVarDecl var)
 {
     if (var != null)
     {
         return(mNamedTypes.ContainsKey(var));
     }
     else
     {
         return(false);
     }
 }
コード例 #6
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);
        }
コード例 #7
0
 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);
 }
コード例 #8
0
 public Declaration Lookup(AVarDecl decl)
 {
     return(Lookup(decl.GetName().Text));
 }
コード例 #9
0
 public override void CaseAVarDecl(AVarDecl node)
 {
     base.CaseAVarDecl(node);
 }
コード例 #10
0
 public override void CaseAVarDecl(AVarDecl node)
 {
     // add variable to scope
     mEnv.CurrentScope.Add(node);
     base.CaseAVarDecl(node);
 }