use of com.oracle.truffle.api.source.Source in project TrufflePascal by Aspect26.
the class PascalLanguage method parse.
/**
* Gets source from the request, parses it and return call target that, if called, executes
* given script in Pascal language.
* @param request parsing request
* @throws Exception the source cannot be passed
*/
@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
Source source = request.getSource();
this.currentParser.reset();
parseSource(source);
return Truffle.getRuntime().createCallTarget(this.currentParser.getRootNode());
}
use of com.oracle.truffle.api.source.Source in project graal by oracle.
the class BreakpointSnippets method example.
@SuppressFBWarnings("")
public void example() {
SuspendedCallback suspendedCallback = new SuspendedCallback() {
public void onSuspend(SuspendedEvent event) {
}
};
Source someCode = Source.newBuilder("").mimeType("").name("").build();
TruffleInstrument.Env instrumentEnvironment = null;
// BEGIN: BreakpointSnippets.example
try (DebuggerSession session = Debugger.find(instrumentEnvironment).startSession(suspendedCallback)) {
// install breakpoint in someCode at line 3.
session.install(Breakpoint.newBuilder(someCode).lineIs(3).build());
// install breakpoint for a URI at line 3
session.install(Breakpoint.newBuilder(someCode.getURI()).lineIs(3).build());
}
// END: BreakpointSnippets.example
// @formatter:on
}
use of com.oracle.truffle.api.source.Source in project graal by oracle.
the class SourceBuilderDocumentationTest method stringSample.
@Test
public void stringSample() throws Exception {
if (!loadedOK) {
return;
}
Source source = (Source) invokeStatic(SOURCE_SNIPPETS, "fromAString");
assertNotNull("Every source must have URI", source.getURI());
}
use of com.oracle.truffle.api.source.Source in project graal by oracle.
the class SourceBuilderTest method markSourceAsInternal.
@Test
public void markSourceAsInternal() {
Source source = Source.newBuilder("anything internal").mimeType("text/plain").name("internalsrc").internal().build();
assertTrue("This source is internal", source.isInternal());
}
use of com.oracle.truffle.api.source.Source in project graal by oracle.
the class SourceBuilderTest method fileWithReload.
@Test
public void fileWithReload() throws Exception {
File file = File.createTempFile("ChangeMe", ".java");
file.deleteOnExit();
String text;
try (FileWriter w = new FileWriter(file)) {
text = "// Hello";
w.write(text);
}
Source original = Source.newBuilder(file).build();
assertEquals(text, original.getCharacters());
String newText;
try (FileWriter w = new FileWriter(file)) {
newText = "// Hello World!";
w.write(newText);
}
Source reloaded = Source.newBuilder(file).build();
assertNotEquals(original, reloaded);
assertEquals("New source has the new text", newText, reloaded.getCharacters());
assertEquals("Old source1 remains unchanged", text, original.getCharacters());
}
Aggregations