public override void visit(Assignment n)
 {
     try {
         int stackLocation = tables[scope].Lookup(n.LHS.Name).StackLocation;
         n.RHS.accept(this);
         //Add(new Move(new RegisterOffset(Global.Registers.STACKBASEPOINTER, extraStackSize++), regRAX));
         Add(new Move(stack.Pop(), new RegisterOffset(Global.Registers.STACKBASEPOINTER, -stackLocation)));
     } catch (NoSuchKeyException)
     {
         // Do nothing, emit the declaration of the constant, normally because the constant was unreferenced and thus unused
     }
 }
        /*private void CheckFunction(FunctionCall node)
        {
            Node = node;
            name = node.Name.Name;
            Table scope = node.Scope;
            Symbol reference = scope.Lookup(name, node.Args);
            if (reference != null) //The identifier exists in the current scope
                reference.accept(this);
            else if (scope == null)
                Swift.error("The function you called could not be found, line " + node.Context.Line.ToString() + ", column " + node.Context.Pos.ToString(), 1);
        }*/













        /*public override void visit(FunctionSymbol n)
        {
            if (paramTypes.Count == n.Parameters.Count)
            {
                for (int i = 0; i < paramTypes.Count; i++)
                {
                    if (!(paramTypes[i] == n.Parameters[i].Type))
                        Swift.error("The type of the parameter you supplied when calling \"" + name + "\" at the line " + Node.Context.Line.ToString() + ", column " + Node.Context.Pos.ToString() + " is not the same type as required by the function", 1);
                }
            }
            else
            {
                Swift.error("The number of parameters you supplied when calling \"" + name + "\" at the line " + Node.Context.Line.ToString() + ", column " + Node.Context.Pos.ToString() + " does not match the required number of parameters as defined in the function", 1);
            }
        }*/

        public override void visit(Assignment n)
        {
            string name = n.LHS.Name;
            Table scope = n.Scope;
            while (scope != null)
            {
                Symbol reference = scope.Lookup(name);
                if (reference != null)
                {
                    if (reference is VariableSymbol) {
                        if (n.RHS is IdentifierExp)
                            if (n.Scope.Lookup(((IdentifierExp) n.RHS).ID.Name) is ConstantSymbol)
                                n.RHS = ((ConstantSymbol)n.Scope.Lookup(((IdentifierExp)n.RHS).ID.Name)).Value;
                        ASTType type = n.RHS.accept(new TypeVisitor());
                        if (((VariableSymbol)reference).Type.GetType() != type.GetType())
                            Swift.error(new IncompatibleTypesException(n.Context));
                    }
                    else if (reference is ConstantSymbol) {
                        Swift.error(new ConstantReassignmentException(n.Context));
                    }
                    reference.SetReferenced();
                    break;
                }
                else
                    Swift.error(new AssignmentUnknownVariable(n.Context));
                scope = scope.GetReference();
            }
        }
 public abstract void visit(Assignment n);
 public void visit(Assignment n)
 {
     throw new NotImplementedException();
 }
 public virtual void visit(Assignment n)
 {
     // Do nothing; leave the implementation to the main class
 }
 public override void visit(Assignment n)
 {
     n.Scope = Scope;
     n.RHS.accept(this);
 }
 private Assignment EatAssignment()
 {
     Assignment node = new Assignment(context[0]);
     Identifier lhs = new Identifier(tokens[0].value);
     CutData(2);
     Exp rhs = EatExpression();
     node.LHS = lhs;
     node.RHS = rhs;
     astBase.Children.Add(node);
     return node;
 }
 public ASTType visit(Assignment n)
 {
     throw new NotImplementedException();
 }