diff --git a/.gitignore b/.gitignore index 0520ab8..b930c26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .vscode .gradle +.ignore out build bin diff --git a/files.txt b/files.txt deleted file mode 100644 index 68c8009..0000000 --- a/files.txt +++ /dev/null @@ -1,144 +0,0 @@ -src/me/topchetoeu/jscript/compilation/AssignableStatement.java -src/me/topchetoeu/jscript/compilation/CompileOptions.java -src/me/topchetoeu/jscript/compilation/CompoundStatement.java -src/me/topchetoeu/jscript/compilation/control/BreakStatement.java -src/me/topchetoeu/jscript/compilation/control/ContinueStatement.java -src/me/topchetoeu/jscript/compilation/control/DebugStatement.java -src/me/topchetoeu/jscript/compilation/control/DeleteStatement.java -src/me/topchetoeu/jscript/compilation/control/DoWhileStatement.java -src/me/topchetoeu/jscript/compilation/control/ForInStatement.java -src/me/topchetoeu/jscript/compilation/control/ForStatement.java -src/me/topchetoeu/jscript/compilation/control/IfStatement.java -src/me/topchetoeu/jscript/compilation/control/ReturnStatement.java -src/me/topchetoeu/jscript/compilation/control/SwitchStatement.java -src/me/topchetoeu/jscript/compilation/control/ThrowStatement.java -src/me/topchetoeu/jscript/compilation/control/TryStatement.java -src/me/topchetoeu/jscript/compilation/control/WhileStatement.java -src/me/topchetoeu/jscript/compilation/DiscardStatement.java -src/me/topchetoeu/jscript/compilation/Instruction.java -src/me/topchetoeu/jscript/compilation/Statement.java -src/me/topchetoeu/jscript/compilation/values/LazyOrStatement.java -src/me/topchetoeu/jscript/compilation/values/ArrayStatement.java -src/me/topchetoeu/jscript/compilation/values/CallStatement.java -src/me/topchetoeu/jscript/compilation/values/ChangeStatement.java -src/me/topchetoeu/jscript/compilation/values/CommaStatement.java -src/me/topchetoeu/jscript/compilation/values/ConstantStatement.java -src/me/topchetoeu/jscript/compilation/values/FunctionStatement.java -src/me/topchetoeu/jscript/compilation/values/GlobalThisStatement.java -src/me/topchetoeu/jscript/compilation/values/IndexAssignStatement.java -src/me/topchetoeu/jscript/compilation/values/IndexStatement.java -src/me/topchetoeu/jscript/compilation/values/LazyAndStatement.java -src/me/topchetoeu/jscript/compilation/values/NewStatement.java -src/me/topchetoeu/jscript/compilation/values/ObjectStatement.java -src/me/topchetoeu/jscript/compilation/values/OperationStatement.java -src/me/topchetoeu/jscript/compilation/values/RegexStatement.java -src/me/topchetoeu/jscript/compilation/values/TernaryStatement.java -src/me/topchetoeu/jscript/compilation/values/TypeofStatement.java -src/me/topchetoeu/jscript/compilation/values/VariableAssignStatement.java -src/me/topchetoeu/jscript/compilation/values/VariableIndexStatement.java -src/me/topchetoeu/jscript/compilation/values/VariableStatement.java -src/me/topchetoeu/jscript/compilation/values/VoidStatement.java -src/me/topchetoeu/jscript/compilation/VariableDeclareStatement.java -src/me/topchetoeu/jscript/engine/frame/CodeFrame.java -src/me/topchetoeu/jscript/engine/frame/ConvertHint.java -src/me/topchetoeu/jscript/engine/frame/InstructionResult.java -src/me/topchetoeu/jscript/engine/frame/Runners.java -src/me/topchetoeu/jscript/engine/BreakpointData.java -src/me/topchetoeu/jscript/engine/CallContext.java -src/me/topchetoeu/jscript/engine/debug/DebugServer.java -src/me/topchetoeu/jscript/engine/debug/DebugState.java -src/me/topchetoeu/jscript/engine/debug/handlers/DebuggerHandles.java -src/me/topchetoeu/jscript/engine/debug/Http.java -src/me/topchetoeu/jscript/engine/debug/HttpRequest.java -src/me/topchetoeu/jscript/engine/debug/V8Error.java -src/me/topchetoeu/jscript/engine/debug/V8Event.java -src/me/topchetoeu/jscript/engine/debug/V8Message.java -src/me/topchetoeu/jscript/engine/debug/V8Result.java -src/me/topchetoeu/jscript/engine/debug/WebSocket.java -src/me/topchetoeu/jscript/engine/debug/WebSocketMessage.java -src/me/topchetoeu/jscript/engine/DebugCommand.java -src/me/topchetoeu/jscript/engine/Engine.java -src/me/topchetoeu/jscript/engine/modules/FileModuleProvider.java -src/me/topchetoeu/jscript/engine/modules/Module.java -src/me/topchetoeu/jscript/engine/modules/ModuleManager.java -src/me/topchetoeu/jscript/engine/modules/ModuleProvider.java -src/me/topchetoeu/jscript/engine/scope/GlobalScope.java -src/me/topchetoeu/jscript/engine/scope/LocalScope.java -src/me/topchetoeu/jscript/engine/scope/LocalScopeRecord.java -src/me/topchetoeu/jscript/engine/scope/ScopeRecord.java -src/me/topchetoeu/jscript/engine/scope/ValueVariable.java -src/me/topchetoeu/jscript/engine/scope/Variable.java -src/me/topchetoeu/jscript/engine/values/ArrayValue.java -src/me/topchetoeu/jscript/engine/values/CodeFunction.java -src/me/topchetoeu/jscript/engine/values/FunctionValue.java -src/me/topchetoeu/jscript/engine/values/NativeFunction.java -src/me/topchetoeu/jscript/engine/values/NativeWrapper.java -src/me/topchetoeu/jscript/engine/values/ObjectValue.java -src/me/topchetoeu/jscript/engine/values/SignalValue.java -src/me/topchetoeu/jscript/engine/values/Symbol.java -src/me/topchetoeu/jscript/engine/values/Values.java -src/me/topchetoeu/jscript/events/Awaitable.java -src/me/topchetoeu/jscript/events/DataNotifier.java -src/me/topchetoeu/jscript/events/Event.java -src/me/topchetoeu/jscript/events/FinishedException.java -src/me/topchetoeu/jscript/events/Handle.java -src/me/topchetoeu/jscript/events/Notifier.java -src/me/topchetoeu/jscript/events/Observable.java -src/me/topchetoeu/jscript/events/Observer.java -src/me/topchetoeu/jscript/events/Pipe.java -src/me/topchetoeu/jscript/events/WarmObservable.java -src/me/topchetoeu/jscript/exceptions/EngineException.java -src/me/topchetoeu/jscript/exceptions/SyntaxException.java -src/me/topchetoeu/jscript/filesystem/File.java -src/me/topchetoeu/jscript/filesystem/Filesystem.java -src/me/topchetoeu/jscript/filesystem/InaccessibleFile.java -src/me/topchetoeu/jscript/filesystem/MemoryFile.java -src/me/topchetoeu/jscript/filesystem/Permissions.java -src/me/topchetoeu/jscript/filesystem/PermissionsProvider.java -src/me/topchetoeu/jscript/filesystem/PhysicalFile.java -src/me/topchetoeu/jscript/filesystem/PhysicalFilesystem.java -src/me/topchetoeu/jscript/interop/Native.java -src/me/topchetoeu/jscript/interop/NativeGetter.java -src/me/topchetoeu/jscript/interop/NativeSetter.java -src/me/topchetoeu/jscript/interop/NativeTypeRegister.java -src/me/topchetoeu/jscript/interop/Overload.java -src/me/topchetoeu/jscript/interop/OverloadFunction.java -src/me/topchetoeu/jscript/json/JSON.java -src/me/topchetoeu/jscript/json/JSONElement.java -src/me/topchetoeu/jscript/json/JSONList.java -src/me/topchetoeu/jscript/json/JSONMap.java -src/me/topchetoeu/jscript/Location.java -src/me/topchetoeu/jscript/Main.java -src/me/topchetoeu/jscript/MessageReceiver.java -src/me/topchetoeu/jscript/parsing/Operator.java -src/me/topchetoeu/jscript/parsing/ParseRes.java -src/me/topchetoeu/jscript/parsing/Parsing.java -src/me/topchetoeu/jscript/parsing/RawToken.java -src/me/topchetoeu/jscript/parsing/TestRes.java -src/me/topchetoeu/jscript/parsing/Token.java -src/me/topchetoeu/jscript/parsing/TokenType.java -src/me/topchetoeu/jscript/polyfills/Date.java -src/me/topchetoeu/jscript/polyfills/Internals.java -src/me/topchetoeu/jscript/polyfills/JSON.java -src/me/topchetoeu/jscript/polyfills/Map.java -src/me/topchetoeu/jscript/polyfills/Math.java -src/me/topchetoeu/jscript/polyfills/PolyfillEngine.java -src/me/topchetoeu/jscript/polyfills/Promise.java -src/me/topchetoeu/jscript/polyfills/RegExp.java -src/me/topchetoeu/jscript/polyfills/Set.java -src/me/topchetoeu/jscript/polyfills/TypescriptEngine.java -lib/core.ts -lib/iterators.ts -lib/map.ts -lib/promise.ts -lib/regex.ts -lib/require.ts -lib/set.ts -lib/values/array.ts -lib/values/boolean.ts -lib/values/errors.ts -lib/values/function.ts -lib/values/number.ts -lib/values/object.ts -lib/values/string.ts -lib/values/symbol.ts diff --git a/src/me/topchetoeu/jscript/Main.java b/src/me/topchetoeu/jscript/Main.java index e702f13..a13ad08 100644 --- a/src/me/topchetoeu/jscript/Main.java +++ b/src/me/topchetoeu/jscript/Main.java @@ -12,6 +12,7 @@ import me.topchetoeu.jscript.events.Observer; import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.exceptions.SyntaxException; import me.topchetoeu.jscript.polyfills.PolyfillEngine; +import me.topchetoeu.jscript.polyfills.TypescriptEngine; public class Main { static Thread task; @@ -51,7 +52,7 @@ public class Main { public static void main(String args[]) { var in = new BufferedReader(new InputStreamReader(System.in)); - engine = new PolyfillEngine(new File(".")); + engine = new TypescriptEngine(new File(".")); var scope = engine.global().globalChild(); var exited = new boolean[1]; diff --git a/src/me/topchetoeu/jscript/compilation/values/ObjectStatement.java b/src/me/topchetoeu/jscript/compilation/values/ObjectStatement.java index ecfc97a..99a0082 100644 --- a/src/me/topchetoeu/jscript/compilation/values/ObjectStatement.java +++ b/src/me/topchetoeu/jscript/compilation/values/ObjectStatement.java @@ -50,8 +50,8 @@ public class ObjectStatement extends Statement { public ObjectStatement(Location loc, Map map, Map getters, Map setters) { super(loc); - this.map = Map.copyOf(map); - this.getters = Map.copyOf(getters); - this.setters = Map.copyOf(setters); + this.map = map; + this.getters = getters; + this.setters = setters; } } diff --git a/src/me/topchetoeu/jscript/engine/CallContext.java b/src/me/topchetoeu/jscript/engine/CallContext.java index 41c0fd7..f787872 100644 --- a/src/me/topchetoeu/jscript/engine/CallContext.java +++ b/src/me/topchetoeu/jscript/engine/CallContext.java @@ -21,14 +21,16 @@ public class CallContext { return this; } public CallContext setData(DataKey key, T val) { - data.put(key, val); + if (val == null) data.remove(key); + else data.put(key, val); return this; } @SuppressWarnings("unchecked") public T addData(DataKey key, T val) { if (data.containsKey(key)) return (T)data.get(key); else { - data.put(key, val); + if (val == null) data.remove(key); + else data.put(key, val); return val; } } diff --git a/src/me/topchetoeu/jscript/engine/frame/Runners.java b/src/me/topchetoeu/jscript/engine/frame/Runners.java index ce78b8a..97f7818 100644 --- a/src/me/topchetoeu/jscript/engine/frame/Runners.java +++ b/src/me/topchetoeu/jscript/engine/frame/Runners.java @@ -532,6 +532,7 @@ public class Runners { } public static Object exec(DebugCommand state, Instruction instr, CodeFrame frame, CallContext ctx) throws InterruptedException { + // System.out.println(instr + "@" + instr.location); switch (instr.type) { case NOP: return execNop(instr, frame, ctx); case RETURN: return execReturn(instr, frame, ctx); diff --git a/src/me/topchetoeu/jscript/engine/values/CodeFunction.java b/src/me/topchetoeu/jscript/engine/values/CodeFunction.java index 9b93d96..e543728 100644 --- a/src/me/topchetoeu/jscript/engine/values/CodeFunction.java +++ b/src/me/topchetoeu/jscript/engine/values/CodeFunction.java @@ -25,6 +25,12 @@ public class CodeFunction extends FunctionValue { } return null; } + public String readable() { + var loc = loc(); + if (loc == null) return name; + else if (name.equals("")) return loc.toString(); + else return name + "@" + loc; + } @Override public Object call(CallContext ctx, Object thisArg, Object... args) throws InterruptedException { diff --git a/src/me/topchetoeu/jscript/engine/values/ObjectValue.java b/src/me/topchetoeu/jscript/engine/values/ObjectValue.java index 64d13f6..2daf6c5 100644 --- a/src/me/topchetoeu/jscript/engine/values/ObjectValue.java +++ b/src/me/topchetoeu/jscript/engine/values/ObjectValue.java @@ -205,6 +205,10 @@ public class ObjectValue { else return null; } protected boolean setField(CallContext ctx, Object key, Object val) throws InterruptedException { + if (val instanceof FunctionValue && ((FunctionValue)val).name.equals("")) { + ((FunctionValue)val).name = Values.toString(ctx, key); + } + values.put(key, val); return true; }