Example #1
0
        //	Accepts pattersn:
        //	, @method @prose ,
        //	, @method ,
        public override PNode evaluate(PNode evaluateMe, PatternMatcher successfulMatch)
        {
            PatternMatcher match = successfulMatch;

            //	Extract the "arguments" from the PatternMatcher.
            List <PNode> M = match.Matching;                            //	The pattern -> prose index from the match

            MethodNameWord     methodWord = (MethodNameWord)M[1].value;
            List <ProseObject> args;
            ProseObject        terminalPunctuation;

            //	Depending on whether or not our method has arguments.
            if (successfulMatch.NumObjectsMatched > 3)
            {
                args = successfulMatch.getArgumentAsProseAtIndex(2);
                terminalPunctuation = M[3].value;
            }
            else
            {
                args = new List <ProseObject>();
                terminalPunctuation = M[2].value;
            }

            ProseAction action = new MethodDelegateAction(methodWord, args);

            value    = new ProseObject[3];
            value[0] = M[0].value;
            value[1] = action;
            value[2] = terminalPunctuation;

            PNode ret = replaceWithValueAt(evaluateMe, successfulMatch);

            value = null;
            return(ret);
        }
Example #2
0
        public void performAction(ProseRuntime runtime)
        {
            //	Look up the type.

            MethodInfo methodInfo = typeWord.TypeObject.GetMethod(methodName, BindingFlags.Public|BindingFlags.Static);
            ProseLanguage.ActionDelegate delegateMethod = (ProseLanguage.ActionDelegate) Delegate.CreateDelegate(typeof(ProseLanguage.ActionDelegate), methodInfo);
            MethodNameWord methodNameWord = new MethodNameWord(rawWords, runtime, delegateMethod);
            runtime.addWord(methodNameWord);
        }
Example #3
0
        public void performAction(ProseRuntime runtime)
        {
            //	Look up the type.

            MethodInfo methodInfo = typeWord.TypeObject.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static);

            ProseLanguage.ActionDelegate delegateMethod = (ProseLanguage.ActionDelegate)Delegate.CreateDelegate(typeof(ProseLanguage.ActionDelegate), methodInfo);
            MethodNameWord methodNameWord = new MethodNameWord(rawWords, runtime, delegateMethod);

            runtime.addWord(methodNameWord);
        }
 public MethodDelegateAction(MethodNameWord methodName, List <ProseObject> args)
 {
     this.methodName = methodName;
     this.args       = args;
     this.method     = methodName.DelegateMethod;
 }
Example #5
0
 public MethodDelegateAction(MethodNameWord methodName, List<ProseObject> args)
 {
     this.methodName = methodName;
     this.args = args;
     this.method = methodName.DelegateMethod;
 }