Push() public method

public Push ( Wren.Core.Objects.Obj c ) : void
c Wren.Core.Objects.Obj
return void
示例#1
0
        static bool prim_fiber_new(WrenVM vm, Obj[] args, int stackStart)
        {
            Obj o = args[stackStart + 1];
            if (o is ObjFn || o is ObjClosure)
            {
                ObjFiber newFiber = new ObjFiber(o);

                // The compiler expects the first slot of a function to hold the receiver.
                // Since a fiber's stack is invoked directly, it doesn't have one, so put it
                // in here.
                newFiber.Push(Obj.Null);

                args[stackStart] = newFiber;
                return true;
            }

            vm.Fiber.Error = Obj.MakeString("Argument must be a function.");
            return false;
        }
示例#2
0
        static PrimitiveResult prim_fiber_new(WrenVM vm, ObjFiber fiber, Value[] args)
        {
            Obj o = args[1].Obj;
            if (o.Type == ObjType.Fn || o.Type == ObjType.Closure)
            {
                ObjFiber newFiber = new ObjFiber(o);

                // The compiler expects the first slot of a function to hold the receiver.
                // Since a fiber's stack is invoked directly, it doesn't have one, so put it
                // in here.
                newFiber.Push(Value.Null);

                args[0] = new Value(newFiber);
                return PrimitiveResult.Value;
            }

            args[0] = new Value("Argument must be a function.");
            return PrimitiveResult.Error;
        }