Java Code Examples for jdk.nashorn.internal.runtime.Source#getContent()

The following examples show how to use jdk.nashorn.internal.runtime.Source#getContent() . 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: SourceTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testSources(final Source source1, final Source source2) {
    final char[] chars1 = source1.getContent();
    final char[] chars2 = source2.getContent();
    final String str1 = source1.getString();
    final String str2 = source2.getString();
    assertTrue(Arrays.equals(chars1, chars2));
    assertEquals(str1, str2);
    assertEquals(source1.hashCode(), source2.hashCode());
    assertTrue(source1.equals(source2));
    assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
    assertTrue(Arrays.equals(source1.getContent(), chars1));
    assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
}
 
Example 2
Source File: Lexer.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param stream    the token stream to lex
 * @param scripting are we in scripting mode
 */
public Lexer(final Source source, final TokenStream stream, final boolean scripting) {
    super(source.getContent(), 1, 0, source.getLength());

    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;
}
 
Example 3
Source File: SourceTest.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static void testSources(final Source source1, final Source source2) {
    final char[] chars1 = source1.getContent();
    final char[] chars2 = source2.getContent();
    final String str1 = source1.getString();
    final String str2 = source2.getString();
    assertTrue(Arrays.equals(chars1, chars2));
    assertEquals(str1, str2);
    assertEquals(source1.hashCode(), source2.hashCode());
    assertTrue(source1.equals(source2));
    assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
    assertTrue(Arrays.equals(source1.getContent(), chars1));
    assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
}
 
Example 4
Source File: Lexer.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param start     start position in source from which to start lexing
 * @param len       length of source segment to lex
 * @param stream    token stream to lex
 * @param scripting are we in scripting mode
 * @param pauseOnFunctionBody if true, lexer will return from {@link #lexify()} when it encounters a
 * function body. This is used with the feature where the parser is skipping nested function bodies to
 * avoid reading ahead unnecessarily when we skip the function bodies.
 */

public Lexer(final Source source, final int start, final int len, final TokenStream stream, final boolean scripting, final boolean pauseOnFunctionBody) {
    super(source.getContent(), 1, start, len);
    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;

    this.pauseOnFunctionBody = pauseOnFunctionBody;
}
 
Example 5
Source File: Lexer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param stream    the token stream to lex
 * @param scripting are we in scripting mode
 */
public Lexer(final Source source, final TokenStream stream, final boolean scripting) {
    super(source.getContent(), 1, 0, source.getLength());

    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;
}
 
Example 6
Source File: Lexer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param stream    the token stream to lex
 * @param scripting are we in scripting mode
 */
public Lexer(final Source source, final TokenStream stream, final boolean scripting) {
    super(source.getContent(), 1, 0, source.getLength());

    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;
}
 
Example 7
Source File: SourceTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void testSources(final Source source1, final Source source2) {
    final char[] chars1 = source1.getContent();
    final char[] chars2 = source2.getContent();
    final String str1 = source1.getString();
    final String str2 = source2.getString();
    assertTrue(Arrays.equals(chars1, chars2));
    assertEquals(str1, str2);
    assertEquals(source1.hashCode(), source2.hashCode());
    assertTrue(source1.equals(source2));
    assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
    assertTrue(Arrays.equals(source1.getContent(), chars1));
    assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
}
 
Example 8
Source File: Lexer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param start     start position in source from which to start lexing
 * @param len       length of source segment to lex
 * @param stream    token stream to lex
 * @param scripting are we in scripting mode
 * @param pauseOnFunctionBody if true, lexer will return from {@link #lexify()} when it encounters a
 * function body. This is used with the feature where the parser is skipping nested function bodies to
 * avoid reading ahead unnecessarily when we skip the function bodies.
 */

public Lexer(final Source source, final int start, final int len, final TokenStream stream, final boolean scripting, final boolean pauseOnFunctionBody) {
    super(source.getContent(), 1, start, len);
    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;

    this.pauseOnFunctionBody = pauseOnFunctionBody;
}
 
Example 9
Source File: SourceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void testSources(final Source source1, final Source source2) {
    final char[] chars1 = source1.getContent();
    final char[] chars2 = source2.getContent();
    final String str1 = source1.getString();
    final String str2 = source2.getString();
    assertTrue(Arrays.equals(chars1, chars2));
    assertEquals(str1, str2);
    assertEquals(source1.hashCode(), source2.hashCode());
    assertTrue(source1.equals(source2));
    assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
    assertTrue(Arrays.equals(source1.getContent(), chars1));
    assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
}
 
Example 10
Source File: SourceTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void testSources(final Source source1, final Source source2) {
    final char[] chars1 = source1.getContent();
    final char[] chars2 = source2.getContent();
    final String str1 = source1.getString();
    final String str2 = source2.getString();
    assertTrue(Arrays.equals(chars1, chars2));
    assertEquals(str1, str2);
    assertEquals(source1.hashCode(), source2.hashCode());
    assertTrue(source1.equals(source2));
    assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
    assertTrue(Arrays.equals(source1.getContent(), chars1));
    assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
}
 
Example 11
Source File: Lexer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param start     start position in source from which to start lexing
 * @param len       length of source segment to lex
 * @param stream    token stream to lex
 * @param scripting are we in scripting mode
 * @param pauseOnFunctionBody if true, lexer will return from {@link #lexify()} when it encounters a
 * function body. This is used with the feature where the parser is skipping nested function bodies to
 * avoid reading ahead unnecessarily when we skip the function bodies.
 */

public Lexer(final Source source, final int start, final int len, final TokenStream stream, final boolean scripting, final boolean pauseOnFunctionBody) {
    super(source.getContent(), 1, start, len);
    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;

    this.pauseOnFunctionBody = pauseOnFunctionBody;
}
 
Example 12
Source File: SourceTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testSources(final Source source1, final Source source2) {
    final char[] chars1 = source1.getContent();
    final char[] chars2 = source2.getContent();
    final String str1 = source1.getString();
    final String str2 = source2.getString();
    assertTrue(Arrays.equals(chars1, chars2));
    assertEquals(str1, str2);
    assertEquals(source1.hashCode(), source2.hashCode());
    assertTrue(source1.equals(source2));
    assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
    assertTrue(Arrays.equals(source1.getContent(), chars1));
    assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
}
 
Example 13
Source File: Lexer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param start     start position in source from which to start lexing
 * @param len       length of source segment to lex
 * @param stream    token stream to lex
 * @param scripting are we in scripting mode
 * @param pauseOnFunctionBody if true, lexer will return from {@link #lexify()} when it encounters a
 * function body. This is used with the feature where the parser is skipping nested function bodies to
 * avoid reading ahead unnecessarily when we skip the function bodies.
 */

public Lexer(final Source source, final int start, final int len, final TokenStream stream, final boolean scripting, final boolean pauseOnFunctionBody) {
    super(source.getContent(), 1, start, len);
    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;

    this.pauseOnFunctionBody = pauseOnFunctionBody;
}
 
Example 14
Source File: SourceTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void testSources(final Source source1, final Source source2) {
    final char[] chars1 = source1.getContent();
    final char[] chars2 = source2.getContent();
    final String str1 = source1.getString();
    final String str2 = source2.getString();
    assertTrue(Arrays.equals(chars1, chars2));
    assertEquals(str1, str2);
    assertEquals(source1.hashCode(), source2.hashCode());
    assertTrue(source1.equals(source2));
    assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
    assertTrue(Arrays.equals(source1.getContent(), chars1));
    assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
}
 
Example 15
Source File: Lexer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param start     start position in source from which to start lexing
 * @param len       length of source segment to lex
 * @param stream    token stream to lex
 * @param scripting are we in scripting mode
 * @param pauseOnFunctionBody if true, lexer will return from {@link #lexify()} when it encounters a
 * function body. This is used with the feature where the parser is skipping nested function bodies to
 * avoid reading ahead unnecessarily when we skip the function bodies.
 */

public Lexer(final Source source, final int start, final int len, final TokenStream stream, final boolean scripting, final boolean pauseOnFunctionBody) {
    super(source.getContent(), 1, start, len);
    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;

    this.pauseOnFunctionBody = pauseOnFunctionBody;
}
 
Example 16
Source File: Lexer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param start     start position in source from which to start lexing
 * @param len       length of source segment to lex
 * @param stream    token stream to lex
 * @param scripting are we in scripting mode
 * @param pauseOnFunctionBody if true, lexer will return from {@link #lexify()} when it encounters a
 * function body. This is used with the feature where the parser is skipping nested function bodies to
 * avoid reading ahead unnecessarily when we skip the function bodies.
 */

public Lexer(final Source source, final int start, final int len, final TokenStream stream, final boolean scripting, final boolean pauseOnFunctionBody) {
    super(source.getContent(), 1, start, len);
    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;

    this.pauseOnFunctionBody = pauseOnFunctionBody;
}
 
Example 17
Source File: Lexer.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructor
 *
 * @param source    the source
 * @param start     start position in source from which to start lexing
 * @param len       length of source segment to lex
 * @param stream    token stream to lex
 * @param scripting are we in scripting mode
 * @param es6       are we in ECMAScript 6 mode
 * @param pauseOnFunctionBody if true, lexer will return from {@link #lexify()} when it encounters a
 * function body. This is used with the feature where the parser is skipping nested function bodies to
 * avoid reading ahead unnecessarily when we skip the function bodies.
 */
public Lexer(final Source source, final int start, final int len, final TokenStream stream, final boolean scripting, final boolean es6, final boolean pauseOnFunctionBody) {
    super(source.getContent(), 1, start, len);
    this.source      = source;
    this.stream      = stream;
    this.scripting   = scripting;
    this.es6         = es6;
    this.nested      = false;
    this.pendingLine = 1;
    this.last        = EOL;

    this.pauseOnFunctionBody = pauseOnFunctionBody;
}