コード例 #1
0
ファイル: Repl.java プロジェクト: anba/es6draft
 private void errorReporter(ExecutionContext cx, Throwable throwable) {
   try {
     throw throwable;
   } catch (StopExecutionException e) {
     if (e.getReason() == Reason.Quit) {
       System.exit(0);
     }
   } catch (ScriptException e) {
     handleException(cx.getRealm(), e);
   } catch (UnhandledRejectionException e) {
     handleException(cx.getRealm(), e);
   } catch (StackOverflowError e) {
     handleException(cx.getRealm(), e);
   } catch (OutOfMemoryError e) {
     handleException(cx.getRealm(), e);
   } catch (InternalException e) {
     handleException(e);
   } catch (BootstrapMethodError e) {
     handleException(e.getCause());
   } catch (UncheckedIOException e) {
     handleException(e.getCause());
   } catch (Throwable e) {
     printStackTrace(System.err, e, options.stacktraceDepth);
     System.exit(1);
   }
 }
コード例 #2
0
 /**
  * 9.2.6 GeneratorFunctionCreate (kind, ParameterList, Body, Scope, Strict)
  *
  * @param cx the execution context
  * @param kind the function kind
  * @param function the function code
  * @param scope the lexical environment
  * @return the new generator function object
  */
 public static OrdinaryConstructorGenerator ConstructorGeneratorFunctionCreate(
     ExecutionContext cx,
     FunctionKind kind,
     RuntimeInfo.Function function,
     LexicalEnvironment<?> scope) {
   assert function.isGenerator() && kind != FunctionKind.ClassConstructor;
   /* step 1 */
   ScriptObject functionPrototype = cx.getIntrinsic(Intrinsics.Generator);
   /* step 2 */
   OrdinaryConstructorGenerator f =
       FunctionAllocate(cx, functionPrototype, function.isStrict(), kind);
   /* step 3 */
   FunctionInitialize(f, kind, function, scope, cx.getCurrentExecutable());
   return f;
 }
コード例 #3
0
ファイル: SymbolConstructor.java プロジェクト: anba/es6draft
 /**
  * 19.4.2.1 Symbol.for (key)
  *
  * @param cx the execution context
  * @param thisValue the function this-value
  * @param key the symbol string key
  * @return the mapped symbol
  */
 @Function(name = "for", arity = 1)
 public static Object _for(ExecutionContext cx, Object thisValue, Object key) {
   /* steps 1-2 */
   String stringKey = ToFlatString(cx, key);
   /* steps 3-7 */
   return cx.getRealm().getSymbolRegistry().getSymbol(stringKey);
 }
コード例 #4
0
ファイル: SymbolConstructor.java プロジェクト: anba/es6draft
 /**
  * 19.4.2.5 Symbol.keyFor (sym)
  *
  * @param cx the execution context
  * @param thisValue the function this-value
  * @param sym the global symbol
  * @return the symbol string key or undefined if the symbol is not in the registry
  */
 @Function(name = "keyFor", arity = 1)
 public static Object keyFor(ExecutionContext cx, Object thisValue, Object sym) {
   /* step 1 */
   if (!Type.isSymbol(sym)) {
     throw newTypeError(cx, Messages.Key.NotSymbol);
   }
   /* steps 2-3 */
   String key = cx.getRealm().getSymbolRegistry().getKey(Type.symbolValue(sym));
   /* step 4 */
   return key != null ? key : UNDEFINED;
 }
コード例 #5
0
 /**
  * 9.2.3 FunctionAllocate (functionPrototype, strict [,functionKind] )
  *
  * @param cx the execution context
  * @param functionPrototype the function prototype
  * @param strict the strict mode flag
  * @param kind the function kind
  * @return the new generator function object
  */
 public static OrdinaryConstructorGenerator FunctionAllocate(
     ExecutionContext cx, ScriptObject functionPrototype, boolean strict, FunctionKind kind) {
   assert kind != FunctionKind.ClassConstructor;
   Realm realm = cx.getRealm();
   /* steps 1-5 (implicit) */
   /* steps 6-9 */
   OrdinaryConstructorGenerator f = new OrdinaryConstructorGenerator(realm);
   /* steps 10-14 */
   f.allocate(realm, functionPrototype, strict, kind, ConstructorKind.Derived);
   /* step 15 */
   return f;
 }
コード例 #6
0
ファイル: BaseShellFunctions.java プロジェクト: anba/es6draft
 /**
  * shell-function: {@code print(message)}
  *
  * @param cx the execution context
  * @param messages the string to print
  */
 @Function(name = "print", arity = 1)
 public void print(ExecutionContext cx, String... messages) {
   PrintWriter writer = cx.getRuntimeContext().getConsole().writer();
   writer.println(Strings.concatWith(' ', messages));
 }
コード例 #7
0
ファイル: BaseShellFunctions.java プロジェクト: anba/es6draft
 /**
  * shell-function: {@code readline()}
  *
  * @param cx the execution context
  * @return the read line from stdin
  */
 @Function(name = "readline", arity = 0)
 public String readline(ExecutionContext cx) {
   return cx.getRuntimeContext().getConsole().readLine();
 }
コード例 #8
0
ファイル: NumberObject.java プロジェクト: leobalter/es6draft
 /**
  * Creates a new Number object.
  *
  * @param cx the execution context
  * @param numberData the number value
  * @param prototype the prototype object
  * @return the new number object
  */
 public static NumberObject NumberCreate(
     ExecutionContext cx, double numberData, ScriptObject prototype) {
   return new NumberObject(cx.getRealm(), numberData, prototype);
 }
コード例 #9
0
ファイル: NumberObject.java プロジェクト: leobalter/es6draft
 /**
  * Creates a new Number object with the default %NumberPrototype% prototype object.
  *
  * @param cx the execution context
  * @param numberData the number value
  * @return the new number object
  */
 public static NumberObject NumberCreate(ExecutionContext cx, double numberData) {
   return new NumberObject(cx.getRealm(), numberData, cx.getIntrinsic(Intrinsics.NumberPrototype));
 }