Ejemplo n.º 1
0
        private void InitHelpers()
        {
            addToProgram = true;
            lastCompiledAssign = null;

            isOperatorUnaryPrefix = false;
            isCompilingAssignmentTarget = false;
            isSelectorsFirstCompile = true;
            isCurrentCompiledTheMainProgram = true;

            lazyEvaluationJumpStack = new System.Collections.Generic.Stack<Jump>();
            jumpStack = new System.Collections.Generic.Stack<Jump>();

            conditionCount = 0;
            lineLengthList = SourceInfoUtils.FindLineLengths(Source);

            currentGlobalVariableInfo = null;
            currentUserDefinedFunctionInfo = null;
        }
Ejemplo n.º 2
0
        public override void Visit(AssignmentOpNode node)
        {
            if (node.Value == "=")
            {
                isCompilingAssignmentTarget = true;
                node.Left.Accept(this);
                isCompilingAssignmentTarget = false;
                node.Right.Accept(this);
                AddCommand(lastCompiledAssign = new Assign(true));
            }
            else
            {
                // x op= y -> x = x op y //
                isCompilingAssignmentTarget = true;
                node.Left.Accept(this);
                isCompilingAssignmentTarget = false;
                node.Left.Accept(this);
                node.Right.Accept(this);

                switch (node.Value[0])
                {
                    case '+': AddCommand(new BinaryOperation(BinaryOperation.Operations.Addition)); break;
                    case '-': AddCommand(new BinaryOperation(BinaryOperation.Operations.Subtraction)); break;
                    case '*': AddCommand(new BinaryOperation(BinaryOperation.Operations.Multiplication)); break;
                    case '/': AddCommand(new BinaryOperation(BinaryOperation.Operations.Division)); break;
                    case '%': AddCommand(new BinaryOperation(BinaryOperation.Operations.Modulo)); break;
                    case '^': AddCommand(new BinaryOperation(BinaryOperation.Operations.Power)); break;
                    case '&': AddCommand(new BinaryOperation(BinaryOperation.Operations.LogicalAnd)); break;
                    case '|': AddCommand(new BinaryOperation(BinaryOperation.Operations.LogicalOr)); break;
                    case '~': AddCommand(new BinaryOperation(BinaryOperation.Operations.LogicalXor)); break;
                    default:
                        AddError(CompilerErrorCode.Custom, string.Format("Unknown Assign Operator : {0}", node.Value), node.NodeValueInfo);
                        break;
                }

                AddCommand(lastCompiledAssign = new Assign(true));
            }
        }
Ejemplo n.º 3
0
 public override void Visit(ExpressionNode node)
 {
     VisitChildren(node);
     if (lastCompiledAssign != null) lastCompiledAssign.PushResult = false;
     lastCompiledAssign = null;
 }