Parses and evaluates the sourceCode
with the interpreter identified by languageId
.
The value of sourceCode
is expected to be a string (or convertible to one).
Returns the evaluation result, depending on the sourceCode
and/or the semantics of the language evaluated.
Exceptions can occur when an invalid languageId
is passed, when the sourceCode
cannot be evaluated by the language,
or when the executed program throws one.
var rArray = Polyglot.eval('R', 'runif(1000)');```
Parses the file sourceFileName
with the interpreter identified by languageId
.
The value of sourceFileName
is expected to be a string (or convertible to one),
representing a file reachable by the current path. Returns an executable object, typically a function.
Exceptions can occur when an invalid languageId
is passed, when the file identified by sourceFileName
cannot be found, or when the language throws an exception during parsing (parse time errors, e.g. syntax errors).
Exceptions thrown by the evaluated program are only thrown once the resulting function is evaluated.
var rArray = Polyglot.evalFile('R', 'myExample.r');
var result = rFunc();```
Exports the JavaScript value
under the name key
(a string) to the polyglot bindings.
If the polyglot bindings already had a value identified by key
, it is overwritten with
the new value. Throws a TypeError
if key is not a string or missing. The value
may be any valid Polyglot value.
function helloWorld() { print("Hello, JavaScript world"); }
Polyglot.export("helloJSWorld", helloWorld);```
Imports the value identified by key
(a string) from the polyglot bindings and returns it.
If no language has exported a value identified by key
, null
is returned.
Throws a TypeError
if key is not a string or missing.
var rubyHelloWorld = Polyglot.import("helloRubyWorld");
rubyHelloWorld();```
Generated using TypeDoc
The functions of the
Polyglot
object allow to interact with values from other polyglot languages.