fix: remove major mistakes in README
This commit is contained in:
parent
82a09e8865
commit
562f1f9425
44
README.md
44
README.md
@ -2,44 +2,28 @@
|
|||||||
|
|
||||||
**NOTE: This had nothing to do with Microsoft's dialect of EcmaScript**
|
**NOTE: This had nothing to do with Microsoft's dialect of EcmaScript**
|
||||||
|
|
||||||
**WARNING: Currently, this code is mostly undocumented. Proceed with caution and a psychiatrist.**
|
**WARNING: Currently, this code is undocumented. Proceed with caution and a psychiatrist.**
|
||||||
|
|
||||||
JScript is an engine, capable of running EcmaScript 5, written entirely in Java. This engine has been developed with the goal of being easy to integrate with your preexisting codebase, **THE GOAL OF THIS ENGINE IS NOT PERFORMANCE**. My crude experiments show that this engine is 50x-100x slower than V8, which, although bad, is acceptable for most simple scripting purposes. Note that although the codebase has a Main class, this isn't meant to be a standalone program, but instead a library for running JavaScript code.
|
JScript is an engine, capable of running EcmaScript 5, written entirely in Java. This engine has been developed with the goal of being easy to integrate with your preexisting codebase, **THE GOAL OF THIS ENGINE IS NOT PERFORMANCE**. My crude experiments show that this engine is 50x-100x slower than V8, which, although bad, is acceptable for most simple scripting purposes. Note that although the codebase has a Main class, this isn't meant to be a standalone program, but instead a library for running JavaScript code.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
The following will create a REPL using the engine as a backend. Not that this won't properly log errors. I recommend checking out the implementation in `Main.main`:
|
The following is going to execute a simple javascript statement:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
var engine = new Engine(true /* false if you dont want debugging */);
|
var engine = new Engine(false);
|
||||||
var env = new Environment(null, null, null);
|
// Initialize a standard environment, with implementations of most basic standard libraries (Object, Array, Symbol, etc.)
|
||||||
var debugger = new DebugServer();
|
var env = Internals.apply(new Environment());
|
||||||
|
|
||||||
// Create one target for the engine and start debugging server
|
|
||||||
debugger.targets.put("target", (socket, req) -> new SimpleDebugger(socket, engine));
|
|
||||||
debugger.start(new InetSocketAddress("127.0.0.1", 9229), true);
|
|
||||||
|
|
||||||
// Queue code to load internal libraries and start engine
|
// Queue code to load internal libraries and start engine
|
||||||
engine.pushMsg(false, null, new Internals().getApplier(env));
|
var awaitable = engine.pushMsg(false, env, new Filename("tmp", "eval"), "10 + Math.sqrt(5 / 3)", null);
|
||||||
engine.start();
|
// Run the engine on the same thread, until the event loop runs empty
|
||||||
|
engine.run(true);
|
||||||
|
|
||||||
while (true) {
|
// Get our result
|
||||||
try {
|
System.out.println(awaitable.await());
|
||||||
var raw = Reading.read();
|
|
||||||
if (raw == null) break;
|
|
||||||
|
|
||||||
// Push a message to the engine with the raw REPL code
|
|
||||||
var res = engine.pushMsg(
|
|
||||||
false, new Context(engine).pushEnv(env),
|
|
||||||
new Filename("jscript", "repl.js"), raw, null
|
|
||||||
).await();
|
|
||||||
|
|
||||||
Values.printValue(null, res);
|
|
||||||
}
|
|
||||||
catch (EngineException e) { Values.printError(e, ""); }
|
|
||||||
catch (SyntaxException ex) {
|
|
||||||
System.out.println("Syntax error:" + ex.msg);
|
|
||||||
}
|
|
||||||
catch (IOException e) { }
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## NOTE:
|
||||||
|
|
||||||
|
To setup the typescript bundle in your sources, run `node build.js init-ts`. This will download the latest version of typescript, minify it, and add it to your src/assets folder. If you are going to work with the `node build.js debug|release` command, this is not a necessary step.
|
||||||
|
Loading…
Reference in New Issue
Block a user