Java Code Examples for jdk.nashorn.internal.runtime.ScriptEnvironment

The following examples show how to use jdk.nashorn.internal.runtime.ScriptEnvironment. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: hottub   Source File: CompilationPhase.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) {
    final FunctionNode newFunctionNode = transformFunction(fn, new LocalVariableTypesCalculator(compiler));
    final ScriptEnvironment senv = compiler.getScriptEnvironment();
    final PrintWriter       err  = senv.getErr();

    //TODO separate phase for the debug printouts for abstraction and clarity
    if (senv._print_lower_ast || fn.getFlag(FunctionNode.IS_PRINT_LOWER_AST)) {
        err.println("Lower AST for: " + quote(newFunctionNode.getName()));
        err.println(new ASTWriter(newFunctionNode));
    }

    if (senv._print_lower_parse || fn.getFlag(FunctionNode.IS_PRINT_LOWER_PARSE)) {
        err.println("Lower AST for: " + quote(newFunctionNode.getName()));
        err.println(new PrintVisitor(newFunctionNode));
    }

    return newFunctionNode;
}
 
Example 2
Source Project: jdk8u60   Source File: Parser.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
Example 3
/**
 * Collects the byte codes for a generated JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @return Byte codes for the class.
 */
private byte[] toByteArray(final ClassEmitter classEmitter) {
    classEmitter.end();

    final byte[] code = classEmitter.toByteArray();
    final ScriptEnvironment env = context.getEnv();

    if (env._print_code) {
        env.getErr().println(ClassEmitter.disassemble(code));
    }

    if (env._verify_code) {
        context.verify(code);
    }

    return code;
}
 
Example 4
Source Project: openjdk-jdk8u   Source File: Parser.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
Example 5
Source Project: nashorn   Source File: Parser.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict) {
    super(source, errors, strict);
    this.env       = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }
}
 
Example 6
Source Project: openjdk-jdk8u   Source File: Shell.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run method logic.
 *
 * @param in input stream for Shell
 * @param out output stream for Shell
 * @param err error stream for Shell
 * @param args arguments to Shell
 *
 * @return exit code
 *
 * @throws IOException if there's a problem setting up the streams
 */
protected final int run(final InputStream in, final OutputStream out, final OutputStream err, final String[] args) throws IOException {
    final Context context = makeContext(in, out, err, args);
    if (context == null) {
        return COMMANDLINE_ERROR;
    }

    final Global global = context.createGlobal();
    final ScriptEnvironment env = context.getEnv();
    final List<String> files = env.getFiles();
    if (files.isEmpty()) {
        return readEvalPrint(context, global);
    }

    if (env._compile_only) {
        return compileScripts(context, global, files);
    }

    if (env._fx) {
        return runFXScripts(context, global, files);
    }

    return runScripts(context, global, files);
}
 
Example 7
Source Project: openjdk-jdk8u-backup   Source File: Parser.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
Example 8
Source Project: openjdk-jdk8u-backup   Source File: Shell.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run method logic.
 *
 * @param in input stream for Shell
 * @param out output stream for Shell
 * @param err error stream for Shell
 * @param args arguments to Shell
 *
 * @return exit code
 *
 * @throws IOException if there's a problem setting up the streams
 */
protected final int run(final InputStream in, final OutputStream out, final OutputStream err, final String[] args) throws IOException {
    final Context context = makeContext(in, out, err, args);
    if (context == null) {
        return COMMANDLINE_ERROR;
    }

    final Global global = context.createGlobal();
    final ScriptEnvironment env = context.getEnv();
    final List<String> files = env.getFiles();
    if (files.isEmpty()) {
        return readEvalPrint(context, global);
    }

    if (env._compile_only) {
        return compileScripts(context, global, files);
    }

    if (env._fx) {
        return runFXScripts(context, global, files);
    }

    return runScripts(context, global, files);
}
 
Example 9
Source Project: hottub   Source File: Shell.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run method logic.
 *
 * @param in input stream for Shell
 * @param out output stream for Shell
 * @param err error stream for Shell
 * @param args arguments to Shell
 *
 * @return exit code
 *
 * @throws IOException if there's a problem setting up the streams
 */
protected final int run(final InputStream in, final OutputStream out, final OutputStream err, final String[] args) throws IOException {
    final Context context = makeContext(in, out, err, args);
    if (context == null) {
        return COMMANDLINE_ERROR;
    }

    final Global global = context.createGlobal();
    final ScriptEnvironment env = context.getEnv();
    final List<String> files = env.getFiles();
    if (files.isEmpty()) {
        return readEvalPrint(context, global);
    }

    if (env._compile_only) {
        return compileScripts(context, global, files);
    }

    if (env._fx) {
        return runFXScripts(context, global, files);
    }

    return runScripts(context, global, files);
}
 
Example 10
Source Project: openjdk-jdk9   Source File: Shell.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run method logic.
 *
 * @param in input stream for Shell
 * @param out output stream for Shell
 * @param err error stream for Shell
 * @param args arguments to Shell
 *
 * @return exit code
 *
 * @throws IOException if there's a problem setting up the streams
 */
protected final int run(final InputStream in, final OutputStream out, final OutputStream err, final String[] args) throws IOException {
    final Context context = makeContext(in, out, err, args);
    if (context == null) {
        return COMMANDLINE_ERROR;
    }

    final Global global = context.createGlobal();
    final ScriptEnvironment env = context.getEnv();
    final List<String> files = env.getFiles();
    if (files.isEmpty()) {
        return readEvalPrint(context, global);
    }

    if (env._compile_only) {
        return compileScripts(context, global, files);
    }

    if (env._fx) {
        return runFXScripts(context, global, files);
    }

    return runScripts(context, global, files);
}
 
Example 11
private static Parser createParser(final ScriptEnvironment env) {
    final List<String> args = new ArrayList<>();
    if (env._const_as_var) {
        args.add("--const-as-var");
    }

    if (env._no_syntax_extensions) {
        args.add("-nse");
    }

    if (env._scripting) {
        args.add("-scripting");
    }

    if (env._strict) {
        args.add("-strict");
    }

    if (env._es6) {
        args.add("--language=es6");
    }

    return Parser.create(args.toArray(new String[0]));
}
 
Example 12
Source Project: openjdk-8-source   Source File: JSONWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns AST as JSON compatible string.
 *
 * @param env  script environment to use
 * @param code code to be parsed
 * @param name name of the code source (used for location)
 * @param includeLoc tells whether to include location information for nodes or not
 * @return JSON string representation of AST of the supplied code
 */
public static String parse(final ScriptEnvironment env, final String code, final String name, final boolean includeLoc) {
    final Parser       parser     = new Parser(env, new Source(name, code), new Context.ThrowErrorManager(), env._strict);
    final JSONWriter   jsonWriter = new JSONWriter(includeLoc);
    try {
        final FunctionNode functionNode = parser.parse(CompilerConstants.RUN_SCRIPT.symbolName());
        functionNode.accept(jsonWriter);
        return jsonWriter.getString();
    } catch (final ParserException e) {
        e.throwAsEcmaException();
        return null;
    }
}
 
Example 13
Source Project: openjdk-8-source   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void copyInitialMaps(final ScriptEnvironment env) {
    this.accessorPropertyDescriptorMap = AccessorPropertyDescriptor.getInitialMap().duplicate();
    this.dataPropertyDescriptorMap = DataPropertyDescriptor.getInitialMap().duplicate();
    this.genericPropertyDescriptorMap = GenericPropertyDescriptor.getInitialMap().duplicate();
    this.nativeArgumentsMap = NativeArguments.getInitialMap().duplicate();
    this.nativeArrayMap = NativeArray.getInitialMap().duplicate();
    this.nativeBooleanMap = NativeBoolean.getInitialMap().duplicate();
    this.nativeDateMap = NativeDate.getInitialMap().duplicate();
    this.nativeErrorMap = NativeError.getInitialMap().duplicate();
    this.nativeEvalErrorMap = NativeEvalError.getInitialMap().duplicate();
    this.nativeJSAdapterMap = NativeJSAdapter.getInitialMap().duplicate();
    this.nativeNumberMap = NativeNumber.getInitialMap().duplicate();
    this.nativeRangeErrorMap = NativeRangeError.getInitialMap().duplicate();
    this.nativeReferenceErrorMap = NativeReferenceError.getInitialMap().duplicate();
    this.nativeRegExpMap = NativeRegExp.getInitialMap().duplicate();
    this.nativeRegExpExecResultMap = NativeRegExpExecResult.getInitialMap().duplicate();
    this.nativeStrictArgumentsMap = NativeStrictArguments.getInitialMap().duplicate();
    this.nativeStringMap = NativeString.getInitialMap().duplicate();
    this.nativeSyntaxErrorMap = NativeSyntaxError.getInitialMap().duplicate();
    this.nativeTypeErrorMap = NativeTypeError.getInitialMap().duplicate();
    this.nativeURIErrorMap = NativeURIError.getInitialMap().duplicate();
    this.prototypeObjectMap = PrototypeObject.getInitialMap().duplicate();
    this.objectMap = JO.getInitialMap().duplicate();
    this.functionMap = ScriptFunctionImpl.getInitialMap().duplicate();
    this.anonymousFunctionMap = ScriptFunctionImpl.getInitialAnonymousMap().duplicate();
    this.strictFunctionMap = ScriptFunctionImpl.getInitialStrictMap().duplicate();
    this.boundFunctionMap = ScriptFunctionImpl.getInitialBoundMap().duplicate();

    // java
    if (! env._no_java) {
        this.nativeJavaImporterMap = NativeJavaImporter.getInitialMap().duplicate();
    }

    // typed arrays
    if (! env._no_typed_arrays) {
        this.arrayBufferViewMap = ArrayBufferView.getInitialMap().duplicate();
        this.nativeArrayBufferMap = NativeArrayBuffer.getInitialMap().duplicate();
    }
}
 
Example 14
Source Project: openjdk-8-source   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void initScripting(final ScriptEnvironment scriptEnv) {
    Object value;
    value = ScriptFunctionImpl.makeFunction("readLine", ScriptingFunctions.READLINE);
    addOwnProperty("readLine", Attribute.NOT_ENUMERABLE, value);

    value = ScriptFunctionImpl.makeFunction("readFully", ScriptingFunctions.READFULLY);
    addOwnProperty("readFully", Attribute.NOT_ENUMERABLE, value);

    final String execName = ScriptingFunctions.EXEC_NAME;
    value = ScriptFunctionImpl.makeFunction(execName, ScriptingFunctions.EXEC);
    addOwnProperty(execName, Attribute.NOT_ENUMERABLE, value);

    // Nashorn extension: global.echo (scripting-mode-only)
    // alias for "print"
    value = get("print");
    addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value);

    // Nashorn extension: global.$OPTIONS (scripting-mode-only)
    final ScriptObject options = newObject();
    copyOptions(options, scriptEnv);
    addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options);

    // Nashorn extension: global.$ENV (scripting-mode-only)
    if (System.getSecurityManager() == null) {
        // do not fill $ENV if we have a security manager around
        // Retrieve current state of ENV variables.
        final ScriptObject env = newObject();
        env.putAll(System.getenv(), scriptEnv._strict);
        addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env);
    } else {
        addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
    }

    // add other special properties for exec support
    addOwnProperty(ScriptingFunctions.OUT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
    addOwnProperty(ScriptingFunctions.ERR_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
    addOwnProperty(ScriptingFunctions.EXIT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
}
 
Example 15
/**
 * Constructor - only used internally in this class as it breaks
 * abstraction towards ASM or other code generator below
 *
 * @param env script environment
 * @param cw  ASM classwriter
 */
private ClassEmitter(final ScriptEnvironment env, final ClassWriter cw) {
    assert env != null;

    this.env            = env;
    this.cw             = cw;
    this.methodsStarted = new HashSet<>();
}
 
Example 16
Source Project: TencentKona-8   Source File: NativeDate.java    License: GNU General Public License v2.0 5 votes vote down vote up
private NativeDate(final double time, final ScriptObject proto, final PropertyMap map) {
    super(proto, map);
    final ScriptEnvironment env = Global.getEnv();

    this.time = time;
    this.timezone = env._timezone;
}
 
Example 17
/**
 * Constructor from the compiler
 *
 * @param env           Script environment
 * @param sourceName    Source name
 * @param unitClassName Compile unit class name.
 * @param strictMode    Should we generate this method in strict mode
 */
ClassEmitter(final ScriptEnvironment env, final String sourceName, final String unitClassName, final boolean strictMode) {
    this(env,
         new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS) {
            private static final String OBJECT_CLASS  = "java/lang/Object";

            @Override
            protected String getCommonSuperClass(final String type1, final String type2) {
                try {
                    return super.getCommonSuperClass(type1, type2);
                } catch (final RuntimeException e) {
                    if (isScriptObject(Compiler.SCRIPTS_PACKAGE, type1) && isScriptObject(Compiler.SCRIPTS_PACKAGE, type2)) {
                        return className(ScriptObject.class);
                    }
                    return OBJECT_CLASS;
                }
            }
        });

    this.unitClassName        = unitClassName;
    this.constantMethodNeeded = new HashSet<>();

    cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, unitClassName, null, pathName(jdk.nashorn.internal.scripts.JS.class.getName()), null);
    cw.visitSource(sourceName, null);

    defineCommonStatics(strictMode);
}
 
Example 18
Source Project: hottub   Source File: ObjectClassGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Collects the byte codes for a generated JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @return Byte codes for the class.
 */
private byte[] toByteArray(final String className, final ClassEmitter classEmitter) {
    classEmitter.end();

    final byte[] code = classEmitter.toByteArray();
    final ScriptEnvironment env = context.getEnv();

    DumpBytecode.dumpBytecode(env, log, code, className);

    if (env._verify_code) {
        context.verify(code);
    }

    return code;
}
 
Example 19
Source Project: nashorn   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void initScripting(final ScriptEnvironment scriptEnv) {
    Object value;
    value = ScriptFunctionImpl.makeFunction("readLine", ScriptingFunctions.READLINE);
    addOwnProperty("readLine", Attribute.NOT_ENUMERABLE, value);

    value = ScriptFunctionImpl.makeFunction("readFully", ScriptingFunctions.READFULLY);
    addOwnProperty("readFully", Attribute.NOT_ENUMERABLE, value);

    final String execName = ScriptingFunctions.EXEC_NAME;
    value = ScriptFunctionImpl.makeFunction(execName, ScriptingFunctions.EXEC);
    addOwnProperty(execName, Attribute.NOT_ENUMERABLE, value);

    // Nashorn extension: global.echo (scripting-mode-only)
    // alias for "print"
    value = get("print");
    addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value);

    // Nashorn extension: global.$OPTIONS (scripting-mode-only)
    final ScriptObject options = newObject();
    copyOptions(options, scriptEnv);
    addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options);

    // Nashorn extension: global.$ENV (scripting-mode-only)
    if (System.getSecurityManager() == null) {
        // do not fill $ENV if we have a security manager around
        // Retrieve current state of ENV variables.
        final ScriptObject env = newObject();
        env.putAll(System.getenv(), scriptEnv._strict);
        addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env);
    } else {
        addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
    }

    // add other special properties for exec support
    addOwnProperty(ScriptingFunctions.OUT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
    addOwnProperty(ScriptingFunctions.ERR_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
    addOwnProperty(ScriptingFunctions.EXIT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
}
 
Example 20
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) {
    for (final Field f : scriptEnv.getClass().getFields()) {
        try {
            options.set(f.getName(), f.get(scriptEnv), 0);
        } catch (final IllegalArgumentException | IllegalAccessException exp) {
            throw new RuntimeException(exp);
        }
    }
}
 
Example 21
Source Project: hottub   Source File: NativeDate.java    License: GNU General Public License v2.0 5 votes vote down vote up
private NativeDate(final double time, final ScriptObject proto, final PropertyMap map) {
    super(proto, map);
    final ScriptEnvironment env = Global.getEnv();

    this.time = time;
    this.timezone = env._timezone;
}
 
Example 22
Source Project: jdk8u60   Source File: Compiler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param context                  context
 * @param env                      script environment
 * @param installer                code installer
 * @param source                   source to compile
 * @param errors                   error manager
 * @param isStrict                 is this a strict compilation
 * @param isOnDemand               is this an on demand compilation
 * @param compiledFunction         compiled function, if any
 * @param types                    parameter and return value type information, if any is known
 * @param invalidatedProgramPoints invalidated program points for recompilation
 * @param typeInformationFile      descriptor of the location where type information is persisted
 * @param continuationEntryPoints  continuation entry points for restof method
 * @param runtimeScope             runtime scope for recompilation type lookup in {@code TypeEvaluator}
 */
@SuppressWarnings("unused")
public Compiler(
        final Context context,
        final ScriptEnvironment env,
        final CodeInstaller<ScriptEnvironment> installer,
        final Source source,
        final ErrorManager errors,
        final boolean isStrict,
        final boolean isOnDemand,
        final RecompilableScriptFunctionData compiledFunction,
        final TypeMap types,
        final Map<Integer, Type> invalidatedProgramPoints,
        final Object typeInformationFile,
        final int[] continuationEntryPoints,
        final ScriptObject runtimeScope) {
    this.context                  = context;
    this.env                      = env;
    this.installer                = installer;
    this.constantData             = new ConstantData();
    this.compileUnits             = CompileUnit.createCompileUnitSet();
    this.bytecode                 = new LinkedHashMap<>();
    this.log                      = initLogger(context);
    this.source                   = source;
    this.errors                   = errors;
    this.sourceName               = FunctionNode.getSourceName(source);
    this.onDemand                 = isOnDemand;
    this.compiledFunction         = compiledFunction;
    this.types                    = types;
    this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new HashMap<Integer, Type>() : invalidatedProgramPoints;
    this.typeInformationFile      = typeInformationFile;
    this.continuationEntryPoints  = continuationEntryPoints == null ? null: continuationEntryPoints.clone();
    this.typeEvaluator            = new TypeEvaluator(this, runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isStrict;

    this.optimistic = env._optimistic_types;
}
 
Example 23
Source Project: openjdk-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void copyInitialMaps(final ScriptEnvironment env) {
    this.accessorPropertyDescriptorMap = AccessorPropertyDescriptor.getInitialMap().duplicate();
    this.dataPropertyDescriptorMap = DataPropertyDescriptor.getInitialMap().duplicate();
    this.genericPropertyDescriptorMap = GenericPropertyDescriptor.getInitialMap().duplicate();
    this.nativeArgumentsMap = NativeArguments.getInitialMap().duplicate();
    this.nativeArrayMap = NativeArray.getInitialMap().duplicate();
    this.nativeBooleanMap = NativeBoolean.getInitialMap().duplicate();
    this.nativeDateMap = NativeDate.getInitialMap().duplicate();
    this.nativeErrorMap = NativeError.getInitialMap().duplicate();
    this.nativeEvalErrorMap = NativeEvalError.getInitialMap().duplicate();
    this.nativeJSAdapterMap = NativeJSAdapter.getInitialMap().duplicate();
    this.nativeNumberMap = NativeNumber.getInitialMap().duplicate();
    this.nativeRangeErrorMap = NativeRangeError.getInitialMap().duplicate();
    this.nativeReferenceErrorMap = NativeReferenceError.getInitialMap().duplicate();
    this.nativeRegExpMap = NativeRegExp.getInitialMap().duplicate();
    this.nativeRegExpExecResultMap = NativeRegExpExecResult.getInitialMap().duplicate();
    this.nativeStrictArgumentsMap = NativeStrictArguments.getInitialMap().duplicate();
    this.nativeStringMap = NativeString.getInitialMap().duplicate();
    this.nativeSyntaxErrorMap = NativeSyntaxError.getInitialMap().duplicate();
    this.nativeTypeErrorMap = NativeTypeError.getInitialMap().duplicate();
    this.nativeURIErrorMap = NativeURIError.getInitialMap().duplicate();
    this.prototypeObjectMap = PrototypeObject.getInitialMap().duplicate();
    this.objectMap = JO.getInitialMap().duplicate();
    this.functionMap = ScriptFunctionImpl.getInitialMap().duplicate();
    this.anonymousFunctionMap = ScriptFunctionImpl.getInitialAnonymousMap().duplicate();
    this.strictFunctionMap = ScriptFunctionImpl.getInitialStrictMap().duplicate();
    this.boundFunctionMap = ScriptFunctionImpl.getInitialBoundMap().duplicate();

    // java
    if (! env._no_java) {
        this.nativeJavaImporterMap = NativeJavaImporter.getInitialMap().duplicate();
    }

    // typed arrays
    if (! env._no_typed_arrays) {
        this.arrayBufferViewMap = ArrayBufferView.getInitialMap().duplicate();
        this.nativeArrayBufferMap = NativeArrayBuffer.getInitialMap().duplicate();
    }
}
 
Example 24
Source Project: jdk8u_nashorn   Source File: NativeDate.java    License: GNU General Public License v2.0 5 votes vote down vote up
private NativeDate(final double time, final ScriptObject proto, final PropertyMap map) {
    super(proto, map);
    final ScriptEnvironment env = Global.getEnv();

    this.time = time;
    this.timezone = env._timezone;
}
 
Example 25
Source Project: jdk8u60   Source File: ObjectClassGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Collects the byte codes for a generated JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @return Byte codes for the class.
 */
private byte[] toByteArray(final String className, final ClassEmitter classEmitter) {
    classEmitter.end();

    final byte[] code = classEmitter.toByteArray();
    final ScriptEnvironment env = context.getEnv();

    DumpBytecode.dumpBytecode(env, log, code, className);

    if (env._verify_code) {
        context.verify(code);
    }

    return code;
}
 
Example 26
Source Project: nashorn   Source File: NativeDate.java    License: GNU General Public License v2.0 5 votes vote down vote up
private NativeDate(final double time, final ScriptObject proto, final PropertyMap map) {
    super(proto, map);
    final ScriptEnvironment env = Global.getEnv();

    this.time = time;
    this.timezone = env._timezone;
}
 
Example 27
Source Project: nashorn   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) {
    for (Field f : scriptEnv.getClass().getFields()) {
        try {
            options.set(f.getName(), f.get(scriptEnv), false);
        } catch (final IllegalArgumentException | IllegalAccessException exp) {
            throw new RuntimeException(exp);
        }
    }
}
 
Example 28
Source Project: openjdk-8   Source File: NativeDate.java    License: GNU General Public License v2.0 5 votes vote down vote up
private NativeDate(final double time, final ScriptObject proto, final PropertyMap map) {
    super(proto, map);
    final ScriptEnvironment env = Global.getEnv();

    this.time = time;
    this.timezone = env._timezone;
}
 
Example 29
Source Project: openjdk-8-source   Source File: NativeDate.java    License: GNU General Public License v2.0 5 votes vote down vote up
private NativeDate(final double time, final ScriptObject proto, final PropertyMap map) {
    super(proto, map);
    final ScriptEnvironment env = Global.getEnv();

    this.time = time;
    this.timezone = env._timezone;
}
 
Example 30
Source Project: jdk8u_nashorn   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) {
    for (final Field f : scriptEnv.getClass().getFields()) {
        try {
            options.set(f.getName(), f.get(scriptEnv), 0);
        } catch (final IllegalArgumentException | IllegalAccessException exp) {
            throw new RuntimeException(exp);
        }
    }
}