Пример #1
0
        private void ChunkVarDeclaration(VarDeclarationNode p_node)
        {
            if (p_node.Initializer == null)
            {
                Add(OpCode.LOAD_NIL, p_node.PositionData);
            }
            else
            {
                ChunkIt(p_node.Initializer);
            }

            Nullable <Variable> maybe_var = SetVar(p_node.Name);

            if (maybe_var.HasValue)
            {
                Variable this_var = maybe_var.Value;
                if (this_var.type == ValueType.Global)
                {
                    Add(OpCode.DECLARE_GLOBAL, p_node.PositionData);
                }
                else
                {
                    Add(OpCode.DECLARE_VARIABLE, p_node.PositionData);
                }
            }
            else
            {
                Error("Variable Name has already been used!", p_node.PositionData);
            }
        }
Пример #2
0
 private void PrintVarDeclaration(VarDeclarationNode p_node)
 {
     Console.Write(identString + "[VARIABLE DECLARATION " + p_node.Name);
     if (p_node.Initializer != null)
     {
         Console.Write(" = ");
         Print(p_node.Initializer);
     }
     Console.WriteLine("]");
 }