public void Dispose() { if (!disposed) { RuntimeFunctionInvocation parent = this.Parent; bool isSuspendedDispose = parent != null && previous != parent; if (current == this) { current = previous; } if (this.SuspendOnDispose) { if (parent != null) { parent.childCount++; } } else if (childCount == 0) { disposed = true; if (isSuspendedDispose && parent.childCount == 0) { parent.Dispose(); } } previous = null; } }
public static RuntimeFunction GetExecutingFunction() { RuntimeFunctionInvocation current = RuntimeFunctionInvocation.Current; if (current == null) { return(null); } return(current.FunctionObject); }
public override EcmaValue Call(EcmaValue thisValue, params EcmaValue[] arguments) { Guard.ArgumentNotNull(arguments, "arguments"); if (this.HomeObject == this) { throw new EcmaTypeErrorException(InternalString.Error.MustCallAsConstructor); } using (RuntimeFunctionInvocation invocation = new RuntimeFunctionInvocation(this, thisValue, arguments)) { return(Invoke(invocation, arguments)); } }
private EcmaValue GetCurrentArguments() { RuntimeFunctionInvocation invocation = RuntimeFunctionInvocation.Current; for (; invocation != null; invocation = invocation.Parent) { if (invocation.FunctionObject == this) { return(invocation.Arguments); } } return(EcmaValue.Null); }
public IDisposable Resume() { if (disposed) { throw new ObjectDisposedException(""); } if (this.Parent != null) { this.Parent.childCount--; } previous = current; current = this; return(this); }
internal RuntimeFunctionInvocation(RuntimeFunction method, EcmaValue thisValue, EcmaValue[] arguments, RuntimeObject newTarget = null) { this.FunctionObject = method; this.Parent = current; this.ThisValue = thisValue; this.NewTarget = newTarget; this.arguments = arguments; this.previous = current; if (method.IsHomedMethod || method.IsDerivedConstructor) { this.Super = new SuperAccessor(this, method.HomeObject); } current = this; }
private EcmaValue GetCurrentCallee() { RuntimeFunctionInvocation invocation = RuntimeFunctionInvocation.Current; bool returnCaller = false; for (; invocation != null; invocation = invocation.Parent) { if (returnCaller) { return(invocation.FunctionObject); } if (invocation.FunctionObject == this) { returnCaller = true; } } return(EcmaValue.Null); }
public override EcmaValue Construct(EcmaValue[] arguments, RuntimeObject newTarget) { Guard.ArgumentNotNull(arguments, "arguments"); Guard.ArgumentNotNull(newTarget, "newTarget"); if (!this.IsConstructor || !newTarget.IsConstructor || (this.HomeObject != null && this.HomeObject != this)) { throw new EcmaTypeErrorException(InternalString.Error.NotConstructor); } RuntimeObject thisValue = IsDerivedFromInternalClass() ? default : ConstructThisValue(newTarget); using (RuntimeFunctionInvocation invocation = new RuntimeFunctionInvocation(this, thisValue, arguments, newTarget)) { EcmaValue returnValue = Invoke(invocation, arguments); if (returnValue.Type == EcmaValueType.Object) { return(returnValue); } if (invocation.Super != null && !invocation.Super.ConstructorInvoked) { throw new EcmaReferenceErrorException(InternalString.Error.SuperConstructorNotCalled); } return(invocation.ThisValue); } }
protected override EcmaValue Invoke(RuntimeFunctionInvocation invocation, EcmaValue[] arguments) { return(EcmaValue.Undefined); }
protected virtual EcmaValue Invoke(RuntimeFunctionInvocation invocation, EcmaValue[] arguments) { throw new EcmaTypeErrorException(InternalString.Error.IllegalInvocation); }
internal SuperAccessor(RuntimeFunctionInvocation invocation, RuntimeObject homeObject) { this.invocation = invocation; this.homeObject = homeObject; }
protected override EcmaValue Invoke(RuntimeFunctionInvocation invocation, EcmaValue[] arguments) { return(GetDelegate()(invocation, arguments, method.IsStatic ? null : invocation.ThisValue.GetUnderlyingObject())); }
protected override EcmaValue Invoke(RuntimeFunctionInvocation invocation, EcmaValue[] arguments) { return(GetDelegate()(invocation, arguments, target)); }
protected override EcmaValue Invoke(RuntimeFunctionInvocation invocation, EcmaValue[] arguments) { return(new AsyncGenerator(invocation, new GeneratorDelegateEnumerator(generator))); }