Exemplo n.º 1
0
        internal HybInstance RunWrappedFunc(HybInstance _this, Func <HybInstance[], HybInstance> func, HybInstance[] args)
        {
            BindThis(_this);
            var ret = func.Invoke(args);

            if (Halt == HaltType.Return)
            {
                Halt = HaltType.None;
            }
            return(ret);
        }
Exemplo n.º 2
0
        internal HybInstance RunMethod(SSInterpretMethodInfo method, HybInstance[] args)
        {
            Ret = null;
            Ctx.PushMethod(method);

            var node  = ((SSInterpretMethodInfo)method).Declaration;
            var vf    = new VarFrame(null);
            var count = 0;

            foreach (var p in method.Parameters)
            {
                if (p.DefaultValue == null)
                {
                    continue;
                }
                vf.SetValue(p.Id, p.DefaultValue);
            }
            foreach (var arg in args)
            {
                var p = method.Parameters[count++];
                if (p.IsParams)
                {
                    break;
                }

                vf.SetValue(p.Id, arg);
            }

            if (method.IsVaArg)
            {
                var paramId = node.ParameterList.Parameters.Last()
                              .Identifier.Text;

                var vaArgs = args.Skip(count - 1).ToArray();
                vf.SetValue(paramId, HybInstance.ObjectArray(vaArgs));
            }

            Frames.Push(Vars);
            Vars = null;

            if (node.Body != null)
            {
                if (method.ReturnType != null && // ctor doesn't have return type
                    method.ReturnType.IsCompiledType &&
                    method.ReturnType.CompiledType == typeof(IEnumerator))
                {
                    var enumerator = new SSEnumerator(this, node.Body, vf);
                    Ret = HybInstance.Object(enumerator);
                }
                else
                {
                    RunBlock(node.Body, vf);
                }
            }
            else
            {
                Ret = RunArrowExpressionClause(node.ExpressionBody, vf);
            }

            Vars = Frames.Pop();

            if (Halt == HaltType.Return)
            {
                Halt = HaltType.None;
            }

            Ctx.PopMethod();

            return(Ret);
        }
Exemplo n.º 3
0
 internal HaltedTick(int requestId, TickType tickType, HaltType haltType)
 {
     RequestId = requestId;
     TickType  = tickType;
     HaltType  = haltType;
 }