@Override public CharSequence getCode(Object impl, int lineNumber) { com.oracle.truffle.api.source.Source source = (com.oracle.truffle.api.source.Source) impl; return source.getCharacters(lineNumber); }
@Override public CharSequence getCode(Object impl) { com.oracle.truffle.api.source.Source source = (com.oracle.truffle.api.source.Source) impl; return source.getCharacters(); }
@Override public CharSequence getCode(Object impl, int lineNumber) { com.oracle.truffle.api.source.Source source = (com.oracle.truffle.api.source.Source) impl; return source.getCharacters(lineNumber); }
@Override public CharSequence getCode(Object impl) { com.oracle.truffle.api.source.Source source = (com.oracle.truffle.api.source.Source) impl; return source.getCharacters(); }
@Override public CharSequence getCharacters() { return base.getCharacters().subSequence(baseIndex, baseIndex + subLength); }
/** * Gets the text (not including a possible terminating newline) in a (1-based) numbered line. * Causes the contents of this source to be loaded if they are loaded lazily. * * @since 0.8 or earlier * @deprecated use {@link #getCharacters(int)} instead. */ @Deprecated public final String getCode(int lineNumber) { return getCharacters(lineNumber).toString(); }
@Override public CharSequence getCharacters() { return key.base.getCharacters().subSequence(key.baseIndex, key.baseIndex + key.subLength); }
/** * Access to the source contents. Causes the contents of this source to be loaded if they are * loaded lazily. * * @since 0.8 or earlier */ public final InputStream getInputStream() { return new ByteArrayInputStream(getCharacters().toString().getBytes()); }
/** * @since 0.8 or earlier * @deprecated without replacement use either {@link #getBytes()} or {@link #getCharacters()} * directly. */ @Deprecated public final InputStream getInputStream() { return new ByteArrayInputStream(getCharacters().toString().getBytes()); }
/** * Returns a subsection of the code test. Causes the contents of this source to be loaded if * they are loaded lazily. * * @since 0.8 or earlier * @deprecated use {@link #getCharacters() getCodeSequence()}. * {@link CharSequence#subSequence(int, int)} subSequence(charIndex, charIndex + * charLength) */ @Deprecated public String getCode(int charIndex, int charLength) { return getCharacters().subSequence(charIndex, charIndex + charLength).toString(); }
/** * Returns whether the source section is in bounds of the {@link #getSource() source} * {@link Source#getCharacters() code}. Please note that calling this method causes the * {@link Source#getCharacters() code} of the {@link #getSource() source} to be loaded if it was * not yet loaded. */ @Override boolean isValid() { return charIndex + charLength <= getSource().getCharacters().length(); }
/** * Access to the source contents. * * @since 0.8 or earlier */ public final Reader getReader() { return new CharSequenceReader(getCharacters()); }
/** * Returns whether the source section is in bounds of the {@link #getSource() source} * {@link Source#getCharacters() code}. Please note that calling this method causes the * {@link Source#getCharacters() code} of the {@link #getSource() source} to be loaded if it was * not yet loaded. */ boolean isValid() { return isAvailable() ? (charIndex + charLength <= getSource().getCharacters().length()) : false; }
TextMap createTextMap() { final CharSequence code = getCharacters(); if (code == null) { throw new RuntimeException("can't read file " + getName()); } return TextMap.fromCharSequence(code); }
TextMap createTextMap() { final CharSequence code = getCharacters(); if (code == null) { throw new RuntimeException("can't read file " + getName()); } return TextMap.fromCharSequence(code); }
@Override protected CallTarget parse(com.oracle.truffle.api.TruffleLanguage.ParsingRequest request) throws Exception { String sourceString = request.getSource().getCharacters().toString(); return Truffle.getRuntime().createCallTarget(new RootNode(this) { @Override public Object execute(VirtualFrame frame) { HostContext context = getContextReference().get(); Class<?> allTarget = context.findClass(sourceString); return context.internalContext.toGuestValue(allTarget); } }); }
@Override public CharSequence getCharacters() { if (!isValid()) { return ""; } return source.getCharacters().subSequence(getCharIndex(), getCharEndIndex()); }
/** * Gets the text (not including a possible terminating newline) in a (1-based) numbered line. * Causes the contents of this source to be loaded if they are loaded lazily. * * @since 0.28 */ public final CharSequence getCharacters(int lineNumber) { final int offset = getTextMap().lineStartOffset(lineNumber); final int length = getTextMap().lineLength(lineNumber); return getCharacters().subSequence(offset, offset + length); }
/** * Gets the text (not including a possible terminating newline) in a (1-based) numbered line. * Causes the contents of this source to be loaded if they are loaded lazily. * * @throws UnsupportedOperationException if this source cannot contain {@link #hasCharacters() * characters}. * @since 0.28 */ public final CharSequence getCharacters(int lineNumber) { final int offset = getTextMap().lineStartOffset(lineNumber); final int length = getTextMap().lineLength(lineNumber); return getCharacters().subSequence(offset, offset + length); }
@Override protected CallTarget parse(com.oracle.truffle.api.TruffleLanguage.ParsingRequest request) throws Exception { Class<?> allTarget = getContextReference().get().findClass(request.getSource().getCharacters().toString()); return Truffle.getRuntime().createCallTarget(new RootNode(this) { @Override public Object execute(VirtualFrame frame) { return JavaInterop.asTruffleObject(allTarget); } }); }