示例#1
0
        public IodineGenerator(StackFrame parentFrame, IodineInstanceMethodWrapper baseMethod,
			IodineObject[] args)
            : base(TypeDef)
        {
            arguments = args;
            self = baseMethod.Self;
            this.baseMethod = baseMethod.Method;
        }
示例#2
0
		public StackFrame (IodineMethod method, StackFrame parent, IodineObject self, int localCount,
		                   IodineObject[] locals) : this (method, parent, self, localCount)
		{
			parentLocals = locals;
			this.locals = new IodineObject[localCount];
			for (int i = 0; i < localCount; i++) {
				this.locals [i] = locals [i]; 
			}
		}
示例#3
0
		public StackFrame (IodineMethod method, StackFrame parent, IodineObject self, int localCount)
		{
			LocalCount = localCount;
			locals = new IodineObject[localCount];
			parentLocals = locals;
			Method = method;
			Self = self;
			Parent = parent;
		}
示例#4
0
		public NativeStackFrame (InternalMethodCallback method, StackFrame parent)
			: base (null, parent, null, 0)
		{
			this.NativeMethod = method;
		}
示例#5
0
		internal StackFrame Duplicate (StackFrame top, int localCount)
		{
			if (localCount > LocalCount) {
				IodineObject[] oldLocals = locals;
				locals = new IodineObject[localCount];
				Array.Copy (oldLocals, locals, oldLocals.Length);
			}
			return new StackFrame (Method, top, Self, Math.Max (LocalCount, localCount), locals);
		}
示例#6
0
			public DebugResponse (SourceLocation location, StackFrame frame)
			{
				Location = location;
				Frame = frame;
			}
示例#7
0
        private IodineObject Invoke(IodineMethod method, IodineObject[] arguments)
        {
            if (method.Body.Count > 0)
            {
                currentLocation = method.Body [0].Location;
            }

            int insCount      = method.Body.Count;
            int prevStackSize = stackSize;
            int i             = 0;

            foreach (string param in method.Parameters.Keys)
            {
                if (method.Variadic && (method.AcceptsKeywordArgs ? i == method.Parameters.Keys.Count - 2 :
                                        i == method.Parameters.Keys.Count - 1))
                {
                    IodineObject[] tupleItems = new IodineObject[arguments.Length - i];
                    Array.Copy(arguments, i, tupleItems, 0, arguments.Length - i);
                    Top.StoreLocal(method.Parameters [param], new IodineTuple(tupleItems));
                }
                else if (i == method.Parameters.Keys.Count - 1 && method.AcceptsKeywordArgs)
                {
                    if (i < arguments.Length && arguments [i] is IodineHashMap)
                    {
                        Top.StoreLocal(method.Parameters [param], arguments [i]);
                    }
                    else
                    {
                        Top.StoreLocal(method.Parameters [param], new IodineHashMap());
                    }
                }
                else
                {
                    Top.StoreLocal(method.Parameters [param], arguments [i++]);
                }
            }
            StackFrame top = Top;

            if (traceCallback != null)
            {
                Trace(TraceType.Function, top, currentLocation);
            }

            while (top.InstructionPointer < insCount && !top.AbortExecution && !Top.Yielded)
            {
                instruction = method.Body [Top.InstructionPointer++];
                if (traceCallback != null && instruction.Location.Line != currentLocation.Line)
                {
                    Trace(TraceType.Line, top, instruction.Location);
                }
                ExecuteInstruction();
                top.Location = currentLocation;
            }

            IodineObject retVal = lastObject ?? IodineNull.Instance;

            while (top.DisposableObjects.Count > 0)
            {
                top.DisposableObjects.Pop().Exit(this);
            }

            stackSize = prevStackSize;

            if (top.AbortExecution)
            {
                return(IodineNull.Instance);
            }

            EndFrame();

            return(retVal);
        }
示例#8
0
 public IodineClosure(StackFrame frame, IodineMethod target)
     : base(TypeDefinition)
 {
     this.frame = frame;
     Target     = target;
 }
示例#9
0
 public IodineGenerator(StackFrame parentFrame, IodineMethod baseMethod, IodineObject[] args)
     : base(TypeDef)
 {
     arguments = args;
     this.baseMethod = baseMethod;
 }
示例#10
0
 private void NewFrame(IodineMethod method, IodineObject self, int localCount)
 {
     frameCount++;
     Top = new StackFrame (method, Top, self, localCount);
     frames.Push (Top);
 }
示例#11
0
 public StackFrame EndFrame()
 {
     frameCount--;
     StackFrame ret = frames.Pop ();
     if (frames.Count != 0) {
         Top = frames.Peek ();
     } else {
         Top = null;
     }
     return ret;
 }
示例#12
0
 private void NewFrame(StackFrame frame)
 {
     frameCount++;
     Top = frame;
     frames.Push (frame);
 }
示例#13
0
 public void Unwind(int frames)
 {
     for (int i = 0; i < frames; i++) {
         StackFrame frame = this.frames.Pop ();
         frame.AbortExecution = true;
     }
     frameCount -= frames;
     Top = this.frames.Peek ();
 }
示例#14
0
        public IodineObject InvokeMethod(IodineMethod method, StackFrame frame, IodineObject self,
		                                  IodineObject[] arguments)
        {
            int requiredArgs = method.AcceptsKeywordArgs ? method.ParameterCount - 1 :
                method.ParameterCount;
            if ((method.Variadic && arguments.Length + 1 < requiredArgs) ||
                (!method.Variadic && arguments.Length < requiredArgs)) {
                RaiseException (new IodineArgumentException (method.ParameterCount));
                return null;
            }

            NewFrame (frame);
            return Invoke (method, arguments);
        }
示例#15
0
 public UnhandledIodineExceptionException(StackFrame frame, IodineObject original)
 {
     OriginalException = original;
     Frame = frame;
 }
示例#16
0
 public override void IterReset(VirtualMachine vm)
 {
     stackFrame = new StackFrame (baseMethod, vm.Top, null, this.baseMethod.LocalCount);
 }
示例#17
0
		public IodineClosure (StackFrame frame, IodineMethod target)
			: base (TypeDefinition)
		{
			this.frame = frame;
			Target = target;
		}
示例#18
0
		private void Trace (TraceType type, StackFrame frame, SourceLocation location)
		{
			pauseVirtualMachine.WaitOne ();
			if (traceCallback (type, this, frame, location)) {
				pauseVirtualMachine.Reset ();
			}
		}