jdk.nashorn.internal.codegen.Namespace Java Examples

The following examples show how to use jdk.nashorn.internal.codegen.Namespace. 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 check out the related API usage on the sidebar.
Example #1
Source File: Parser.java    From openjdk-8 with 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 #2
Source File: Parser.java    From TencentKona-8 with 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
Source File: FunctionNode.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the source and namespace for this function. It can only set a non-null source and namespace for a function
 * that currently has both a null source and a null namespace. This is used to re-set the source and namespace for
 * a deserialized function node.
 * @param source the source for the function.
 * @param namespace the namespace for the function
 * @return a new function node with the set source and namespace
 * @throws IllegalArgumentException if the specified source or namespace is null
 * @throws IllegalStateException if the function already has either a source or namespace set.
 */
public FunctionNode initializeDeserialized(final Source source, final Namespace namespace) {
    if (source == null || namespace == null) {
        throw new IllegalArgumentException();
    } else if (this.source == source && this.namespace == namespace) {
        return this;
    } else if (this.source != null || this.namespace != null) {
        throw new IllegalStateException();
    }
    return new FunctionNode(
        this,
        lastToken,
        endParserState,
        flags,
        name,
        returnType,
        compileUnit,
        body,
        parameters,
        thisProperties,
        rootClass, source, namespace);
}
 
Example #4
Source File: FunctionNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the source and namespace for this function. It can only set a non-null source and namespace for a function
 * that currently has both a null source and a null namespace. This is used to re-set the source and namespace for
 * a deserialized function node.
 * @param source the source for the function.
 * @param namespace the namespace for the function
 * @return a new function node with the set source and namespace
 * @throws IllegalArgumentException if the specified source or namespace is null
 * @throws IllegalStateException if the function already has either a source or namespace set.
 */
public FunctionNode initializeDeserialized(final Source source, final Namespace namespace) {
    if (source == null || namespace == null) {
        throw new IllegalArgumentException();
    } else if (this.source == source && this.namespace == namespace) {
        return this;
    } else if (this.source != null || this.namespace != null) {
        throw new IllegalStateException();
    }
    return new FunctionNode(
        this,
        lastToken,
        endParserState,
        flags,
        name,
        returnType,
        compileUnit,
        body,
        parameters,
        thisProperties,
        rootClass, source, namespace);
}
 
Example #5
Source File: Parser.java    From hottub with 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 #6
Source File: Parser.java    From openjdk-jdk8u-backup with 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 #7
Source File: FunctionNode.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the source and namespace for this function. It can only set a non-null source and namespace for a function
 * that currently has both a null source and a null namespace. This is used to re-set the source and namespace for
 * a deserialized function node.
 * @param source the source for the function.
 * @param namespace the namespace for the function
 * @return a new function node with the set source and namespace
 * @throws IllegalArgumentException if the specified source or namespace is null
 * @throws IllegalStateException if the function already has either a source or namespace set.
 */
public FunctionNode initializeDeserialized(final Source source, final Namespace namespace) {
    if (source == null || namespace == null) {
        throw new IllegalArgumentException();
    } else if (this.source == source && this.namespace == namespace) {
        return this;
    } else if (this.source != null || this.namespace != null) {
        throw new IllegalStateException();
    }
    return new FunctionNode(
        this,
        lastToken,
        endParserState,
        flags,
        name,
        returnType,
        compileUnit,
        body,
        parameters,
        thisProperties,
        rootClass, source, namespace);
}
 
Example #8
Source File: FunctionNode.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the source and namespace for this function. It can only set a non-null source and namespace for a function
 * that currently has both a null source and a null namespace. This is used to re-set the source and namespace for
 * a deserialized function node.
 * @param source the source for the function.
 * @param namespace the namespace for the function
 * @return a new function node with the set source and namespace
 * @throws IllegalArgumentException if the specified source or namespace is null
 * @throws IllegalStateException if the function already has either a source or namespace set.
 */
public FunctionNode initializeDeserialized(final Source source, final Namespace namespace) {
    if (source == null || namespace == null) {
        throw new IllegalArgumentException();
    } else if (this.source == source && this.namespace == namespace) {
        return this;
    } else if (this.source != null || this.namespace != null) {
        throw new IllegalStateException();
    }
    return new FunctionNode(
        this,
        lastToken,
        endParserState,
        flags,
        name,
        returnType,
        compileUnit,
        body,
        parameters,
        thisProperties,
        rootClass, source, namespace);
}
 
Example #9
Source File: Parser.java    From openjdk-8-source with 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 #10
Source File: Parser.java    From openjdk-jdk8u with 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 #11
Source File: FunctionNode.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the source and namespace for this function. It can only set a non-null source and namespace for a function
 * that currently has both a null source and a null namespace. This is used to re-set the source and namespace for
 * a deserialized function node.
 * @param source the source for the function.
 * @param namespace the namespace for the function
 * @return a new function node with the set source and namespace
 * @throws IllegalArgumentException if the specified source or namespace is null
 * @throws IllegalStateException if the function already has either a source or namespace set.
 */
public FunctionNode initializeDeserialized(final Source source, final Namespace namespace) {
    if (source == null || namespace == null) {
        throw new IllegalArgumentException();
    } else if (this.source == source && this.namespace == namespace) {
        return this;
    } else if (this.source != null || this.namespace != null) {
        throw new IllegalStateException();
    }
    return new FunctionNode(
        this,
        lastToken,
        endParserState,
        flags,
        name,
        returnType,
        compileUnit,
        compilationState,
        body,
        parameters,
        thisProperties,
        rootClass, source, namespace);
}
 
Example #12
Source File: Parser.java    From jdk8u_nashorn with 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 #13
Source File: Parser.java    From jdk8u60 with 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 #14
Source File: FunctionNode.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the source and namespace for this function. It can only set a non-null source and namespace for a function
 * that currently has both a null source and a null namespace. This is used to re-set the source and namespace for
 * a deserialized function node.
 * @param source the source for the function.
 * @param namespace the namespace for the function
 * @return a new function node with the set source and namespace
 * @throws IllegalArgumentException if the specified source or namespace is null
 * @throws IllegalStateException if the function already has either a source or namespace set.
 */
public FunctionNode initializeDeserialized(final Source source, final Namespace namespace) {
    if (source == null || namespace == null) {
        throw new IllegalArgumentException();
    } else if (this.source == source && this.namespace == namespace) {
        return this;
    } else if (this.source != null || this.namespace != null) {
        throw new IllegalStateException();
    }
    return new FunctionNode(
        this,
        lastToken,
        endParserState,
        flags,
        name,
        returnType,
        compileUnit,
        body,
        parameters,
        thisProperties,
        rootClass, source, namespace);
}
 
Example #15
Source File: FunctionNode.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the source and namespace for this function. It can only set a non-null source and namespace for a function
 * that currently has both a null source and a null namespace. This is used to re-set the source and namespace for
 * a deserialized function node.
 * @param source the source for the function.
 * @param namespace the namespace for the function
 * @return a new function node with the set source and namespace
 * @throws IllegalArgumentException if the specified source or namespace is null
 * @throws IllegalStateException if the function already has either a source or namespace set.
 */
public FunctionNode initializeDeserialized(final Source source, final Namespace namespace) {
    if (source == null || namespace == null) {
        throw new IllegalArgumentException();
    } else if (this.source == source && this.namespace == namespace) {
        return this;
    } else if (this.source != null || this.namespace != null) {
        throw new IllegalStateException();
    }
    return new FunctionNode(
        this,
        lastToken,
        endParserState,
        flags,
        name,
        returnType,
        compileUnit,
        body,
        parameters,
        thisProperties,
        rootClass, source, namespace);
}
 
Example #16
Source File: Parser.java    From nashorn with 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 #17
Source File: FunctionNode.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source     the source
 * @param lineNumber line number
 * @param token      token
 * @param finish     finish
 * @param firstToken first token of the funtion node (including the function declaration)
 * @param namespace  the namespace
 * @param ident      the identifier
 * @param name       the name of the function
 * @param parameters parameter list
 * @param kind       kind of function as in {@link FunctionNode.Kind}
 * @param flags      initial flags
 */
public FunctionNode(
    final Source source,
    final int lineNumber,
    final long token,
    final int finish,
    final long firstToken,
    final Namespace namespace,
    final IdentNode ident,
    final String name,
    final List<IdentNode> parameters,
    final FunctionNode.Kind kind,
    final int flags) {
    super(token, finish);

    this.source           = source;
    this.lineNumber       = lineNumber;
    this.ident            = ident;
    this.name             = name;
    this.kind             = kind;
    this.parameters       = parameters;
    this.firstToken       = firstToken;
    this.lastToken        = token;
    this.namespace        = namespace;
    this.compilationState = EnumSet.of(CompilationState.INITIALIZED);
    this.declaredSymbols  = new HashSet<>();
    this.flags            = flags;
    this.compileUnit      = null;
    this.body             = null;
    this.snapshot         = null;
    this.hints            = null;
}
 
Example #18
Source File: FunctionNode.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source     the source
 * @param lineNumber line number
 * @param token      token
 * @param finish     finish
 * @param firstToken first token of the function node (including the function declaration)
 * @param lastToken  lastToken
 * @param namespace  the namespace
 * @param ident      the identifier
 * @param name       the name of the function
 * @param parameters parameter list
 * @param paramExprs the ES6 function parameter expressions
 * @param kind       kind of function as in {@link FunctionNode.Kind}
 * @param flags      initial flags
 * @param body       body of the function
 * @param endParserState The parser state at the end of the parsing.
 * @param module     the module
 * @param debugFlags the debug flags
 */
public FunctionNode(
    final Source source,
    final int lineNumber,
    final long token,
    final int finish,
    final long firstToken,
    final long lastToken,
    final Namespace namespace,
    final IdentNode ident,
    final String name,
    final List<IdentNode> parameters,
    final Map<IdentNode, Expression> paramExprs,
    final FunctionNode.Kind kind,
    final int flags,
    final Block body,
    final Object endParserState,
    final Module module,
    final int debugFlags) {
    super(token, finish);

    this.source           = source;
    this.lineNumber       = lineNumber;
    this.ident            = ident;
    this.name             = name;
    this.kind             = kind;
    this.parameters       = parameters;
    this.parameterExpressions = paramExprs;
    this.firstToken       = firstToken;
    this.lastToken        = lastToken;
    this.namespace        = namespace;
    this.flags            = flags;
    this.compileUnit      = null;
    this.body             = body;
    this.thisProperties   = 0;
    this.rootClass        = null;
    this.endParserState   = endParserState;
    this.module           = module;
    this.debugFlags       = debugFlags;
}
 
Example #19
Source File: FunctionNode.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source     the source
 * @param lineNumber line number
 * @param token      token
 * @param finish     finish
 * @param firstToken first token of the funtion node (including the function declaration)
 * @param namespace  the namespace
 * @param ident      the identifier
 * @param name       the name of the function
 * @param parameters parameter list
 * @param kind       kind of function as in {@link FunctionNode.Kind}
 * @param flags      initial flags
 */
public FunctionNode(
    final Source source,
    final int lineNumber,
    final long token,
    final int finish,
    final long firstToken,
    final Namespace namespace,
    final IdentNode ident,
    final String name,
    final List<IdentNode> parameters,
    final FunctionNode.Kind kind,
    final int flags) {
    super(token, finish);

    this.source           = source;
    this.lineNumber       = lineNumber;
    this.ident            = ident;
    this.name             = name;
    this.kind             = kind;
    this.parameters       = parameters;
    this.firstToken       = firstToken;
    this.lastToken        = token;
    this.namespace        = namespace;
    this.compilationState = EnumSet.of(CompilationState.INITIALIZED);
    this.declaredSymbols  = new HashSet<>();
    this.flags            = flags;
    this.compileUnit      = null;
    this.body             = null;
    this.snapshot         = null;
    this.hints            = null;
}
 
Example #20
Source File: RecompilableScriptFunctionData.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode deserialize(final byte[] serializedAst) {
    final ScriptEnvironment env = installer.getContext().getEnv();
    final Timing timing = env._timing;
    final long t1 = System.nanoTime();
    try {
        return AstDeserializer.deserialize(serializedAst).initializeDeserialized(source, new Namespace(env.getNamespace()));
    } finally {
        timing.accumulateTime("'Deserialize'", System.nanoTime() - t1);
    }
}
 
Example #21
Source File: FunctionNode.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source     the source
 * @param lineNumber line number
 * @param token      token
 * @param finish     finish
 * @param firstToken first token of the function node (including the function declaration)
 * @param namespace  the namespace
 * @param ident      the identifier
 * @param name       the name of the function
 * @param parameters parameter list
 * @param kind       kind of function as in {@link FunctionNode.Kind}
 * @param flags      initial flags
 */
public FunctionNode(
    final Source source,
    final int lineNumber,
    final long token,
    final int finish,
    final long firstToken,
    final Namespace namespace,
    final IdentNode ident,
    final String name,
    final List<IdentNode> parameters,
    final FunctionNode.Kind kind,
    final int flags) {
    super(token, finish);

    this.source           = source;
    this.lineNumber       = lineNumber;
    this.ident            = ident;
    this.name             = name;
    this.kind             = kind;
    this.parameters       = parameters;
    this.firstToken       = firstToken;
    this.lastToken        = token;
    this.namespace        = namespace;
    this.flags            = flags;
    this.compileUnit      = null;
    this.body             = null;
    this.thisProperties   = 0;
    this.rootClass        = null;
    this.endParserState    = null;
}
 
Example #22
Source File: FunctionNode.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final Object endParserState,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final Block body,
    final List<IdentNode> parameters,
    final int thisProperties,
    final Class<?> rootClass,
    final Source source, final Namespace namespace) {
    super(functionNode);

    this.endParserState    = endParserState;
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.body             = body;
    this.parameters       = parameters;
    this.thisProperties   = thisProperties;
    this.rootClass        = rootClass;
    this.source           = source;
    this.namespace        = namespace;

    // the fields below never change - they are final and assigned in constructor
    this.ident           = functionNode.ident;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
}
 
Example #23
Source File: FunctionNode.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source     the source
 * @param lineNumber line number
 * @param token      token
 * @param finish     finish
 * @param firstToken first token of the function node (including the function declaration)
 * @param namespace  the namespace
 * @param ident      the identifier
 * @param name       the name of the function
 * @param parameters parameter list
 * @param kind       kind of function as in {@link FunctionNode.Kind}
 * @param flags      initial flags
 */
public FunctionNode(
    final Source source,
    final int lineNumber,
    final long token,
    final int finish,
    final long firstToken,
    final Namespace namespace,
    final IdentNode ident,
    final String name,
    final List<IdentNode> parameters,
    final FunctionNode.Kind kind,
    final int flags) {
    super(token, finish);

    this.source           = source;
    this.lineNumber       = lineNumber;
    this.ident            = ident;
    this.name             = name;
    this.kind             = kind;
    this.parameters       = parameters;
    this.firstToken       = firstToken;
    this.lastToken        = token;
    this.namespace        = namespace;
    this.flags            = flags;
    this.compileUnit      = null;
    this.body             = null;
    this.thisProperties   = 0;
    this.rootClass        = null;
    this.endParserState    = null;
}
 
Example #24
Source File: RecompilableScriptFunctionData.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode deserialize(final byte[] serializedAst) {
    final ScriptEnvironment env = installer.getContext().getEnv();
    final Timing timing = env._timing;
    final long t1 = System.nanoTime();
    try {
        return AstDeserializer.deserialize(serializedAst).initializeDeserialized(source, new Namespace(env.getNamespace()));
    } finally {
        timing.accumulateTime("'Deserialize'", System.nanoTime() - t1);
    }
}
 
Example #25
Source File: FunctionNode.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final Object endParserState,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final Block body,
    final List<IdentNode> parameters,
    final int thisProperties,
    final Class<?> rootClass,
    final Source source, final Namespace namespace) {
    super(functionNode);

    this.endParserState    = endParserState;
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.body             = body;
    this.parameters       = parameters;
    this.thisProperties   = thisProperties;
    this.rootClass        = rootClass;
    this.source           = source;
    this.namespace        = namespace;

    // the fields below never change - they are final and assigned in constructor
    this.ident           = functionNode.ident;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
}
 
Example #26
Source File: FunctionNode.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final Object endParserState,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final Block body,
    final List<IdentNode> parameters,
    final int thisProperties,
    final Class<?> rootClass,
    final Source source, final Namespace namespace) {
    super(functionNode);

    this.endParserState    = endParserState;
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.body             = body;
    this.parameters       = parameters;
    this.parameterExpressions = functionNode.parameterExpressions;
    this.thisProperties   = thisProperties;
    this.rootClass        = rootClass;
    this.source           = source;
    this.namespace        = namespace;

    // the fields below never change - they are final and assigned in constructor
    this.ident           = functionNode.ident;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
    this.module          = functionNode.module;
    this.debugFlags      = functionNode.debugFlags;
}
 
Example #27
Source File: FunctionNode.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source     the source
 * @param lineNumber line number
 * @param token      token
 * @param finish     finish
 * @param firstToken first token of the funtion node (including the function declaration)
 * @param namespace  the namespace
 * @param ident      the identifier
 * @param name       the name of the function
 * @param parameters parameter list
 * @param kind       kind of function as in {@link FunctionNode.Kind}
 * @param flags      initial flags
 */
public FunctionNode(
    final Source source,
    final int lineNumber,
    final long token,
    final int finish,
    final long firstToken,
    final Namespace namespace,
    final IdentNode ident,
    final String name,
    final List<IdentNode> parameters,
    final FunctionNode.Kind kind,
    final int flags) {
    super(token, finish);

    this.source           = source;
    this.lineNumber       = lineNumber;
    this.ident            = ident;
    this.name             = name;
    this.kind             = kind;
    this.parameters       = parameters;
    this.firstToken       = firstToken;
    this.lastToken        = token;
    this.namespace        = namespace;
    this.compilationState = EnumSet.of(CompilationState.INITIALIZED);
    this.declaredSymbols  = new HashSet<>();
    this.flags            = flags;
    this.compileUnit      = null;
    this.body             = null;
    this.snapshot         = null;
    this.hints            = null;
}
 
Example #28
Source File: RecompilableScriptFunctionData.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode deserialize(final byte[] serializedAst) {
    final ScriptEnvironment env = installer.getContext().getEnv();
    final Timing timing = env._timing;
    final long t1 = System.nanoTime();
    try {
        return AstDeserializer.deserialize(serializedAst).initializeDeserialized(source, new Namespace(env.getNamespace()));
    } finally {
        timing.accumulateTime("'Deserialize'", System.nanoTime() - t1);
    }
}
 
Example #29
Source File: RecompilableScriptFunctionData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode deserialize(final byte[] serializedAst) {
    final ScriptEnvironment env = installer.getContext().getEnv();
    final Timing timing = env._timing;
    final long t1 = System.nanoTime();
    try {
        return AstDeserializer.deserialize(serializedAst).initializeDeserialized(source, new Namespace(env.getNamespace()));
    } finally {
        timing.accumulateTime("'Deserialize'", System.nanoTime() - t1);
    }
}
 
Example #30
Source File: FunctionNode.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source     the source
 * @param lineNumber line number
 * @param token      token
 * @param finish     finish
 * @param firstToken first token of the function node (including the function declaration)
 * @param namespace  the namespace
 * @param ident      the identifier
 * @param name       the name of the function
 * @param parameters parameter list
 * @param kind       kind of function as in {@link FunctionNode.Kind}
 * @param flags      initial flags
 */
public FunctionNode(
    final Source source,
    final int lineNumber,
    final long token,
    final int finish,
    final long firstToken,
    final Namespace namespace,
    final IdentNode ident,
    final String name,
    final List<IdentNode> parameters,
    final FunctionNode.Kind kind,
    final int flags) {
    super(token, finish);

    this.source           = source;
    this.lineNumber       = lineNumber;
    this.ident            = ident;
    this.name             = name;
    this.kind             = kind;
    this.parameters       = parameters;
    this.firstToken       = firstToken;
    this.lastToken        = token;
    this.namespace        = namespace;
    this.flags            = flags;
    this.compileUnit      = null;
    this.body             = null;
    this.thisProperties   = 0;
    this.rootClass        = null;
    this.endParserState    = null;
}