Пример #1
0
 //返回一个调用函数 Object
 private CodeCallFunction GetFunction(CodeObject member)
 {
     CodeCallFunction ret = new CodeCallFunction();
     ReadLeftParenthesis();
     List<CodeObject> pars = new List<CodeObject>();
     Token token = PeekToken();
     while (token.Type != TokenType.RightPar)
     {
         pars.Add(GetObject());
         token = PeekToken();
         if (token.Type == TokenType.Comma)
             ReadComma();
         else if (token.Type == TokenType.RightPar)
             break;
         else
             throw new ParserException("Comma ',' or right parenthesis ')' expected in function declararion.", token);
     }
     ReadRightParenthesis();
     ret.Member = member;
     ret.Parameters = pars;
     return ret;
 }
Пример #2
0
 ScriptObject ParseCall(CodeCallFunction scriptFunction, bool needRet)
 {
     ScriptObject obj = ResolveOperand(scriptFunction.Member);
     int num = scriptFunction.ParametersCount;
     ScriptObject[] parameters = new ScriptObject[num];
     for (int i = 0; i < num; ++i) {
         //此处要调用Assign 如果传入number string等基础类型  在函数内自运算的话 会影响 传入的值
         parameters[i] = ResolveOperand(scriptFunction.Parameters[i]).Assign();
     }
     m_script.PushStackInfo();
     object ret = obj.Call(parameters);
     m_script.PopStackInfo();
     return needRet ? m_script.CreateObject(ret) : null;
 }
Пример #3
0
 ScriptObject ParseCall(CodeCallFunction scriptFunction, bool needRet)
 {
     ScriptObject obj = ResolveOperand(scriptFunction.Member);
     int num = scriptFunction.Parameters.Count;
     ScriptObject[] parameters = new ScriptObject[num];
     for (int i = 0; i < num; ++i) {
         parameters[i] = ResolveOperand(scriptFunction.Parameters[i]);
     }
     m_script.PushStackInfo();
     object ret = obj.Call(parameters);
     return needRet ? m_script.CreateObject(ret) : null;
 }