public static void SendUnhandledException(EcmaValue value) { Exception ex = null; if (value.GetUnderlyingObject() is EcmaError e) { ex = e.Exception; } RuntimeExecution current = EnsureInstance(); current.UnhandledException?.Invoke(null, new RuntimeUnhandledExceptionEventArgs(ex ?? EcmaException.FromValue(value), value)); }
private EcmaValue ThrowOriginalValue(EcmaValue _) { throw EcmaException.FromValue(originalValue); }
public bool MoveNext() { begin: IGeneratorEnumerator top; Yield.ResumeValue = context.ResumeValue; while ((top = stack[0]) != this) { // iterate through inner generators // remove it from the stack if inner generator is completed if (top.MoveNext()) { return(true); } Yield.ResumeValue = stack[0].Current; stack.RemoveAt(0); } if (state == State.Closed) { return(false); } bool moveNext = true; if (afterYield) { switch (context.ResumeState) { case GeneratorResumeState.Return: moveNext = SetFinally(); break; case GeneratorResumeState.Throw: moveNext = SetException(EcmaException.FromValue(context.ResumeValue)); break; } } while (moveNext) { GeneratorDelegateEnumerator previous = current; iterator = iterator ?? tryBlock().GetEnumerator(); afterYield = false; current = this; try { if (iterator.MoveNext()) { afterYield = true; if (stack[0] != this) { // new generator scope is pushed to the stack by either a yield* or try-catch block // ignore the yielded dummy value and begin iterate through the delegated enumerator goto begin; } return(true); } } catch (GeneratorClosedException) { } catch (Exception ex) { moveNext = SetException(ex); continue; } finally { current = previous; } moveNext = SetFinally(); } return(false); }