public void VisitIf(CIf cif)
 {
     if (!cif.IsElseIf)
     {
         InstrumentNode(cif);
     }
     visitor.VisitIf(cif);
 }
示例#2
0
    public override EqCompiler.CFunction CreateInstance(ArrayList alValues)
    {
        CIf oIf = new CIf();

        oIf.SetValue(alValues);

        return(oIf);
    }
        public void PreAcceptEndIf(CIf cif, Object objstate)
        {
            if (objstate == null)
            {
                return;
            }

            DbTypeInfo state = (DbTypeInfo)objstate;

            dbtype = state.oldtype;
        }
        public void PrintSimpleFunctionTest()
        {
            var ifStatement = new CIf((CExpression)5 != 3.2f, new CBlock(
                                          new CLabel("Start"),
                                          new CWhile(true),
                                          new CGoto("Start"),
                                          CExpression.Assign(new CVariable("Something")[5], "Thing")
                                          ));
            var procedure = new CMethod("test_a", (new CType("void", true), "a"), (new CType("int"), "b"))
            {
                IsStatic = true,
                Body     = new CBlock(ifStatement)
            };

            Console.WriteLine(procedure);
        }
    }
        public Object PreAcceptThen(CIf cif, Object objstate)
        {
            int         newtype = 0;
            CExpression exp     = cif.Condition;
            bool        not     = exp is CNot;

            if (not)
            {
                exp = ((CNot)exp).Operand;
                if (exp is CParenExpression)
                {
                    exp = ((CParenExpression)exp).InnerExpression;
                }
            }

            if (exp is CLogic && ((CLogic)exp).Operation.Value == "or")
            {
                CExpression lhs = ((CLogic)exp).Left;
                if (lhs is CAccess && ((CAccess)lhs).IsRootAccess &&
                    ((CAccess)lhs).ReferenceToken.Value == "g_fmssql")
                {
                    newtype |= DbMsSql;
                }
                exp = ((CLogic)exp).Right;
            }

            if (exp is CAccess)
            {
                CAccess acc = (CAccess)exp;
                if (acc.IsRootAccess)
                {
                    if (acc.ReferenceToken.Value == "g_fmssql")
                    {
                        newtype |= DbMsSql;
                    }
                    if (acc.ReferenceToken.Value == "g_fmysql")
                    {
                        newtype |= DbMySql;
                    }
                }
            }

            if (newtype == 0)
            {
                return(null);
            }

            if (not)
            {
                newtype = ~newtype;
            }

            DbTypeInfo state;

            if (objstate == null)
            {
                state         = new DbTypeInfo();
                state.oldtype = dbtype;
            }
            else
            {
                state = (DbTypeInfo)objstate;
            }
            state.currenttype = newtype;
            state.elsetype   &= ~newtype;

            dbtype = newtype;
            return(state);
        }