Exemple #1
0
        internal void buildFirstTernaryOperator()
        {
            int    type;
            string name = pop(out type);

            StatementData arg = popStatement();

            StatementData _statement = newStatement();
            FunctionData  first      = _statement.First;

            first.Call.Name.SetLine(getLastLineNumber());

            _statement.CopyFirstComments(arg);
            arg.FirstComments.Clear();

            mStatementSemanticStack.Push(_statement);

            StatementData statement = getCurStatement();
            FunctionData  func      = getLastFunction();

            if (!func.IsValid())
            {
                func.Call.SetParamClass((int)CallData.ParamClassEnum.PARAM_CLASS_TERNARY_OPERATOR);
                func.SetExtentClass((int)FunctionData.ExtentClassEnum.EXTENT_CLASS_STATEMENT);

                func.Call.Name.SetId(name);
                func.Call.Name.SetType(type);

                if (arg.IsValid())
                {
                    func.Call.AddParams(arg);
                }
            }
        }
Exemple #2
0
        private void buildOperator()
        {
            int    type;
            string name = pop(out type);

            StatementData    arg     = popStatement();
            ISyntaxComponent argComp = simplifyStatement(arg);

            StatementData _statement = newStatementWithOneFunction();
            FunctionData  first      = _statement.First;

            first.Name.SetLine(getLastLineNumber());

            _statement.CopyFirstComments(argComp);
            argComp.FirstComments.Clear();

            mStatementSemanticStack.Push(_statement);

            StatementData statement = getCurStatement();
            FunctionData  func      = getLastFunction();

            if (!func.IsValid())
            {
                if (name.Length > 0 && name[0] == '`')
                {
                    func.SetParamClass((int)(FunctionData.ParamClassEnum.PARAM_CLASS_WRAP_INFIX_CALL_MASK | FunctionData.ParamClassEnum.PARAM_CLASS_OPERATOR));

                    func.Name.SetId(name.Substring(1));
                    func.Name.SetType(type);
                }
                else
                {
                    func.SetParamClass((int)FunctionData.ParamClassEnum.PARAM_CLASS_OPERATOR);

                    func.Name.SetId(name);
                    func.Name.SetType(type);
                }
                if (argComp.IsValid())
                {
                    func.AddParam(argComp);
                }
            }
        }
Exemple #3
0
        private void buildFirstTernaryOperator()
        {
            int    type;
            string name = pop(out type);

            StatementData    arg     = popStatement();
            ISyntaxComponent argComp = simplifyStatement(arg);

            StatementData _statement = newStatementWithOneFunction();
            FunctionData  first      = _statement.First;

            //三元运算符表示成op1(cond)(true_val)op2(false_val)
            first.LowerOrderFunction      = new FunctionData();
            first.LowerOrderFunction.Name = new ValueData();
            first.LowerOrderFunction.Name.SetLine(getLastLineNumber());

            _statement.CopyFirstComments(argComp);
            argComp.FirstComments.Clear();

            mStatementSemanticStack.Push(_statement);

            StatementData statement = getCurStatement();
            FunctionData  func      = getLastFunction();

            if (!func.IsValid())
            {
                func.LowerOrderFunction.SetParamClass((int)FunctionData.ParamClassEnum.PARAM_CLASS_PARENTHESIS);
                func.LowerOrderFunction.Name.SetId(name);
                func.LowerOrderFunction.Name.SetType(type);
                if (argComp.IsValid())
                {
                    func.LowerOrderFunction.AddParam(argComp);
                }

                func.SetParamClass((int)FunctionData.ParamClassEnum.PARAM_CLASS_TERNARY_OPERATOR);
            }
        }