예제 #1
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            bool   exec            = false;
            String mode            = "normal";
            DefaultReturnVector rv = new DefaultReturnVector();

            if (params_Renamed != null && params_Renamed.Length == 1)
            {
                exec = true;
                ValueParam vp = (ValueParam)params_Renamed[0];
                if (vp.StringValue.Equals("true", StringComparison.InvariantCultureIgnoreCase))
                {
                    engine.CurrentFocus.Lazy = true;
                    mode = "lazy";
                }
                else if (vp.StringValue.Equals("false", StringComparison.InvariantCultureIgnoreCase))
                {
                    engine.CurrentFocus.Lazy = false;
                }
            }
            DefaultReturnValue drv = new DefaultReturnValue(Constants.STRING_TYPE, mode);

            rv.addReturnValue(drv);
            return(rv);
        }
예제 #2
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            bool boolVal = true;

            if (params_Renamed != null)
            {
                if (params_Renamed.Length == 1)
                {
                    if (params_Renamed[0] is ValueParam)
                    {
                        ValueParam n = (ValueParam)params_Renamed[0];
                        boolVal = n.BooleanValue;
                    }
                    else if (params_Renamed[0] is BoundParam)
                    {
                        BoundParam bp = (BoundParam)params_Renamed[0];
                        boolVal = ((Boolean)engine.getBinding(bp.VariableName));
                    }
                    else if (params_Renamed[0] is FunctionParam2)
                    {
                        FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                        n.Engine = engine;
                        n.lookUpFunction();
                        IReturnVector rval = (IReturnVector)n.Value;
                        boolVal = rval.firstReturnValue().BooleanValue;
                    }
                    boolVal = (boolVal == false);
                }
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, boolVal);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #3
0
        /* (non-Javadoc)
         * @see woolfel.engine.rete.Function#executeFunction(woolfel.engine.Creshendo.Util.Rete.Rete, woolfel.engine.rete.Parameter[])
         */

        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            if (engine != null && params_Renamed != null && params_Renamed.Length == 3)
            {
                BoundParam  bp       = (BoundParam)params_Renamed[0];
                StringParam slot     = (StringParam)params_Renamed[1];
                ValueParam  val      = (ValueParam)params_Renamed[2];
                Object      instance = bp.ObjectRef;
                Defclass    dc       = engine.findDefclass(instance);
                // we check to make sure the Defclass exists
                if (dc != null)
                {
                    MethodInfo setm = dc.getWriteMethod(slot.StringValue);
                    try
                    {
                        setm.Invoke(instance, (Object[])new Object[] { val });
                    }
                    catch (UnauthorizedAccessException e)
                    {
                    }
                    catch (TargetInvocationException e)
                    {
                    }
                }
            }
            return(new DefaultReturnVector());
        }
예제 #4
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            Decimal bdval = new Decimal(0);

            if (params_Renamed.Length == 1)
            {
                if (params_Renamed[0] is ValueParam)
                {
                    ValueParam n = (ValueParam)params_Renamed[0];
                    bdval = n.BigDecimalValue;
                }
                else if (params_Renamed[0] is BoundParam)
                {
                    BoundParam bp = (BoundParam)params_Renamed[0];
                    bdval = (Decimal)engine.getBinding(bp.VariableName);
                }
                else if (params_Renamed[0] is FunctionParam2)
                {
                    FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                    n.Engine = engine;
                    n.lookUpFunction();
                    IReturnVector rval = (IReturnVector)n.Value;
                    bdval = rval.firstReturnValue().BigDecimalValue;
                }
                double bdh = System.Math.Log(Decimal.ToDouble(bdval)); //.pow(Math.E, bdval.doubleValue());
                bdval = new Decimal(bdh);
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.BIG_DECIMAL, bdval);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #5
0
        /* (non-Javadoc)
         * @see woolfel.engine.rete.Function#executeFunction(woolfel.engine.Creshendo.Util.Rete.Rete, woolfel.engine.rete.Parameter[])
         */

        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            Object rtn = null;
            DefaultReturnVector drv = new DefaultReturnVector();

            if (engine != null && params_Renamed != null && params_Renamed.Length == 3)
            {
                BoundParam  bp       = (BoundParam)params_Renamed[0];
                StringParam slot     = (StringParam)params_Renamed[1];
                ValueParam  val      = (ValueParam)params_Renamed[2];
                Object      instance = bp.ObjectRef;
                Defclass    dc       = engine.findDefclass(instance);
                // we check to make sure the Defclass exists
                if (dc != null)
                {
                    MethodInfo getm = dc.getWriteMethod(slot.StringValue);
                    try
                    {
                        rtn = getm.Invoke(instance, (Object[])new Object[] { val });
                        int rtype = getMethodReturnType(getm);
                        DefaultReturnValue rvalue = new DefaultReturnValue(rtype, rtn);
                        drv.addReturnValue(rvalue);
                    }
                    catch (UnauthorizedAccessException e)
                    {
                        // TODO we should handle error, for now not implemented
                    }
                    catch (TargetInvocationException e)
                    {
                        // TODO we should handle error, for now not implemented
                    }
                }
            }
            return(drv);
        }
예제 #6
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            Decimal bdval = new Decimal(0);

            if (params_Renamed != null)
            {
                if (params_Renamed[0] is ValueParam)
                {
                    bdval = params_Renamed[0].BigDecimalValue;
                }
                else if (params_Renamed[0] is BoundParam)
                {
                    BoundParam bp = (BoundParam)params_Renamed[0];
                    bdval = (Decimal)engine.getBinding(bp.VariableName);
                }
                else if (params_Renamed[0] is FunctionParam2)
                {
                    FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                    n.Engine = engine;
                    n.lookUpFunction();
                    IReturnVector rval = (IReturnVector)n.Value;
                    bdval = rval.firstReturnValue().BigDecimalValue;
                }
                for (int idx = 1; idx < params_Renamed.Length; idx++)
                {
                    if (params_Renamed[idx] is ValueParam)
                    {
                        ValueParam n  = (ValueParam)params_Renamed[idx];
                        Decimal    bd = n.BigDecimalValue;
                        bdval = Decimal.Multiply(bdval, bd);
                    }
                    else if (params_Renamed[idx] is FunctionParam2)
                    {
                        FunctionParam2 n = (FunctionParam2)params_Renamed[idx];
                        n.Engine = engine;
                        n.lookUpFunction();
                        IReturnVector rval = (IReturnVector)n.Value;
                        Decimal       bd   = rval.firstReturnValue().BigDecimalValue;
                        if (idx == 0)
                        {
                            bdval = bd;
                        }
                        else
                        {
                            bdval = Decimal.Multiply(bdval, bd);
                        }
                    }
                }
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.BIG_DECIMAL, bdval);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #7
0
 public void Post([FromBody] ValueParam newvalue)
 {
     _valueRepository.AddValue(new Value
     {
         Id   = newvalue.Id,
         Body = newvalue.Body,
         //  InternalId = newvalue.InternalId,
         //  Name = newvalue.Name,
         //  UpdatedOn = newvalue.UpdatedOn,
         //  CreatedOn = newvalue.CreatedOn
     });
 }
예제 #8
0
 public void AddFunction(IList list)
 {
     if (list.Count > 0)
     {
         //Object[] array = list.ToArray();
         ValueParam vp = (ValueParam)list[0];
         function = vp.ToString();
         IParameter[] parms = new IParameter[list.Count - 1];
         for (int idx = 1; idx < list.Count; idx++)
         {
             parms[idx - 1] = (IParameter)list[idx];
         }
         parameters = parms;
     }
 }
예제 #9
0
 /// <summary> Configure will lookup the function and set it
 /// </summary>
 public virtual void configure(Rete.Rete engine, IRule util)
 {
     if (functionName != null && engine.findFunction(functionName) != null)
     {
         faction = engine.findFunction(functionName);
     }
     // now setup the BoundParameters if there are any
     for (int idx = 0; idx < parameters.Length; idx++)
     {
         if (parameters[idx] is BoundParam)
         {
             BoundParam bp = (BoundParam)parameters[idx];
             Binding    bd = util.getBinding(bp.VariableName);
             if (bd != null)
             {
                 bp.Row    = bd.LeftRow;
                 bp.Column = bd.LeftIndex;
             }
         }
         else if (parameters[idx] is FunctionParam2)
         {
             FunctionParam2 fp2 = (FunctionParam2)parameters[idx];
             fp2.configure(engine, util);
         }
         else if (parameters[idx] is ValueParam)
         {
             ValueParam vp = (ValueParam)parameters[idx];
             // if the value is a deffact, we need to check and make sure
             // the slots with BoundParam value are compiled properly
             if (vp.Value is Deffact)
             {
                 ((Deffact)vp.Value).compileBinding(util);
             }
         }
     }
     // in the case of Assert, we do further compilation
     if (faction is AssertFunction)
     {
         Deftemplate tmpl = (Deftemplate)engine.CurrentFocus.getTemplate(parameters[0].StringValue);
         Deffact     fact = (Deffact)tmpl.createFact((Object[])parameters[1].Value, -1);
         fact.compileBinding(util);
         parameters    = new ValueParam[1];
         parameters[0] = new ValueParam(Constants.OBJECT_TYPE, fact);
     }
 }
예제 #10
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            double dval = 0;

            if (params_Renamed != null)
            {
                if (params_Renamed.Length == 1)
                {
                    if (params_Renamed[0] is ValueParam)
                    {
                        ValueParam n = (ValueParam)params_Renamed[0];
                        dval = n.DoubleValue;
                        dval = System.Math.Cos(dval);
                    }
                    else if (params_Renamed[0] is BoundParam)
                    {
                        BoundParam bp = (BoundParam)params_Renamed[0];
                        dval = bp.DoubleValue;
                        dval = System.Math.Cos(dval);
                    }
                    else if (params_Renamed[0] is FunctionParam2)
                    {
                        FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                        n.Engine = engine;
                        n.lookUpFunction();
                        IReturnVector rval = (IReturnVector)n.Value;
                        dval = rval.firstReturnValue().DoubleValue;
                        dval = System.Math.Cos(dval);
                    }
                }
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.DOUBLE_PRIM_TYPE, dval);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #11
0
 public void valueParams(ArrayList list)
 {
     Object exp;
     Token tok;
     ValueParam vp = null;
     if (mcc_2_1(2147483647))
     {
         mcc_consume_token(LBRACE);
         exp = expr();
         mcc_consume_token(RBRACE);
         ShellFunction subfunc = (ShellFunction) exp;
         FunctionParam2 fp2 = new FunctionParam2();
         fp2.FunctionName = subfunc.Name;
         fp2.Engine = engine;
         fp2.Parameters = subfunc.Parameters;
         list.Add(fp2);
     }
     else
     {
         switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
         {
             case INTEGER_LITERAL:
             case FLOATING_POINT_LITERAL:
             case STRING_LITERAL:
             case PATH_LITERAL:
                 exp = typeExpr();
                 vp = new ValueParam();
                 vp.Value = exp;
                 if (exp is Decimal)
                 {
                     vp.ValueType = Constants.BIG_DECIMAL;
                 }
                 else if (exp is String)
                 {
                     vp.ValueType = Constants.STRING_TYPE;
                 }
                 list.Add(vp);
                 break;
             case IDENTIFIER:
                 exp = mcc_consume_token(IDENTIFIER);
                 vp = new ValueParam();
                 vp.ValueType = Constants.STRING_TYPE;
                 if (exp is Token)
                 {
                     vp.Value = ((Token) exp).image;
                 }
                 else
                 {
                     vp.Value = exp;
                 }
                 list.Add(vp);
                 break;
             case TRUE:
                 exp = mcc_consume_token(TRUE);
                 vp = new ValueParam();
                 vp.Value = true;
                 list.Add(vp);
                 break;
             case TRUE2:
                 exp = mcc_consume_token(TRUE2);
                 vp = new ValueParam();
                 vp.Value = true;
                 list.Add(vp);
                 break;
             case FALSE:
                 exp = mcc_consume_token(FALSE);
                 vp = new ValueParam();
                 vp.Value = false;
                 list.Add(vp);
                 break;
             case FALSE2:
                 exp = mcc_consume_token(FALSE2);
                 vp = new ValueParam();
                 vp.Value = false;
                 list.Add(vp);
                 break;
             case BIND:
             case BIND3:
             case BIND4:
                 // in some cases, the parameters may be a binding to a variable
                 tok = getBindType();
                 BoundParam bp = new BoundParam();
                 if (tok.kind == BIND4)
                 {
                     bp.VariableName = tok.image.Substring(2);
                     bp.IsMultislot = true;
                 }
                 else
                 {
                     bp.VariableName = tok.image;
                 }
                 list.Add(bp);
                 break;
             default:
                 mcc_la1[17] = mcc_gen;
                 mcc_consume_token(-1);
                 throw new ParseException();
         }
     }
 }
예제 #12
0
        public ValueParam[] assertBody()
        {
            Token exp;
            IList tokens = new ArrayList();
            ValueParam[] param = null;
            jj_consume_token(CLIPSParserConstants_Fields.LBRACE);
            exp = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
            while (true)
            {
                assertContents(tokens);
                switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                {
                    case CLIPSParserConstants_Fields.LBRACE:
                        ;
                        break;

                    default:
                        jj_la1[19] = jj_gen;
                        //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                        goto label_9_brk;
                }
            }
            //UPGRADE_NOTE: Label 'label_9_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
            label_9_brk:
            ;

            jj_consume_token(CLIPSParserConstants_Fields.RBRACE);
            param = new ValueParam[2];
            param[0] = new ValueParam(Constants.STRING_TYPE, exp.image);

            object[] ary = new object[tokens.Count];
            tokens.CopyTo(ary,0);

            param[1] = new ValueParam(Constants.OBJECT_TYPE, ary);
            tokens.Clear();
            exp = null;
            {
                if (true)
                    return param;
            }
            throw new ApplicationException("Missing return statement in function");
        }
예제 #13
0
        public void valueParams(IList list)
        {
            Object exp;
            Token tok;
            ValueParam vp = null;
            if (jj_2_1(2147483647))
            {
                jj_consume_token(CLIPSParserConstants_Fields.LBRACE);
                exp = expr();
                jj_consume_token(CLIPSParserConstants_Fields.RBRACE);
                ShellFunction subfunc = (ShellFunction) exp;
                FunctionParam2 fp2 = new FunctionParam2();
                fp2.FunctionName = subfunc.Name;
                fp2.Engine = engine;
                fp2.Parameters = subfunc.Parameters;
                list.Add(fp2);
            }
            else
            {
                switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                {
                    case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                    case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                    case CLIPSParserConstants_Fields.STRING_LITERAL:
                    case CLIPSParserConstants_Fields.PATH_LITERAL:
                        exp = typeExpr();
                        vp = new ValueParam();
                        vp.Value = exp;
                        if (exp is Decimal)
                        {
                            vp.ValueType = Constants.BIG_DECIMAL;
                        }
                        else if (exp is String)
                        {
                            vp.ValueType = Constants.STRING_TYPE;
                        }
                        list.Add(vp);
                        break;

                    case CLIPSParserConstants_Fields.IDENTIFIER:
                        exp = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
                        vp = new ValueParam();
                        vp.ValueType = Constants.STRING_TYPE;
                        if (exp is Token)
                        {
                            vp.Value = ((Token) exp).image;
                        }
                        else
                        {
                            vp.Value = exp;
                        }
                        list.Add(vp);
                        break;

                    case CLIPSParserConstants_Fields.TRUE:
                        exp = jj_consume_token(CLIPSParserConstants_Fields.TRUE);
                        vp = new ValueParam();
                        vp.Value = true;
                        list.Add(vp);
                        break;

                    case CLIPSParserConstants_Fields.TRUE2:
                        exp = jj_consume_token(CLIPSParserConstants_Fields.TRUE2);
                        vp = new ValueParam();
                        vp.Value = true;
                        list.Add(vp);
                        break;

                    case CLIPSParserConstants_Fields.FALSE:
                        exp = jj_consume_token(CLIPSParserConstants_Fields.FALSE);
                        vp = new ValueParam();
                        vp.Value = false;
                        list.Add(vp);
                        break;

                    case CLIPSParserConstants_Fields.FALSE2:
                        exp = jj_consume_token(CLIPSParserConstants_Fields.FALSE2);
                        vp = new ValueParam();
                        vp.Value = false;
                        list.Add(vp);
                        break;

                    case CLIPSParserConstants_Fields.BIND:
                    case CLIPSParserConstants_Fields.BIND3:
                    case CLIPSParserConstants_Fields.BIND4:
                        tok = BindType;
                        BoundParam bp = new BoundParam();
                        if (tok.kind == CLIPSParserConstants_Fields.BIND4)
                        {
                            bp.VariableName = tok.image.Substring(2);
                            bp.IsMultislot = true;
                        }
                        else
                        {
                            bp.VariableName = tok.image;
                        }
                        list.Add(bp);
                        break;

                    default:
                        jj_la1[17] = jj_gen;
                        jj_consume_token(- 1);
                        throw new ParseException();
                }
            }
        }
예제 #14
0
        public void actionParams(IList list)
        {
            Object exp;
            ValueParam vp = null;
            switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
            {
                case CLIPSParserConstants_Fields.BIND:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.BIND);
                    if (exp is Token)
                    {
                        BoundParam bp = new BoundParam();
                        bp.VariableName = ((Token) exp).image.Substring(1);
                        list.Add(bp);
                    }
                    break;

                case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                case CLIPSParserConstants_Fields.STRING_LITERAL:
                case CLIPSParserConstants_Fields.PATH_LITERAL:
                    exp = typeExpr();
                    vp = new ValueParam();
                    if (exp is Token)
                    {
                        vp.Value = ((Token) exp).image;
                    }
                    else
                    {
                        vp.Value = exp;
                    }
                    if (exp is Int64)
                    {
                        vp.ValueType = Constants.LONG_PRIM_TYPE;
                    }
                    else if (exp is Single)
                    {
                        vp.ValueType = Constants.DOUBLE_PRIM_TYPE;
                    }
                    else if (exp is String)
                    {
                        vp.ValueType = Constants.STRING_TYPE;
                    }
                    list.Add(vp);
                    break;

                case CLIPSParserConstants_Fields.IDENTIFIER:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
                    vp = new ValueParam();
                    vp.ValueType = Constants.STRING_TYPE;
                    if (exp is Token)
                    {
                        vp.Value = ((Token) exp).image;
                    }
                    else
                    {
                        vp.Value = exp;
                    }
                    list.Add(vp);
                    break;

                default:
                    jj_la1[60] = jj_gen;
                    jj_consume_token(- 1);
                    throw new ParseException();
            }
        }
예제 #15
0
        public Object expr()
        {
            Token exp = null;
            Token exp2 = null;
            Token exp3 = null;
            String body;
            ValueParam param;
            Deffact fact;
            Deftemplate templ;
            Defrule rule;
            ShellFunction func;
            DeffunctionFunction dffunc;
            ArrayList list = new ArrayList();
            ValueParam[] pms;
            IList infunc = new ArrayList();
            switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
            {
                case CLIPSParserConstants_Fields.ASSERT:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.ASSERT);
                    jj_consume_token(CLIPSParserConstants_Fields.LBRACE);
                    exp2 = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
                    while (true)
                    {
                        assertContents(list);
                        switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                        {
                            case CLIPSParserConstants_Fields.LBRACE:
                                ;
                                break;

                            default:
                                jj_la1[3] = jj_gen;
                                //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                                goto label_2_brk;
                        }
                    }
                    //UPGRADE_NOTE: Label 'label_2_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                    label_2_brk:
                    ;

                    jj_consume_token(CLIPSParserConstants_Fields.RBRACE);
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[2];
                    pms[0] = new ValueParam(Constants.STRING_TYPE, exp2.image);

                    object[] lst = new object[list.Count];
                    list.CopyTo(lst, 0);

                    pms[1] = new ValueParam(Constants.OBJECT_TYPE, lst);
                    func.setParameters(pms);
                    exp.clear();
                    exp = null;
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.ASSERTTEMPORAL:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.ASSERTTEMPORAL);
                    jj_consume_token(CLIPSParserConstants_Fields.LBRACE);
                    exp2 = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
                    while (true)
                    {
                        assertContents(list);
                        switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                        {
                            case CLIPSParserConstants_Fields.LBRACE:
                                ;
                                break;

                            default:
                                jj_la1[4] = jj_gen;
                                //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                                goto label_3_brk;
                        }
                    }
                    //UPGRADE_NOTE: Label 'label_3_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                    label_3_brk:
                    ;

                    jj_consume_token(CLIPSParserConstants_Fields.RBRACE);
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[2];
                    pms[0] = new ValueParam(Constants.STRING_TYPE, exp2.image);

                    object[] lst1 = new object[list.Count];
                    list.CopyTo(lst1,0);
                    pms[1] = new ValueParam(Constants.OBJECT_TYPE, lst1);
                    func.setParameters(pms);
                    exp.clear();
                    exp = null;
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.RETRACT:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.RETRACT);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.BIND:
                            exp2 = jj_consume_token(CLIPSParserConstants_Fields.BIND);
                            break;

                        case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                            exp2 = jj_consume_token(CLIPSParserConstants_Fields.INTEGER_LITERAL);
                            break;

                        default:
                            jj_la1[5] = jj_gen;
                            jj_consume_token(- 1);
                            throw new ParseException();
                    }
                    func = new ShellFunction();
                    func.Name = exp.image;
                    IParameter[] rpms = new IParameter[1];
                    if (exp2.image.StartsWith("?"))
                    {
                        BoundParam bp = new BoundParam();
                        bp.VariableName = exp2.image;
                        rpms[0] = bp;
                    }
                    else
                    {
                        ValueParam vp = new ValueParam(Constants.BIG_DECIMAL, Decimal.Parse(exp2.image));
                        rpms[0] = vp;
                    }
                    func.Parameters = rpms;
                    exp.clear();
                    exp = null;
                    exp2.clear();
                    exp2 = null;
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.MODIFY:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.MODIFY);
                    exp2 = jj_consume_token(CLIPSParserConstants_Fields.BIND);
                    assertContents(list);
                    func = new ShellFunction();
                    func.Name = exp.image;
                    BoundParam bp1 = new BoundParam();
                    bp1.VariableName = exp2.image;
                    list.Insert(0, bp1);
                    func.setParameters(ParameterUtils.slotToParameters(list));
                    exp.clear();
                    exp = null;
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.DEFTEMPLATE:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.DEFTEMPLATE);
                    templ = templateExpr();
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[1];
                    pms[0] = new ValueParam(Constants.OBJECT_TYPE, templ);
                    func.setParameters(pms);
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.DEFMODULE:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.DEFMODULE);
                    body = Identifier;
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[1];
                    pms[0] = new ValueParam(Constants.STRING_TYPE, body);
                    func.setParameters(pms);
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.DEFRULE:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.DEFRULE);
                    rule = ruleBody();
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[1];
                    pms[0] = new ValueParam(Constants.OBJECT_TYPE, rule);
                    func.setParameters(pms);
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.DEFCLASS:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.DEFCLASS);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.LBRACE:
                        case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                        case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                        case CLIPSParserConstants_Fields.STRING_LITERAL:
                        case CLIPSParserConstants_Fields.BIND:
                        case CLIPSParserConstants_Fields.BIND3:
                        case CLIPSParserConstants_Fields.BIND4:
                        case CLIPSParserConstants_Fields.TRUE:
                        case CLIPSParserConstants_Fields.TRUE2:
                        case CLIPSParserConstants_Fields.FALSE:
                        case CLIPSParserConstants_Fields.FALSE2:
                        case CLIPSParserConstants_Fields.IDENTIFIER:
                        case CLIPSParserConstants_Fields.PATH_LITERAL:
                            while (true)
                            {
                                valueParams(list);
                                switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                                {
                                    case CLIPSParserConstants_Fields.LBRACE:
                                    case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                                    case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                                    case CLIPSParserConstants_Fields.STRING_LITERAL:
                                    case CLIPSParserConstants_Fields.BIND:
                                    case CLIPSParserConstants_Fields.BIND3:
                                    case CLIPSParserConstants_Fields.BIND4:
                                    case CLIPSParserConstants_Fields.TRUE:
                                    case CLIPSParserConstants_Fields.TRUE2:
                                    case CLIPSParserConstants_Fields.FALSE:
                                    case CLIPSParserConstants_Fields.FALSE2:
                                    case CLIPSParserConstants_Fields.IDENTIFIER:
                                    case CLIPSParserConstants_Fields.PATH_LITERAL:
                                        ;
                                        break;

                                    default:
                                        jj_la1[6] = jj_gen;
                                        //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                                        goto label_4_brk;
                                }
                            }
                            //UPGRADE_NOTE: Label 'label_4_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                            label_4_brk:
                            ;

                            break;

                        default:
                            jj_la1[7] = jj_gen;
                            ;
                            break;
                    }
                    func = new ShellFunction();
                    func.Name = exp.image;
                    func.setParameters(ParameterUtils.convertParameters(list));
                    list.Clear();
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.DEFFUNCTION:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.DEFFUNCTION);
                    exp2 = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
                    jj_consume_token(CLIPSParserConstants_Fields.LBRACE);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.BIND:
                        case CLIPSParserConstants_Fields.BIND3:
                        case CLIPSParserConstants_Fields.BIND4:
                            while (true)
                            {
                                bindingParams(list);
                                switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                                {
                                    case CLIPSParserConstants_Fields.BIND:
                                    case CLIPSParserConstants_Fields.BIND3:
                                    case CLIPSParserConstants_Fields.BIND4:
                                        ;
                                        break;

                                    default:
                                        jj_la1[8] = jj_gen;
                                        //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                                        goto label_5_brk;
                                }
                            }
                            //UPGRADE_NOTE: Label 'label_5_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                            label_5_brk:
                            ;

                            break;

                        default:
                            jj_la1[9] = jj_gen;
                            ;
                            break;
                    }
                    jj_consume_token(CLIPSParserConstants_Fields.RBRACE);
                    jj_consume_token(CLIPSParserConstants_Fields.LBRACE);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.BINDING:
                        case CLIPSParserConstants_Fields.ASSERT:
                        case CLIPSParserConstants_Fields.ASSERTTEMPORAL:
                        case CLIPSParserConstants_Fields.DEFCLASS:
                        case CLIPSParserConstants_Fields.DEFFUNCTION:
                        case CLIPSParserConstants_Fields.DEFMODULE:
                        case CLIPSParserConstants_Fields.DEFRULE:
                        case CLIPSParserConstants_Fields.DEFTEMPLATE:
                        case CLIPSParserConstants_Fields.MODIFY:
                        case CLIPSParserConstants_Fields.RETRACT:
                        case CLIPSParserConstants_Fields.PLUS:
                        case CLIPSParserConstants_Fields.MINUS:
                        case CLIPSParserConstants_Fields.MULTIPLY:
                        case CLIPSParserConstants_Fields.DIVIDE:
                        case CLIPSParserConstants_Fields.GT1:
                        case CLIPSParserConstants_Fields.GT2:
                        case CLIPSParserConstants_Fields.LT1:
                        case CLIPSParserConstants_Fields.LT2:
                        case CLIPSParserConstants_Fields.EQ1:
                        case CLIPSParserConstants_Fields.EQ2:
                        case CLIPSParserConstants_Fields.LE1:
                        case CLIPSParserConstants_Fields.LE2:
                        case CLIPSParserConstants_Fields.GE1:
                        case CLIPSParserConstants_Fields.GE2:
                        case CLIPSParserConstants_Fields.IDENTIFIER:
                            ruleAction(infunc);
                            break;

                        default:
                            jj_la1[10] = jj_gen;
                            ;
                            break;
                    }
                    jj_consume_token(CLIPSParserConstants_Fields.RBRACE);
                    dffunc = new DeffunctionFunction();
                    dffunc.Name = exp2.image;
                    dffunc.setParameters(ParameterUtils.convertParameters(list));
                    dffunc.setFunction(infunc);
                    list.Clear();
                    {
                        if (true)
                            return dffunc;
                    }
                    break;

                case CLIPSParserConstants_Fields.BINDING:
                    jj_consume_token(CLIPSParserConstants_Fields.BINDING);
                    exp = BindType;
                    while (true)
                    {
                        valueParams(list);
                        switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                        {
                            case CLIPSParserConstants_Fields.LBRACE:
                            case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                            case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                            case CLIPSParserConstants_Fields.STRING_LITERAL:
                            case CLIPSParserConstants_Fields.BIND:
                            case CLIPSParserConstants_Fields.BIND3:
                            case CLIPSParserConstants_Fields.BIND4:
                            case CLIPSParserConstants_Fields.TRUE:
                            case CLIPSParserConstants_Fields.TRUE2:
                            case CLIPSParserConstants_Fields.FALSE:
                            case CLIPSParserConstants_Fields.FALSE2:
                            case CLIPSParserConstants_Fields.IDENTIFIER:
                            case CLIPSParserConstants_Fields.PATH_LITERAL:
                                ;
                                break;

                            default:
                                jj_la1[11] = jj_gen;
                                //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                                goto label_6_brk;
                        }
                    }
                    //UPGRADE_NOTE: Label 'label_6_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                    label_6_brk:
                    ;

                    func = new ShellFunction();
                    func.Name = "bind";
                    list.Insert(0, new ValueParam(Constants.STRING_TYPE, exp.image.Substring(1)));
                    func.setParameters(ParameterUtils.convertParameters(list));
                    list.Clear();
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.PLUS:
                case CLIPSParserConstants_Fields.MINUS:
                case CLIPSParserConstants_Fields.MULTIPLY:
                case CLIPSParserConstants_Fields.DIVIDE:
                case CLIPSParserConstants_Fields.GT1:
                case CLIPSParserConstants_Fields.GT2:
                case CLIPSParserConstants_Fields.LT1:
                case CLIPSParserConstants_Fields.LT2:
                case CLIPSParserConstants_Fields.EQ1:
                case CLIPSParserConstants_Fields.EQ2:
                case CLIPSParserConstants_Fields.LE1:
                case CLIPSParserConstants_Fields.LE2:
                case CLIPSParserConstants_Fields.GE1:
                case CLIPSParserConstants_Fields.GE2:
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.PLUS:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.PLUS);
                            break;

                        case CLIPSParserConstants_Fields.MINUS:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.MINUS);
                            break;

                        case CLIPSParserConstants_Fields.MULTIPLY:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.MULTIPLY);
                            break;

                        case CLIPSParserConstants_Fields.DIVIDE:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.DIVIDE);
                            break;

                        case CLIPSParserConstants_Fields.GT1:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.GT1);
                            break;

                        case CLIPSParserConstants_Fields.GT2:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.GT2);
                            break;

                        case CLIPSParserConstants_Fields.LT1:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.LT1);
                            break;

                        case CLIPSParserConstants_Fields.LT2:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.LT2);
                            break;

                        case CLIPSParserConstants_Fields.EQ1:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.EQ1);
                            break;

                        case CLIPSParserConstants_Fields.EQ2:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.EQ2);
                            break;

                        case CLIPSParserConstants_Fields.LE1:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.LE1);
                            break;

                        case CLIPSParserConstants_Fields.LE2:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.LE2);
                            break;

                        case CLIPSParserConstants_Fields.GE1:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.GE1);
                            break;

                        case CLIPSParserConstants_Fields.GE2:
                            exp = jj_consume_token(CLIPSParserConstants_Fields.GE2);
                            break;

                        default:
                            jj_la1[12] = jj_gen;
                            jj_consume_token(- 1);
                            throw new ParseException();
                    }
                    while (true)
                    {
                        valueParams(list);
                        switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                        {
                            case CLIPSParserConstants_Fields.LBRACE:
                            case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                            case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                            case CLIPSParserConstants_Fields.STRING_LITERAL:
                            case CLIPSParserConstants_Fields.BIND:
                            case CLIPSParserConstants_Fields.BIND3:
                            case CLIPSParserConstants_Fields.BIND4:
                            case CLIPSParserConstants_Fields.TRUE:
                            case CLIPSParserConstants_Fields.TRUE2:
                            case CLIPSParserConstants_Fields.FALSE:
                            case CLIPSParserConstants_Fields.FALSE2:
                            case CLIPSParserConstants_Fields.IDENTIFIER:
                            case CLIPSParserConstants_Fields.PATH_LITERAL:
                                ;
                                break;

                            default:
                                jj_la1[13] = jj_gen;
                                //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                                goto label_7_brk;
                        }
                    }
                    //UPGRADE_NOTE: Label 'label_7_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                    label_7_brk:
                    ;

                    func = new ShellFunction();
                    func.Name = exp.image;
                    func.setParameters(ParameterUtils.convertParameters(list));
                    list.Clear();
                    {
                        if (true)
                            return func;
                    }
                    break;

                case CLIPSParserConstants_Fields.IDENTIFIER:
                    exp = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.LBRACE:
                        case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                        case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                        case CLIPSParserConstants_Fields.STRING_LITERAL:
                        case CLIPSParserConstants_Fields.BIND:
                        case CLIPSParserConstants_Fields.BIND3:
                        case CLIPSParserConstants_Fields.BIND4:
                        case CLIPSParserConstants_Fields.TRUE:
                        case CLIPSParserConstants_Fields.TRUE2:
                        case CLIPSParserConstants_Fields.FALSE:
                        case CLIPSParserConstants_Fields.FALSE2:
                        case CLIPSParserConstants_Fields.IDENTIFIER:
                        case CLIPSParserConstants_Fields.PATH_LITERAL:
                            while (true)
                            {
                                valueParams(list);
                                switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                                {
                                    case CLIPSParserConstants_Fields.LBRACE:
                                    case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                                    case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                                    case CLIPSParserConstants_Fields.STRING_LITERAL:
                                    case CLIPSParserConstants_Fields.BIND:
                                    case CLIPSParserConstants_Fields.BIND3:
                                    case CLIPSParserConstants_Fields.BIND4:
                                    case CLIPSParserConstants_Fields.TRUE:
                                    case CLIPSParserConstants_Fields.TRUE2:
                                    case CLIPSParserConstants_Fields.FALSE:
                                    case CLIPSParserConstants_Fields.FALSE2:
                                    case CLIPSParserConstants_Fields.IDENTIFIER:
                                    case CLIPSParserConstants_Fields.PATH_LITERAL:
                                        ;
                                        break;

                                    default:
                                        jj_la1[14] = jj_gen;
                                        //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                                        goto label_8_brk;
                                }
                            }
                            //UPGRADE_NOTE: Label 'label_8_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                            label_8_brk:
                            ;

                            break;

                        default:
                            jj_la1[15] = jj_gen;
                            ;
                            break;
                    }
                    func = new ShellFunction();
                    func.Name = exp.image;
                    func.setParameters(ParameterUtils.convertParameters(list));
                    list.Clear();
                    {
                        if (true)
                            return func;
                    }
                    break;

                default:
                    jj_la1[16] = jj_gen;
                    jj_consume_token(- 1);
                    throw new ParseException();
            }
            throw new ApplicationException("Missing return statement in function");
        }
예제 #16
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            DefaultReturnVector ret = new DefaultReturnVector();
            bool eq = false;

            if (params_Renamed != null && params_Renamed.Length > 1)
            {
                Object first = null;
                if (params_Renamed[0] is ValueParam)
                {
                    ValueParam n = (ValueParam)params_Renamed[0];
                    first = n.Value;
                }
                else if (params_Renamed[0] is BoundParam)
                {
                    BoundParam bp = (BoundParam)params_Renamed[0];
                    first = (Decimal)engine.getBinding(bp.VariableName);
                }
                else if (params_Renamed[0] is FunctionParam2)
                {
                    FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                    n.Engine = engine;
                    n.lookUpFunction();
                    IReturnVector rval = (IReturnVector)n.Value;
                    first = rval.firstReturnValue().Value;
                }
                bool eval = true;
                for (int idx = 1; idx < params_Renamed.Length; idx++)
                {
                    Object right = null;
                    if (params_Renamed[idx] is ValueParam)
                    {
                        ValueParam n = (ValueParam)params_Renamed[idx];
                        right = n.Value;
                    }
                    else if (params_Renamed[idx] is BoundParam)
                    {
                        BoundParam bp = (BoundParam)params_Renamed[idx];
                        right = engine.getBinding(bp.VariableName);
                    }
                    else if (params_Renamed[idx] is FunctionParam2)
                    {
                        FunctionParam2 n = (FunctionParam2)params_Renamed[idx];
                        n.Engine = engine;
                        n.lookUpFunction();
                        IReturnVector rval = (IReturnVector)n.Value;
                        right = rval.firstReturnValue().Value;
                    }
                    if (first == null && right != null)
                    {
                        eval = false;
                        break;
                    }
                    else if (first != null && !first.Equals(right))
                    {
                        eval = false;
                        break;
                    }
                }
                eq = eval;
            }
            DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, eq);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #17
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            Object o         = null;
            String classname = null;

            if (params_Renamed != null && params_Renamed.Length == 1)
            {
                if (params_Renamed[0] is ValueParam)
                {
                    ValueParam n = (ValueParam)params_Renamed[0];
                    classname = n.StringValue;
                }
                else if (params_Renamed[0] is BoundParam)
                {
                    BoundParam bp = (BoundParam)params_Renamed[0];
                    classname = (String)engine.getBinding(bp.VariableName);
                }
                else if (params_Renamed[0] is FunctionParam2)
                {
                    FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                    n.Engine = engine;
                    n.lookUpFunction();
                    IReturnVector rval = (IReturnVector)n.Value;
                    classname = rval.firstReturnValue().StringValue;
                }
                try
                {
                    Type classDefinition = classnameResolver.resolveClass(classname);
                    o = CreateNewInstance(classDefinition);
                    if (o is IFunctionGroup)
                    {
                        engine.declareFunctionGroup((IFunctionGroup)o);
                    }
                }

                catch (UnauthorizedAccessException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (SecurityException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (ArgumentException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (Exception e)
                {
                    // TODO Auto-generated catch block
                    Trace.WriteLine(e.Message);
                }
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.OBJECT_TYPE, o);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #18
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            Object o         = null;
            String classname = null;

            Type[]   argsclass = null;
            Object[] args      = null;
            if (params_Renamed != null)
            {
                if (params_Renamed[0] is ValueParam)
                {
                    ValueParam n = (ValueParam)params_Renamed[0];
                    classname = n.StringValue;
                }
                else if (params_Renamed[0] is BoundParam)
                {
                    BoundParam bp = (BoundParam)params_Renamed[0];
                    classname = (String)engine.getBinding(bp.VariableName);
                }
                else if (params_Renamed[0] is FunctionParam2)
                {
                    FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                    n.Engine = engine;
                    n.lookUpFunction();
                    IReturnVector rval = (IReturnVector)n.Value;
                    classname = rval.firstReturnValue().StringValue;
                }
                args = new Object[params_Renamed.Length - 1];
                for (int idx = 1; idx < params_Renamed.Length; idx++)
                {
                    if (params_Renamed[idx] is ValueParam)
                    {
                        ValueParam n = (ValueParam)params_Renamed[idx];
                        args[idx - 1] = n.Value;
                    }
                    else if (params_Renamed[idx] is BoundParam)
                    {
                        BoundParam bp = (BoundParam)params_Renamed[idx];
                        args[idx - 1] = engine.getBinding(bp.VariableName);
                    }
                    else if (params_Renamed[idx] is FunctionParam2)
                    {
                        FunctionParam2 n = (FunctionParam2)params_Renamed[idx];
                        n.Engine = engine;
                        n.lookUpFunction();
                        IReturnVector rval = (IReturnVector)n.Value;
                        args[idx - 1] = rval.firstReturnValue().Value;
                    }
                }
                try
                {
                    Type            classDefinition  = classnameResolver.resolveClass(classname);
                    ConstructorInfo foundConstructor = null;
                    for (int idx = 0; idx < classDefinition.GetConstructors().Length; idx++)
                    {
                        ConstructorInfo constructor      = classDefinition.GetConstructors()[idx];
                        ParameterInfo[] parameterClasses = constructor.GetParameters();
                        if (parameterClasses.Length == args.Length)
                        {
                            bool match = true;
                            for (int i = 0; i < parameterClasses.Length; ++i)
                            {
                                match &= (parameterClasses[i].GetType().IsInstanceOfType(args[i]) || args[i] == null);
                            }
                            if (match)
                            {
                                foundConstructor = constructor;
                                break;
                            }
                        }
                    }
                    if (foundConstructor != null)
                    {
                        o = foundConstructor.Invoke(args);
                    }
                }

                catch (UnauthorizedAccessException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (SecurityException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (ArgumentException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (TargetInvocationException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (Exception e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.OBJECT_TYPE, o);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #19
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            String sval = new String("".ToCharArray());

            if (params_Renamed != null)
            {
                if (params_Renamed.Length == 1)
                {
                    if (params_Renamed[0] is ValueParam)
                    {
                        ValueParam n = (ValueParam)params_Renamed[0];
                        sval = n.StringValue;
                        IFunction aFunction = engine.findFunction(sval);
                        if (aFunction != null)
                        {
                            sval = aFunction.toPPString(null, 0);
                        }
                        else
                        {
                            sval = toPPString(null, 0);
                        }
                    }
                    else if (params_Renamed[0] is BoundParam)
                    {
                        BoundParam bp = (BoundParam)params_Renamed[0];
                        sval = bp.StringValue;
                        IFunction aFunction = engine.findFunction(sval);
                        if (aFunction != null)
                        {
                            sval = aFunction.toPPString(null, 0);
                        }
                        else
                        {
                            sval = toPPString(null, 0);
                        }
                    }
                    else if (params_Renamed[0] is FunctionParam2)
                    {
                        FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                        n.Engine = engine;
                        n.lookUpFunction();
                        IReturnVector rval = (IReturnVector)n.Value;
                        sval = rval.firstReturnValue().StringValue;
                        IFunction aFunction = engine.findFunction(sval);
                        if (aFunction != null)
                        {
                            sval = aFunction.toPPString(null, 0);
                        }
                        else
                        {
                            sval = toPPString(null, 0);
                        }
                    }
                }
                else
                {
                    sval = toPPString(null, 0);
                }
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.STRING_TYPE, sval);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #20
0
 /// <summary> Configure will lookup the function and set it
 /// </summary>
 public virtual void configure(Rete.Rete engine, IRule util)
 {
     if (functionName != null && engine.findFunction(functionName) != null)
     {
         faction = engine.findFunction(functionName);
     }
     // now setup the BoundParameters if there are any
     for (int idx = 0; idx < parameters.Length; idx++)
     {
         if (parameters[idx] is BoundParam)
         {
             BoundParam bp = (BoundParam) parameters[idx];
             Binding bd = util.getBinding(bp.VariableName);
             if (bd != null)
             {
                 bp.Row = bd.LeftRow;
                 bp.Column = bd.LeftIndex;
             }
         }
         else if (parameters[idx] is FunctionParam2)
         {
             FunctionParam2 fp2 = (FunctionParam2) parameters[idx];
             fp2.configure(engine, util);
         }
         else if (parameters[idx] is ValueParam)
         {
             ValueParam vp = (ValueParam) parameters[idx];
             // if the value is a deffact, we need to check and make sure
             // the slots with BoundParam value are compiled properly
             if (vp.Value is Deffact)
             {
                 ((Deffact) vp.Value).compileBinding(util);
             }
         }
     }
     // in the case of Assert, we do further compilation
     if (faction is AssertFunction)
     {
         Deftemplate tmpl = (Deftemplate) engine.CurrentFocus.getTemplate(parameters[0].StringValue);
         Deffact fact = (Deffact) tmpl.createFact((Object[]) parameters[1].Value, - 1);
         fact.compileBinding(util);
         parameters = new ValueParam[1];
         parameters[0] = new ValueParam(Constants.OBJECT_TYPE, fact);
     }
 }
예제 #21
0
        public void ValueParamTest()
        {
            ValueParam <string> OParam = new ValueParam <string>("Hello World!");

            Assert.IsTrue(OParam == "Hello World!");
        }
예제 #22
0
 public void actionParams(ArrayList list)
 {
     Object exp;
     ValueParam vp = null;
     switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
     {
         case BIND:
             exp = mcc_consume_token(BIND);
             if (exp is Token)
             {
                 BoundParam bp = new BoundParam();
                 bp.VariableName = ((Token) exp).image.Substring(1);
                 list.Add(bp);
             }
             break;
         case INTEGER_LITERAL:
         case FLOATING_POINT_LITERAL:
         case STRING_LITERAL:
         case PATH_LITERAL:
             exp = typeExpr();
             vp = new ValueParam();
             if (exp is Token)
             {
                 vp.Value = ((Token) exp).image;
             }
             else
             {
                 vp.Value = exp;
             }
             if (exp is long)
             {
                 vp.ValueType = Constants.LONG_PRIM_TYPE;
             }
             else if (exp is float)
             {
                 vp.ValueType = Constants.DOUBLE_PRIM_TYPE;
             }
             else if (exp is String)
             {
                 vp.ValueType = Constants.STRING_TYPE;
             }
             list.Add(vp);
             break;
         case IDENTIFIER:
             exp = mcc_consume_token(IDENTIFIER);
             vp = new ValueParam();
             vp.ValueType = Constants.STRING_TYPE;
             if (exp is Token)
             {
                 vp.Value = ((Token) exp).image;
             }
             else
             {
                 vp.Value = exp;
             }
             list.Add(vp);
             break;
         default:
             mcc_la1[62] = mcc_gen;
             mcc_consume_token(-1);
             throw new ParseException();
     }
 }
예제 #23
0
        public Object expr()
        {
            Token exp = null;
            Token exp2 = null;
            Token exp3 = null;
            String body;
            ValueParam param;
            Deffact fact;
            Deftemplate templ;
            Defrule rule;
            ShellFunction func;
            DeffunctionFunction dffunc;
            ArrayList list = new ArrayList();
            ValueParam[] pms;
            ArrayList infunc = new ArrayList();
            switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
            {
                case ASSERT:
                    exp = mcc_consume_token(ASSERT);
                    mcc_consume_token(LBRACE);
                    exp2 = mcc_consume_token(IDENTIFIER);
                    while (true)
                    {
                        assertContents(list);
                        switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                        {
                            case LBRACE:
                                ;
                                break;
                            default:
                                mcc_la1[3] = mcc_gen;
                                goto label_2;
                        }
                    }
                    label_2:
                    ;

                    mcc_consume_token(RBRACE);
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[2];
                    pms[0] = new ValueParam(Constants.STRING_TYPE, exp2.image);
                    pms[1] = new ValueParam(Constants.OBJECT_TYPE, list.ToArray());
                    func.setParameters(pms);
                    exp.Clear();
                    exp = null;
                    {
                        if (true) return func;
                    }
                    break;
                case ASSERTTEMPORAL:
                    exp = mcc_consume_token(ASSERTTEMPORAL);
                    mcc_consume_token(LBRACE);
                    exp2 = mcc_consume_token(IDENTIFIER);
                    while (true)
                    {
                        assertContents(list);
                        switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                        {
                            case LBRACE:
                                ;
                                break;
                            default:
                                mcc_la1[4] = mcc_gen;
                                goto label_3;
                        }
                    }
                    label_3:
                    ;

                    mcc_consume_token(RBRACE);
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[2];
                    pms[0] = new ValueParam(Constants.STRING_TYPE, exp2.image);
                    pms[1] = new ValueParam(Constants.OBJECT_TYPE, list.ToArray());
                    func.setParameters(pms);
                    exp.Clear();
                    exp = null;
                    {
                        if (true) return func;
                    }
                    break;
                case RETRACT:
                    exp = mcc_consume_token(RETRACT);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case BIND:
                            exp2 = mcc_consume_token(BIND);
                            break;
                        case INTEGER_LITERAL:
                            exp2 = mcc_consume_token(INTEGER_LITERAL);
                            break;
                        default:
                            mcc_la1[5] = mcc_gen;
                            mcc_consume_token(-1);
                            throw new ParseException();
                    }
                    func = new ShellFunction();
                    func.Name = exp.image;
                    IParameter[] rpms = new IParameter[1];
                    if (exp2.image.StartsWith("?"))
                    {
                        BoundParam bp1 = new BoundParam();
                        bp1.VariableName = exp2.image;
                        rpms[0] = bp1;
                    }
                    else
                    {
                        ValueParam vp = new ValueParam(Constants.BIG_DECIMAL, Convert.ToDecimal(exp2.image));
                        rpms[0] = vp;
                    }
                    func.setParameters(rpms);
                    exp.Clear();
                    exp = null;
                    exp2.Clear();
                    exp2 = null;
                    {
                        if (true) return func;
                    }
                    break;
                case MODIFY:
                    exp = mcc_consume_token(MODIFY);
                    exp2 = mcc_consume_token(BIND);
                    assertContents(list);
                    func = new ShellFunction();
                    func.Name = exp.image;
                    BoundParam bp = new BoundParam();
                    bp.VariableName = exp2.image;
                    list.Insert(0, bp);
                    func.setParameters(ParameterUtils.slotToParameters(list));
                    exp.Clear();
                    exp = null;
                    {
                        if (true) return func;
                    }
                    break;
                case DEFTEMPLATE:
                    exp = mcc_consume_token(DEFTEMPLATE);
                    templ = templateExpr();
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[1];
                    pms[0] = new ValueParam(Constants.OBJECT_TYPE, templ);
                    func.setParameters(pms);
                    {
                        if (true) return func;
                    }
                    break;
                case DEFMODULE:
                    exp = mcc_consume_token(DEFMODULE);
                    body = getIdentifier();
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[1];
                    pms[0] = new ValueParam(Constants.STRING_TYPE, body);
                    func.setParameters(pms);
                    {
                        if (true) return func;
                    }
                    break;
                case DEFRULE:
                    exp = mcc_consume_token(DEFRULE);
                    rule = ruleBody();
                    func = new ShellFunction();
                    func.Name = exp.image;
                    pms = new ValueParam[1];
                    pms[0] = new ValueParam(Constants.OBJECT_TYPE, rule);
                    func.setParameters(pms);
                    {
                        if (true) return func;
                    }
                    break;
                case DEFCLASS:
                    exp = mcc_consume_token(DEFCLASS);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case LBRACE:
                        case INTEGER_LITERAL:
                        case FLOATING_POINT_LITERAL:
                        case STRING_LITERAL:
                        case BIND:
                        case BIND3:
                        case BIND4:
                        case TRUE:
                        case TRUE2:
                        case FALSE:
                        case FALSE2:
                        case IDENTIFIER:
                        case PATH_LITERAL:
                            while (true)
                            {
                                valueParams(list);
                                switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                                {
                                    case LBRACE:
                                    case INTEGER_LITERAL:
                                    case FLOATING_POINT_LITERAL:
                                    case STRING_LITERAL:
                                    case BIND:
                                    case BIND3:
                                    case BIND4:
                                    case TRUE:
                                    case TRUE2:
                                    case FALSE:
                                    case FALSE2:
                                    case IDENTIFIER:
                                    case PATH_LITERAL:
                                        ;
                                        break;
                                    default:
                                        mcc_la1[6] = mcc_gen;
                                        goto label_4;
                                }
                            }
                            label_4:
                            ;

                            break;
                        default:
                            mcc_la1[7] = mcc_gen;
                            ;
                            break;
                    }
                    func = new ShellFunction();
                    func.Name = exp.image;
                    func.setParameters(ParameterUtils.convertParameters(list));
                    list.Clear();
                    {
                        if (true) return func;
                    }
                    break;
                case DEFFUNCTION:
                    exp = mcc_consume_token(DEFFUNCTION);
                    exp2 = mcc_consume_token(IDENTIFIER);
                    mcc_consume_token(LBRACE);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case BIND:
                        case BIND3:
                        case BIND4:
                            while (true)
                            {
                                bindingParams(list);
                                switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                                {
                                    case BIND:
                                    case BIND3:
                                    case BIND4:
                                        ;
                                        break;
                                    default:
                                        mcc_la1[8] = mcc_gen;
                                        goto label_5;
                                }
                            }
                            label_5:
                            ;

                            break;
                        default:
                            mcc_la1[9] = mcc_gen;
                            ;
                            break;
                    }
                    mcc_consume_token(RBRACE);
                    mcc_consume_token(LBRACE);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case BINDING:
                        case ASSERT:
                        case ASSERTTEMPORAL:
                        case DEFCLASS:
                        case DEFFUNCTION:
                        case DEFMODULE:
                        case DEFRULE:
                        case DEFTEMPLATE:
                        case MODIFY:
                        case RETRACT:
                        case PLUS:
                        case MINUS:
                        case MULTIPLY:
                        case DIVIDE:
                        case GT1:
                        case GT2:
                        case LT1:
                        case LT2:
                        case EQ1:
                        case EQ2:
                        case LE1:
                        case LE2:
                        case GE1:
                        case GE2:
                        case IDENTIFIER:
                            ruleAction(infunc);
                            break;
                        default:
                            mcc_la1[10] = mcc_gen;
                            ;
                            break;
                    }
                    mcc_consume_token(RBRACE);
                    dffunc = new DeffunctionFunction();
                    dffunc.Name = exp2.image;
                    dffunc.setParameters(ParameterUtils.convertParameters(list));
                    dffunc.Function = (infunc);
                    list.Clear();
                    {
                        if (true) return dffunc;
                    }
                    break;
                case BINDING:
                    mcc_consume_token(BINDING);
                    exp = getBindType();
                    while (true)
                    {
                        valueParams(list);
                        switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                        {
                            case LBRACE:
                            case INTEGER_LITERAL:
                            case FLOATING_POINT_LITERAL:
                            case STRING_LITERAL:
                            case BIND:
                            case BIND3:
                            case BIND4:
                            case TRUE:
                            case TRUE2:
                            case FALSE:
                            case FALSE2:
                            case IDENTIFIER:
                            case PATH_LITERAL:
                                ;
                                break;
                            default:
                                mcc_la1[11] = mcc_gen;
                                goto label_6;
                        }
                    }
                    label_6:
                    ;

                    func = new ShellFunction();
                    func.Name = "bind";
                    list.Insert(0, new ValueParam(Constants.STRING_TYPE, exp.image.Substring(1)));
                    func.setParameters(ParameterUtils.convertParameters(list));
                    list.Clear();
                    {
                        if (true) return func;
                    }
                    break;
                case PLUS:
                case MINUS:
                case MULTIPLY:
                case DIVIDE:
                case GT1:
                case GT2:
                case LT1:
                case LT2:
                case EQ1:
                case EQ2:
                case LE1:
                case LE2:
                case GE1:
                case GE2:
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case PLUS:
                            exp = mcc_consume_token(PLUS);
                            break;
                        case MINUS:
                            exp = mcc_consume_token(MINUS);
                            break;
                        case MULTIPLY:
                            exp = mcc_consume_token(MULTIPLY);
                            break;
                        case DIVIDE:
                            exp = mcc_consume_token(DIVIDE);
                            break;
                        case GT1:
                            exp = mcc_consume_token(GT1);
                            break;
                        case GT2:
                            exp = mcc_consume_token(GT2);
                            break;
                        case LT1:
                            exp = mcc_consume_token(LT1);
                            break;
                        case LT2:
                            exp = mcc_consume_token(LT2);
                            break;
                        case EQ1:
                            exp = mcc_consume_token(EQ1);
                            break;
                        case EQ2:
                            exp = mcc_consume_token(EQ2);
                            break;
                        case LE1:
                            exp = mcc_consume_token(LE1);
                            break;
                        case LE2:
                            exp = mcc_consume_token(LE2);
                            break;
                        case GE1:
                            exp = mcc_consume_token(GE1);
                            break;
                        case GE2:
                            exp = mcc_consume_token(GE2);
                            break;
                        default:
                            mcc_la1[12] = mcc_gen;
                            mcc_consume_token(-1);
                            throw new ParseException();
                    }
                    while (true)
                    {
                        valueParams(list);
                        switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                        {
                            case LBRACE:
                            case INTEGER_LITERAL:
                            case FLOATING_POINT_LITERAL:
                            case STRING_LITERAL:
                            case BIND:
                            case BIND3:
                            case BIND4:
                            case TRUE:
                            case TRUE2:
                            case FALSE:
                            case FALSE2:
                            case IDENTIFIER:
                            case PATH_LITERAL:
                                ;
                                break;
                            default:
                                mcc_la1[13] = mcc_gen;
                                goto label_7;
                        }
                    }
                    label_7:
                    ;

                    func = new ShellFunction();
                    func.Name = exp.image;
                    func.setParameters(ParameterUtils.convertParameters(list));
                    list.Clear();
                    {
                        if (true) return func;
                    }
                    break;
                case IDENTIFIER:
                    exp = mcc_consume_token(IDENTIFIER);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case LBRACE:
                        case INTEGER_LITERAL:
                        case FLOATING_POINT_LITERAL:
                        case STRING_LITERAL:
                        case BIND:
                        case BIND3:
                        case BIND4:
                        case TRUE:
                        case TRUE2:
                        case FALSE:
                        case FALSE2:
                        case IDENTIFIER:
                        case PATH_LITERAL:
                            while (true)
                            {
                                valueParams(list);
                                switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                                {
                                    case LBRACE:
                                    case INTEGER_LITERAL:
                                    case FLOATING_POINT_LITERAL:
                                    case STRING_LITERAL:
                                    case BIND:
                                    case BIND3:
                                    case BIND4:
                                    case TRUE:
                                    case TRUE2:
                                    case FALSE:
                                    case FALSE2:
                                    case IDENTIFIER:
                                    case PATH_LITERAL:
                                        ;
                                        break;
                                    default:
                                        mcc_la1[14] = mcc_gen;
                                        goto label_8;
                                }
                            }
                            label_8:
                            ;

                            break;
                        default:
                            mcc_la1[15] = mcc_gen;
                            ;
                            break;
                    }
                    func = new ShellFunction();
                    func.Name = exp.image;
                    func.setParameters(ParameterUtils.convertParameters(list));
                    list.Clear();
                    {
                        if (true) return func;
                    }
                    break;
                default:
                    mcc_la1[16] = mcc_gen;
                    mcc_consume_token(-1);
                    throw new ParseException();
            }
            throw new Exception("Missing return statement in function");
        }
예제 #24
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            Object o          = null;
            Object ro         = null;
            String methodname = null;

            Type[]   argsclass = null;
            Object[] args      = null;
            if (params_Renamed != null)
            {
                if (params_Renamed[0] is ValueParam)
                {
                    ValueParam n = (ValueParam)params_Renamed[0];
                    o = n.Value;
                }
                else if (params_Renamed[0] is BoundParam)
                {
                    BoundParam bp = (BoundParam)params_Renamed[0];
                    o = engine.getBinding(bp.VariableName);
                }
                else if (params_Renamed[0] is FunctionParam2)
                {
                    FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                    n.Engine = engine;
                    n.lookUpFunction();
                    IReturnVector rval = (IReturnVector)n.Value;
                    o = rval.firstReturnValue().Value;
                }
                if (params_Renamed[1] is ValueParam)
                {
                    ValueParam n = (ValueParam)params_Renamed[1];
                    methodname = n.StringValue;
                }
                else if (params_Renamed[1] is BoundParam)
                {
                    BoundParam bp = (BoundParam)params_Renamed[1];
                    methodname = (String)engine.getBinding(bp.VariableName);
                }
                else if (params_Renamed[1] is FunctionParam2)
                {
                    FunctionParam2 n = (FunctionParam2)params_Renamed[1];
                    n.Engine = engine;
                    n.lookUpFunction();
                    IReturnVector rval = (IReturnVector)n.Value;
                    methodname = rval.firstReturnValue().StringValue;
                }
                if (params_Renamed.Length > 2)
                {
                    argsclass = new Type[params_Renamed.Length - 1];
                    args      = new Object[params_Renamed.Length - 1];
                }
                for (int idx = 2; idx < params_Renamed.Length; idx++)
                {
                    if (params_Renamed[idx] is ValueParam)
                    {
                        ValueParam n = (ValueParam)params_Renamed[idx];
                        argsclass[idx - 1] = n.Value.GetType();
                        args[idx - 1]      = n.Value;
                    }
                    else if (params_Renamed[idx] is BoundParam)
                    {
                        BoundParam bp = (BoundParam)params_Renamed[idx];
                        argsclass[idx - 1] = engine.getBinding(bp.VariableName).GetType();
                        args[idx - 1]      = engine.getBinding(bp.VariableName);
                    }
                    else if (params_Renamed[idx] is FunctionParam2)
                    {
                        FunctionParam2 n = (FunctionParam2)params_Renamed[idx];
                        n.Engine = engine;
                        n.lookUpFunction();
                        IReturnVector rval = (IReturnVector)n.Value;
                        argsclass[idx - 1] = rval.firstReturnValue().Value.GetType();
                        args[idx - 1]      = rval.firstReturnValue().Value;
                    }
                }
                try
                {
                    Type       classDefinition = o.GetType();
                    MethodInfo method          = classDefinition.GetMethod(methodname, (Type[])argsclass);
                    ro = method.Invoke(o, (Object[])args);
                }
                catch (UnauthorizedAccessException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (SecurityException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (MethodAccessException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (ArgumentException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
                catch (TargetInvocationException e)
                {
                    // TODO Auto-generated catch block
                    System.Diagnostics.Trace.WriteLine(e.Message);
                }
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.OBJECT_TYPE, ro);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #25
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            Object result = null;

            if (params_Renamed != null)
            {
                if (params_Renamed.Length >= 3)
                {
                    bool conditionValue = false;
                    if (params_Renamed[0] is ValueParam)
                    {
                        ValueParam n = (ValueParam)params_Renamed[0];
                        conditionValue = n.BooleanValue;
                    }
                    else if (params_Renamed[0] is BoundParam)
                    {
                        BoundParam bp = (BoundParam)params_Renamed[0];
                        conditionValue = ((Boolean)engine.getBinding(bp.VariableName));
                    }
                    else if (params_Renamed[0] is FunctionParam2)
                    {
                        FunctionParam2 n = (FunctionParam2)params_Renamed[0];
                        n.Engine = engine;
                        n.lookUpFunction();
                        IReturnVector rval = (IReturnVector)n.Value;
                        conditionValue = rval.firstReturnValue().BooleanValue;
                    }
                    if (params_Renamed[1] is ValueParam && "then".Equals(params_Renamed[1].StringValue))
                    {
                        bool elseExpressions = false;
                        for (int i = 2; i < params_Renamed.Length; ++i)
                        {
                            if (params_Renamed[i] is ValueParam && "else".Equals(params_Renamed[i].StringValue))
                            {
                                elseExpressions = true;
                            }
                            else
                            {
                                if ((conditionValue && !elseExpressions) || (!conditionValue && elseExpressions))
                                {
                                    if (params_Renamed[i] is ValueParam)
                                    {
                                        ValueParam n = (ValueParam)params_Renamed[i];
                                        result = n.Value;
                                    }
                                    else if (params_Renamed[i] is BoundParam)
                                    {
                                        BoundParam bp = (BoundParam)params_Renamed[i];
                                        result = engine.getBinding(bp.VariableName);
                                    }
                                    else if (params_Renamed[i] is FunctionParam2)
                                    {
                                        FunctionParam2 n = (FunctionParam2)params_Renamed[i];
                                        n.Engine = engine;
                                        n.lookUpFunction();
                                        IReturnVector rval = (IReturnVector)n.Value;
                                        if (rval.size() > 0)
                                        {
                                            result = rval.firstReturnValue().Value;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue  rv  = new DefaultReturnValue(Constants.OBJECT_TYPE, result);

            ret.addReturnValue(rv);
            return(ret);
        }
예제 #26
0
        public ValueParam[] assertBody()
        {
            Token exp;
            ArrayList tokens = new ArrayList();
            ValueParam[] param = null;
            mcc_consume_token(LBRACE);
            exp = mcc_consume_token(IDENTIFIER);
            while (true)
            {
                assertContents(tokens);
                switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                {
                    case LBRACE:
                        ;
                        break;
                    default:
                        mcc_la1[19] = mcc_gen;
                        goto label_9;
                }
            }
            label_9:
            ;

            mcc_consume_token(RBRACE);
            param = new ValueParam[2];
            param[0] = new ValueParam(Constants.STRING_TYPE, exp.image);
            param[1] = new ValueParam(Constants.OBJECT_TYPE, tokens.ToArray());
            tokens.Clear();
            exp = null;
            {
                if (true) return param;
            }
            throw new Exception("Missing return statement in function");
        }
예제 #27
0
파일: MainEvent.cs 프로젝트: makmen/WPF
 public override string ToString()
 {
     return(Title + " " + MainParam.Name + " " + ValueParam.ToString());
 }
예제 #28
0
파일: DataItems.cs 프로젝트: bQvle/Sqline
 public TestInsert(ValueParam <bool> processed)
 {
     Initialize("dbo", "Test", Sqline.Tests.DataAccess.DAHandler.SqlineConfig);
     SetPrimaryKeyInfo("ID", "int");
     FProcessed = processed;
 }