Search in sources :

Example 16 with Function

use of com.github.anba.es6draft.runtime.internal.Properties.Function in project es6draft by anba.

the class ShellFunctions method dumpObject.

/**
     * shell-function: {@code dumpObject(object)}
     * 
     * @param cx
     *            the execution context
     * @param object
     *            the object to inspect
     */
@Function(name = "dumpObject", arity = 1)
public void dumpObject(ExecutionContext cx, ScriptObject object) {
    PrintWriter writer = cx.getRuntimeContext().getConsole().writer();
    writer.println(object.toString());
}
Also used : PrintWriter(java.io.PrintWriter) Function(com.github.anba.es6draft.runtime.internal.Properties.Function)

Example 17 with Function

use of com.github.anba.es6draft.runtime.internal.Properties.Function in project es6draft by anba.

the class ShellFunctions method dumpTemplateMap.

/**
     * shell-function: {@code dumpTemplateMap()}
     * 
     * @param cx
     *            the execution context
     */
@Function(name = "dumpTemplateMap", arity = 0)
public void dumpTemplateMap(ExecutionContext cx) {
    PrintWriter writer = cx.getRuntimeContext().getConsole().writer();
    writer.println(cx.getRealm().getTemplateMap().toString());
}
Also used : PrintWriter(java.io.PrintWriter) Function(com.github.anba.es6draft.runtime.internal.Properties.Function)

Example 18 with Function

use of com.github.anba.es6draft.runtime.internal.Properties.Function in project es6draft by anba.

the class V8ShellFunctions method write.

/**
     * shell-function: {@code write(message)}
     *
     * @param cx
     *            the execution context
     * @param messages
     *            the strings to write
     */
@Function(name = "write", arity = 1)
public void write(ExecutionContext cx, String... messages) {
    PrintWriter writer = cx.getRuntimeContext().getConsole().writer();
    writer.print(Strings.concatWith(' ', messages));
    writer.flush();
}
Also used : PrintWriter(java.io.PrintWriter) Function(com.github.anba.es6draft.runtime.internal.Properties.Function)

Example 19 with Function

use of com.github.anba.es6draft.runtime.internal.Properties.Function in project es6draft by anba.

the class MozShellFunctions method putstr.

/**
     * shell-function: {@code putstr(message)}
     *
     * @param cx
     *            the execution context
     * @param message
     *            the message to write
     */
@Function(name = "putstr", arity = 1)
public void putstr(ExecutionContext cx, String message) {
    PrintWriter writer = cx.getRuntimeContext().getConsole().writer();
    writer.print(message);
    writer.flush();
}
Also used : PrintWriter(java.io.PrintWriter) Function(com.github.anba.es6draft.runtime.internal.Properties.Function) BuiltinFunction(com.github.anba.es6draft.runtime.types.builtins.BuiltinFunction)

Example 20 with Function

use of com.github.anba.es6draft.runtime.internal.Properties.Function in project es6draft by anba.

the class MozShellFunctions method loadRelativeToScript.

/**
     * shell-function: {@code loadRelativeToScript(filename)}
     * 
     * @param cx
     *            the execution context
     * @param caller
     *            the caller execution context
     * @param fileName
     *            the file path
     */
@Function(name = "loadRelativeToScript", arity = 1)
public void loadRelativeToScript(ExecutionContext cx, ExecutionContext caller, String fileName) {
    Path file = Paths.get(fileName);
    loadScript(cx, file, relativePathToScript(cx, caller, file));
}
Also used : SharedFunctions.absolutePath(com.github.anba.es6draft.repl.global.SharedFunctions.absolutePath) Path(java.nio.file.Path) Function(com.github.anba.es6draft.runtime.internal.Properties.Function) BuiltinFunction(com.github.anba.es6draft.runtime.types.builtins.BuiltinFunction)

Aggregations

Function (com.github.anba.es6draft.runtime.internal.Properties.Function)22 PrintWriter (java.io.PrintWriter)12 Source (com.github.anba.es6draft.runtime.internal.Source)6 BuiltinFunction (com.github.anba.es6draft.runtime.types.builtins.BuiltinFunction)6 Script (com.github.anba.es6draft.Script)5 SharedFunctions.absolutePath (com.github.anba.es6draft.repl.global.SharedFunctions.absolutePath)5 Realm (com.github.anba.es6draft.runtime.Realm)5 Path (java.nio.file.Path)5 SharedFunctions.loadScript (com.github.anba.es6draft.repl.global.SharedFunctions.loadScript)4 SharedFunctions.relativePathToScript (com.github.anba.es6draft.repl.global.SharedFunctions.relativePathToScript)4 CompilationException (com.github.anba.es6draft.compiler.CompilationException)3 ParserException (com.github.anba.es6draft.parser.ParserException)3 ToFlatString (com.github.anba.es6draft.runtime.AbstractOperations.ToFlatString)3 ModuleLoader (com.github.anba.es6draft.runtime.modules.ModuleLoader)3 ModuleSource (com.github.anba.es6draft.runtime.modules.ModuleSource)3 StringModuleSource (com.github.anba.es6draft.runtime.modules.loader.StringModuleSource)3 GlobalObject (com.github.anba.es6draft.runtime.objects.GlobalObject)3 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)3 FunctionObject (com.github.anba.es6draft.runtime.types.builtins.FunctionObject)3 IOException (java.io.IOException)3