Compare commits
12 Commits
v0.9.0-bet
...
0.9.10-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
446ecd8f2b
|
|||
|
fbf103439a
|
|||
|
b30f94de8f
|
|||
|
47b4dd3c15
|
|||
|
0fb336373a
|
|||
|
b33325a98d
|
|||
|
ccf75d6066
|
|||
|
662dcc1ac1
|
|||
|
3e6214659b
|
|||
|
7c6622c53d
|
|||
|
70d5871091
|
|||
|
7b9bbe576b
|
@@ -1,4 +1,4 @@
|
|||||||
project_group = me.topchetoeu
|
project_group = me.topchetoeu
|
||||||
project_name = jscript
|
project_name = jscript
|
||||||
project_version = 0.8.6-beta
|
project_version = 0.9.10-beta
|
||||||
main_class = me.topchetoeu.jscript.utils.JScriptRepl
|
main_class = me.topchetoeu.jscript.utils.JScriptRepl
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ public class Buffer {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
data = new byte[128];
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void append(byte b) {
|
public void append(byte b) {
|
||||||
write(length, new byte[] { b });
|
write(length, new byte[] { b });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
|
|
||||||
public class Instruction {
|
public class Instruction {
|
||||||
public static enum Type {
|
public static enum Type {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.topchetoeu.jscript.common.events;
|
package me.topchetoeu.jscript.common.events;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.InterruptException;
|
import me.topchetoeu.jscript.runtime.exceptions.InterruptException;
|
||||||
|
|
||||||
public class Notifier {
|
public class Notifier {
|
||||||
private boolean ok = false;
|
private boolean ok = false;
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import me.topchetoeu.jscript.compilation.parsing.Operator;
|
|||||||
import me.topchetoeu.jscript.compilation.parsing.ParseRes;
|
import me.topchetoeu.jscript.compilation.parsing.ParseRes;
|
||||||
import me.topchetoeu.jscript.compilation.parsing.Parsing;
|
import me.topchetoeu.jscript.compilation.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.compilation.parsing.Token;
|
import me.topchetoeu.jscript.compilation.parsing.Token;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
|
||||||
public class JSON {
|
public class JSON {
|
||||||
public static Object toJs(JSONElement val) {
|
public static Object toJs(JSONElement val) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.stream.Collectors;
|
|||||||
import me.topchetoeu.jscript.common.Filename;
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.common.Location;
|
import me.topchetoeu.jscript.common.Location;
|
||||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||||
import me.topchetoeu.jscript.core.scope.LocalScopeRecord;
|
import me.topchetoeu.jscript.compilation.scope.LocalScopeRecord;
|
||||||
import me.topchetoeu.jscript.utils.mapping.SourceMap;
|
import me.topchetoeu.jscript.utils.mapping.SourceMap;
|
||||||
|
|
||||||
public class FunctionMap {
|
public class FunctionMap {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import me.topchetoeu.jscript.common.Location;
|
|||||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||||
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
||||||
import me.topchetoeu.jscript.common.mapping.FunctionMap.FunctionMapBuilder;
|
import me.topchetoeu.jscript.common.mapping.FunctionMap.FunctionMapBuilder;
|
||||||
import me.topchetoeu.jscript.core.scope.LocalScopeRecord;
|
import me.topchetoeu.jscript.compilation.scope.LocalScopeRecord;
|
||||||
|
|
||||||
public class CompileResult {
|
public class CompileResult {
|
||||||
public final Vector<Instruction> instructions = new Vector<>();
|
public final Vector<Instruction> instructions = new Vector<>();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.compilation;
|
package me.topchetoeu.jscript.compilation;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Instruction;
|
import me.topchetoeu.jscript.common.Instruction;
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
|
|
||||||
public class ThrowSyntaxStatement extends Statement {
|
public class ThrowSyntaxStatement extends Statement {
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import me.topchetoeu.jscript.compilation.VariableDeclareStatement.Pair;
|
|||||||
import me.topchetoeu.jscript.compilation.control.*;
|
import me.topchetoeu.jscript.compilation.control.*;
|
||||||
import me.topchetoeu.jscript.compilation.control.SwitchStatement.SwitchCase;
|
import me.topchetoeu.jscript.compilation.control.SwitchStatement.SwitchCase;
|
||||||
import me.topchetoeu.jscript.compilation.parsing.ParseRes.State;
|
import me.topchetoeu.jscript.compilation.parsing.ParseRes.State;
|
||||||
|
import me.topchetoeu.jscript.compilation.scope.LocalScopeRecord;
|
||||||
import me.topchetoeu.jscript.compilation.values.*;
|
import me.topchetoeu.jscript.compilation.values.*;
|
||||||
import me.topchetoeu.jscript.core.scope.LocalScopeRecord;
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
|
||||||
|
|
||||||
// TODO: this has to be rewritten
|
// TODO: this has to be rewritten
|
||||||
public class Parsing {
|
public class Parsing {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.core.scope;
|
package me.topchetoeu.jscript.compilation.scope;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.ScopeRecord;
|
|
||||||
|
|
||||||
public class LocalScopeRecord implements ScopeRecord {
|
public class LocalScopeRecord implements ScopeRecord {
|
||||||
public final LocalScopeRecord parent;
|
public final LocalScopeRecord parent;
|
||||||
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.common;
|
package me.topchetoeu.jscript.compilation.scope;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.scope.LocalScopeRecord;
|
|
||||||
|
|
||||||
public interface ScopeRecord {
|
public interface ScopeRecord {
|
||||||
public Object getKey(String name);
|
public Object getKey(String name);
|
||||||
@@ -7,7 +7,7 @@ import me.topchetoeu.jscript.common.Instruction.Type;
|
|||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.CompoundStatement;
|
import me.topchetoeu.jscript.compilation.CompoundStatement;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
|
|
||||||
public class FunctionStatement extends Statement {
|
public class FunctionStatement extends Statement {
|
||||||
public final CompoundStatement body;
|
public final CompoundStatement body;
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
|
||||||
|
|
||||||
public class Key<T> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -3,11 +3,11 @@ package me.topchetoeu.jscript.lib;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
|
||||||
import me.topchetoeu.jscript.lib.PromiseLib.Handle;
|
import me.topchetoeu.jscript.lib.PromiseLib.Handle;
|
||||||
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
||||||
|
|
||||||
@WrapperName("AsyncGeneratorFunction")
|
@WrapperName("AsyncGeneratorFunction")
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package me.topchetoeu.jscript.lib;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
|
||||||
import me.topchetoeu.jscript.lib.PromiseLib.Handle;
|
import me.topchetoeu.jscript.lib.PromiseLib.Handle;
|
||||||
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package me.topchetoeu.jscript.lib;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.File;
|
import me.topchetoeu.jscript.utils.filesystem.File;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import me.topchetoeu.jscript.common.Buffer;
|
import me.topchetoeu.jscript.common.Buffer;
|
||||||
import me.topchetoeu.jscript.compilation.parsing.Parsing;
|
import me.topchetoeu.jscript.compilation.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeTarget;
|
import me.topchetoeu.jscript.utils.interop.ExposeTarget;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.exceptions.ConvertException;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue.PlaceholderProto;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.core.exceptions.ConvertException;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue.PlaceholderProto;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.File;
|
import me.topchetoeu.jscript.utils.filesystem.File;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.FilesystemException;
|
import me.topchetoeu.jscript.utils.filesystem.FilesystemException;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import java.io.IOException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.ActionType;
|
import me.topchetoeu.jscript.utils.filesystem.ActionType;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.EntryType;
|
import me.topchetoeu.jscript.utils.filesystem.EntryType;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.ErrorReason;
|
import me.topchetoeu.jscript.utils.filesystem.ErrorReason;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeTarget;
|
import me.topchetoeu.jscript.utils.interop.ExposeTarget;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
||||||
|
|
||||||
@WrapperName("GeneratorFunction")
|
@WrapperName("GeneratorFunction")
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
import me.topchetoeu.jscript.utils.interop.WrapperName;
|
||||||
|
|||||||
@@ -2,18 +2,21 @@ package me.topchetoeu.jscript.lib;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
import me.topchetoeu.jscript.core.EventLoop;
|
import me.topchetoeu.jscript.runtime.EventLoop;
|
||||||
import me.topchetoeu.jscript.core.Key;
|
import me.topchetoeu.jscript.runtime.Key;
|
||||||
import me.topchetoeu.jscript.core.scope.GlobalScope;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.scope.GlobalScope;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
import me.topchetoeu.jscript.utils.filesystem.Filesystem;
|
||||||
|
import me.topchetoeu.jscript.utils.filesystem.Mode;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeField;
|
import me.topchetoeu.jscript.utils.interop.ExposeField;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeTarget;
|
import me.topchetoeu.jscript.utils.interop.ExposeTarget;
|
||||||
|
import me.topchetoeu.jscript.utils.interop.ExposeType;
|
||||||
import me.topchetoeu.jscript.utils.modules.ModuleRepo;
|
import me.topchetoeu.jscript.utils.modules.ModuleRepo;
|
||||||
|
|
||||||
public class Internals {
|
public class Internals {
|
||||||
@@ -126,6 +129,19 @@ public class Internals {
|
|||||||
return NumberLib.__isInfinite(args);
|
return NumberLib.__isInfinite(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Expose(target = ExposeTarget.STATIC, type = ExposeType.GETTER)
|
||||||
|
public static FileLib __stdin(Arguments args) {
|
||||||
|
return new FileLib(Filesystem.get(args.ctx).open("std://in", Mode.READ));
|
||||||
|
}
|
||||||
|
@Expose(target = ExposeTarget.STATIC, type = ExposeType.GETTER)
|
||||||
|
public static FileLib __stdout(Arguments args) {
|
||||||
|
return new FileLib(Filesystem.get(args.ctx).open("std://out", Mode.READ));
|
||||||
|
}
|
||||||
|
@Expose(target = ExposeTarget.STATIC, type = ExposeType.GETTER)
|
||||||
|
public static FileLib __stderr(Arguments args) {
|
||||||
|
return new FileLib(Filesystem.get(args.ctx).open("std://err", Mode.READ));
|
||||||
|
}
|
||||||
|
|
||||||
@ExposeField(target = ExposeTarget.STATIC)
|
@ExposeField(target = ExposeTarget.STATIC)
|
||||||
public static double __NaN = Double.NaN;
|
public static double __NaN = Double.NaN;
|
||||||
@ExposeField(target = ExposeTarget.STATIC)
|
@ExposeField(target = ExposeTarget.STATIC)
|
||||||
@@ -157,27 +173,27 @@ public class Internals {
|
|||||||
glob.define(null, "Encoding", false, wp.getNamespace(EncodingLib.class));
|
glob.define(null, "Encoding", false, wp.getNamespace(EncodingLib.class));
|
||||||
glob.define(null, "Filesystem", false, wp.getNamespace(FilesystemLib.class));
|
glob.define(null, "Filesystem", false, wp.getNamespace(FilesystemLib.class));
|
||||||
|
|
||||||
glob.define(false, wp.getConstr(FileLib.class));
|
glob.define(null, false, wp.getConstr(FileLib.class));
|
||||||
|
|
||||||
glob.define(false, wp.getConstr(DateLib.class));
|
glob.define(null, false, wp.getConstr(DateLib.class));
|
||||||
glob.define(false, wp.getConstr(ObjectLib.class));
|
glob.define(null, false, wp.getConstr(ObjectLib.class));
|
||||||
glob.define(false, wp.getConstr(FunctionLib.class));
|
glob.define(null, false, wp.getConstr(FunctionLib.class));
|
||||||
glob.define(false, wp.getConstr(ArrayLib.class));
|
glob.define(null, false, wp.getConstr(ArrayLib.class));
|
||||||
|
|
||||||
glob.define(false, wp.getConstr(BooleanLib.class));
|
glob.define(null, false, wp.getConstr(BooleanLib.class));
|
||||||
glob.define(false, wp.getConstr(NumberLib.class));
|
glob.define(null, false, wp.getConstr(NumberLib.class));
|
||||||
glob.define(false, wp.getConstr(StringLib.class));
|
glob.define(null, false, wp.getConstr(StringLib.class));
|
||||||
glob.define(false, wp.getConstr(SymbolLib.class));
|
glob.define(null, false, wp.getConstr(SymbolLib.class));
|
||||||
|
|
||||||
glob.define(false, wp.getConstr(PromiseLib.class));
|
glob.define(null, false, wp.getConstr(PromiseLib.class));
|
||||||
glob.define(false, wp.getConstr(RegExpLib.class));
|
glob.define(null, false, wp.getConstr(RegExpLib.class));
|
||||||
glob.define(false, wp.getConstr(MapLib.class));
|
glob.define(null, false, wp.getConstr(MapLib.class));
|
||||||
glob.define(false, wp.getConstr(SetLib.class));
|
glob.define(null, false, wp.getConstr(SetLib.class));
|
||||||
|
|
||||||
glob.define(false, wp.getConstr(ErrorLib.class));
|
glob.define(null, false, wp.getConstr(ErrorLib.class));
|
||||||
glob.define(false, wp.getConstr(SyntaxErrorLib.class));
|
glob.define(null, false, wp.getConstr(SyntaxErrorLib.class));
|
||||||
glob.define(false, wp.getConstr(TypeErrorLib.class));
|
glob.define(null, false, wp.getConstr(TypeErrorLib.class));
|
||||||
glob.define(false, wp.getConstr(RangeErrorLib.class));
|
glob.define(null, false, wp.getConstr(RangeErrorLib.class));
|
||||||
|
|
||||||
env.add(Environment.OBJECT_PROTO, wp.getProto(ObjectLib.class));
|
env.add(Environment.OBJECT_PROTO, wp.getProto(ObjectLib.class));
|
||||||
env.add(Environment.FUNCTION_PROTO, wp.getProto(FunctionLib.class));
|
env.add(Environment.FUNCTION_PROTO, wp.getProto(FunctionLib.class));
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.json.JSON;
|
import me.topchetoeu.jscript.common.json.JSON;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeTarget;
|
import me.topchetoeu.jscript.utils.interop.ExposeTarget;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.Symbol;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Symbol;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.ResultRunnable;
|
import me.topchetoeu.jscript.common.ResultRunnable;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.EventLoop;
|
import me.topchetoeu.jscript.runtime.EventLoop;
|
||||||
import me.topchetoeu.jscript.core.Extensions;
|
import me.topchetoeu.jscript.runtime.Extensions;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.exceptions.InterruptException;
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.InterruptException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
@@ -53,26 +53,29 @@ public class PromiseLib {
|
|||||||
private Object val;
|
private Object val;
|
||||||
|
|
||||||
private void resolveSynchronized(Context ctx, Object val, int newState) {
|
private void resolveSynchronized(Context ctx, Object val, int newState) {
|
||||||
if (!ctx.hasNotNull(EventLoop.KEY)) throw EngineException.ofError("No event loop");
|
this.val = val;
|
||||||
|
this.state = newState;
|
||||||
ctx.get(EventLoop.KEY).pushMsg(() -> {
|
|
||||||
this.val = val;
|
for (var handle : handles) {
|
||||||
this.state = newState;
|
if (newState == STATE_FULFILLED) handle.onFulfil(val);
|
||||||
|
if (newState == STATE_REJECTED) {
|
||||||
for (var handle : handles) {
|
handle.onReject((EngineException)val);
|
||||||
if (newState == STATE_FULFILLED) handle.onFulfil(val);
|
handled = true;
|
||||||
if (newState == STATE_REJECTED) {
|
|
||||||
handle.onReject((EngineException)val);
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (state == STATE_REJECTED && !handled) {
|
if (state == STATE_REJECTED && !handled) {
|
||||||
Values.printError(((EngineException)val).setCtx(ctx), "(in promise)");
|
Values.printError(((EngineException)val).setCtx(ctx), "(in promise)");
|
||||||
}
|
}
|
||||||
|
|
||||||
handles = null;
|
handles = null;
|
||||||
}, true);
|
|
||||||
|
// ctx.get(EventLoop.KEY).pushMsg(() -> {
|
||||||
|
// if (!ctx.hasNotNull(EventLoop.KEY)) throw EngineException.ofError("No event loop");
|
||||||
|
|
||||||
|
|
||||||
|
// handles = null;
|
||||||
|
// }, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
private synchronized void resolve(Context ctx, Object val, int newState) {
|
private synchronized void resolve(Context ctx, Object val, int newState) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue.PlaceholderProto;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue.PlaceholderProto;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeField;
|
import me.topchetoeu.jscript.utils.interop.ExposeField;
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.NativeWrapper;
|
import me.topchetoeu.jscript.runtime.values.NativeWrapper;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package me.topchetoeu.jscript.lib;
|
|||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.Symbol;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Symbol;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package me.topchetoeu.jscript.lib;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.Symbol;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Symbol;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.Expose;
|
import me.topchetoeu.jscript.utils.interop.Expose;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue.PlaceholderProto;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue.PlaceholderProto;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeField;
|
import me.topchetoeu.jscript.utils.interop.ExposeField;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue.PlaceholderProto;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue.PlaceholderProto;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
import me.topchetoeu.jscript.utils.interop.ExposeConstructor;
|
||||||
import me.topchetoeu.jscript.utils.interop.ExposeField;
|
import me.topchetoeu.jscript.utils.interop.ExposeField;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Filename;
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.common.FunctionBody;
|
import me.topchetoeu.jscript.common.FunctionBody;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.scope.ValueVariable;
|
import me.topchetoeu.jscript.runtime.scope.ValueVariable;
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
|
|
||||||
public interface Compiler {
|
public interface Compiler {
|
||||||
public Key<Compiler> KEY = new Key<>();
|
public Key<Compiler> KEY = new Key<>();
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Filename;
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.core.debug.DebugContext;
|
import me.topchetoeu.jscript.runtime.debug.DebugContext;
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.scope.ValueVariable;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
import me.topchetoeu.jscript.core.scope.ValueVariable;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
|
|
||||||
public class Context implements Extensions {
|
public class Context implements Extensions {
|
||||||
public static final Context NULL = new Context();
|
public static final Context NULL = new Context();
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Filename;
|
|
||||||
import me.topchetoeu.jscript.common.ResultRunnable;
|
import me.topchetoeu.jscript.common.ResultRunnable;
|
||||||
import me.topchetoeu.jscript.common.events.DataNotifier;
|
import me.topchetoeu.jscript.common.events.DataNotifier;
|
||||||
import me.topchetoeu.jscript.core.exceptions.InterruptException;
|
import me.topchetoeu.jscript.runtime.exceptions.InterruptException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
|
||||||
|
|
||||||
public class Engine implements EventLoop {
|
public class Engine implements EventLoop {
|
||||||
private static class Task<T> implements Comparable<Task<?>> {
|
private static class Task<T> implements Comparable<Task<?>> {
|
||||||
@@ -78,18 +76,6 @@ public class Engine implements EventLoop {
|
|||||||
return this.thread != null;
|
return this.thread != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataNotifier<Object> pushMsg(boolean micro, Environment env, FunctionValue func, Object thisArg, Object ...args) {
|
|
||||||
return pushMsg(() -> {
|
|
||||||
return func.call(new Context(env), thisArg, args);
|
|
||||||
}, micro);
|
|
||||||
}
|
|
||||||
public DataNotifier<Object> pushMsg(boolean micro, Environment env, Filename filename, String raw, Object thisArg, Object ...args) {
|
|
||||||
return pushMsg(() -> {
|
|
||||||
var ctx = new Context(env);
|
|
||||||
return ctx.compile(filename, raw).call(new Context(env), thisArg, args);
|
|
||||||
}, micro);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Engine() {
|
public Engine() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.scope.GlobalScope;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.scope.GlobalScope;
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.utils.interop.NativeWrapperProvider;
|
import me.topchetoeu.jscript.utils.interop.NativeWrapperProvider;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.common.ResultRunnable;
|
import me.topchetoeu.jscript.common.ResultRunnable;
|
||||||
import me.topchetoeu.jscript.common.events.DataNotifier;
|
import me.topchetoeu.jscript.common.events.DataNotifier;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
|
|
||||||
public interface EventLoop {
|
public interface EventLoop {
|
||||||
public static final Key<EventLoop> KEY = new Key<>();
|
public static final Key<EventLoop> KEY = new Key<>();
|
||||||
@@ -20,4 +22,16 @@ public interface EventLoop {
|
|||||||
public default DataNotifier<Void> pushMsg(Runnable runnable, boolean micro) {
|
public default DataNotifier<Void> pushMsg(Runnable runnable, boolean micro) {
|
||||||
return pushMsg(() -> { runnable.run(); return null; }, micro);
|
return pushMsg(() -> { runnable.run(); return null; }, micro);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public default DataNotifier<Object> pushMsg(boolean micro, Environment env, FunctionValue func, Object thisArg, Object ...args) {
|
||||||
|
return pushMsg(() -> {
|
||||||
|
return func.call(new Context(env), thisArg, args);
|
||||||
|
}, micro);
|
||||||
|
}
|
||||||
|
public default DataNotifier<Object> pushMsg(boolean micro, Environment env, Filename filename, String raw, Object thisArg, Object ...args) {
|
||||||
|
return pushMsg(() -> {
|
||||||
|
var ctx = new Context(env);
|
||||||
|
return ctx.compile(filename, raw).call(new Context(env), thisArg, args);
|
||||||
|
}, micro);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface Extensions {
|
public interface Extensions {
|
||||||
|
public static Extensions EMPTY = new Extensions() {
|
||||||
|
@Override public <T> void add(Key<T> key, T obj) { }
|
||||||
|
@Override public boolean remove(Key<?> key) { return false; }
|
||||||
|
|
||||||
|
@Override public <T> T get(Key<T> key) { return null; }
|
||||||
|
@Override public boolean has(Key<?> key) { return false; }
|
||||||
|
@Override public Iterable<Key<?>> keys() { return List.of(); }
|
||||||
|
};
|
||||||
|
|
||||||
<T> T get(Key<T> key);
|
<T> T get(Key<T> key);
|
||||||
<T> void add(Key<T> key, T obj);
|
<T> void add(Key<T> key, T obj);
|
||||||
Iterable<Key<?>> keys();
|
Iterable<Key<?>> keys();
|
||||||
@@ -35,4 +46,9 @@ public interface Extensions {
|
|||||||
add((Key<Object>)key, (Object)source.get(key));
|
add((Key<Object>)key, (Object)source.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Extensions wrap(Extensions ext) {
|
||||||
|
if (ext == null) return EMPTY;
|
||||||
|
else return ext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Instruction;
|
import me.topchetoeu.jscript.common.Instruction;
|
||||||
import me.topchetoeu.jscript.core.debug.DebugContext;
|
import me.topchetoeu.jscript.runtime.debug.DebugContext;
|
||||||
import me.topchetoeu.jscript.core.scope.LocalScope;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.scope.ValueVariable;
|
import me.topchetoeu.jscript.runtime.exceptions.InterruptException;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.scope.LocalScope;
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
import me.topchetoeu.jscript.runtime.scope.ValueVariable;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.ScopeValue;
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.ScopeValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.InterruptException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
|
||||||
public class Frame {
|
public class Frame {
|
||||||
public static enum TryState {
|
public static enum TryState {
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.scope.ValueVariable;
|
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
|
||||||
import me.topchetoeu.jscript.core.values.Symbol;
|
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
|
||||||
import me.topchetoeu.jscript.common.Instruction;
|
import me.topchetoeu.jscript.common.Instruction;
|
||||||
import me.topchetoeu.jscript.common.Operation;
|
import me.topchetoeu.jscript.common.Operation;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
import me.topchetoeu.jscript.runtime.scope.ValueVariable;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.Symbol;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
|
||||||
public class InstructionRunner {
|
public class InstructionRunner {
|
||||||
private static Object execReturn(Context ctx, Instruction instr, Frame frame) {
|
private static Object execReturn(Context ctx, Instruction instr, Frame frame) {
|
||||||
@@ -46,7 +46,7 @@ public class InstructionRunner {
|
|||||||
|
|
||||||
private static Object execMakeVar(Context ctx, Instruction instr, Frame frame) {
|
private static Object execMakeVar(Context ctx, Instruction instr, Frame frame) {
|
||||||
var name = (String)instr.get(0);
|
var name = (String)instr.get(0);
|
||||||
ctx.environment.global.define(name);
|
ctx.environment.global.define(ctx, name);
|
||||||
frame.codePtr++;
|
frame.codePtr++;
|
||||||
return Values.NO_RETURN;
|
return Values.NO_RETURN;
|
||||||
}
|
}
|
||||||
5
src/java/me/topchetoeu/jscript/runtime/Key.java
Normal file
5
src/java/me/topchetoeu/jscript/runtime/Key.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
|
public class Key<T> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.core;
|
package me.topchetoeu.jscript.runtime;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
|
|
||||||
public interface WrapperProvider {
|
public interface WrapperProvider {
|
||||||
public ObjectValue getProto(Class<?> obj);
|
public ObjectValue getProto(Class<?> obj);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.debug;
|
package me.topchetoeu.jscript.runtime.debug;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -10,13 +10,13 @@ import me.topchetoeu.jscript.common.FunctionBody;
|
|||||||
import me.topchetoeu.jscript.common.Instruction;
|
import me.topchetoeu.jscript.common.Instruction;
|
||||||
import me.topchetoeu.jscript.common.Location;
|
import me.topchetoeu.jscript.common.Location;
|
||||||
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Extensions;
|
import me.topchetoeu.jscript.runtime.Extensions;
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.core.Key;
|
import me.topchetoeu.jscript.runtime.Key;
|
||||||
import me.topchetoeu.jscript.core.values.CodeFunction;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.CodeFunction;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
|
|
||||||
public class DebugContext {
|
public class DebugContext {
|
||||||
public static final Key<DebugContext> KEY = new Key<>();
|
public static final Key<DebugContext> KEY = new Key<>();
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package me.topchetoeu.jscript.core.debug;
|
package me.topchetoeu.jscript.runtime.debug;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Filename;
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.common.FunctionBody;
|
import me.topchetoeu.jscript.common.FunctionBody;
|
||||||
import me.topchetoeu.jscript.common.Instruction;
|
import me.topchetoeu.jscript.common.Instruction;
|
||||||
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
|
||||||
public interface DebugHandler {
|
public interface DebugHandler {
|
||||||
/**
|
/**
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.exceptions;
|
package me.topchetoeu.jscript.runtime.exceptions;
|
||||||
|
|
||||||
public class ConvertException extends RuntimeException {
|
public class ConvertException extends RuntimeException {
|
||||||
public final String source, target;
|
public final String source, target;
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package me.topchetoeu.jscript.core.exceptions;
|
package me.topchetoeu.jscript.runtime.exceptions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Location;
|
import me.topchetoeu.jscript.common.Location;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue.PlaceholderProto;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue.PlaceholderProto;
|
||||||
|
|
||||||
public class EngineException extends RuntimeException {
|
public class EngineException extends RuntimeException {
|
||||||
public static class StackElement {
|
public static class StackElement {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.exceptions;
|
package me.topchetoeu.jscript.runtime.exceptions;
|
||||||
|
|
||||||
public class InterruptException extends RuntimeException {
|
public class InterruptException extends RuntimeException {
|
||||||
public InterruptException() { }
|
public InterruptException() { }
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.exceptions;
|
package me.topchetoeu.jscript.runtime.exceptions;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Location;
|
import me.topchetoeu.jscript.common.Location;
|
||||||
|
|
||||||
@@ -1,42 +1,35 @@
|
|||||||
package me.topchetoeu.jscript.core.scope;
|
package me.topchetoeu.jscript.runtime.scope;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.ScopeRecord;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
|
||||||
|
|
||||||
public class GlobalScope implements ScopeRecord {
|
public class GlobalScope {
|
||||||
public final ObjectValue obj;
|
public final ObjectValue obj;
|
||||||
|
|
||||||
public boolean has(Context ctx, String name) {
|
public boolean has(Context ctx, String name) {
|
||||||
return Values.hasMember(null, obj, name, false);
|
return Values.hasMember(null, obj, name, false);
|
||||||
}
|
}
|
||||||
public Object getKey(String name) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalScope globalChild() {
|
public GlobalScope globalChild() {
|
||||||
var obj = new ObjectValue();
|
var obj = new ObjectValue();
|
||||||
Values.setPrototype(null, obj, this.obj);
|
Values.setPrototype(null, obj, this.obj);
|
||||||
return new GlobalScope(obj);
|
return new GlobalScope(obj);
|
||||||
}
|
}
|
||||||
public LocalScopeRecord child() {
|
|
||||||
return new LocalScopeRecord();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object define(String name) {
|
public Object define(Context ctx, String name) {
|
||||||
if (Values.hasMember(Context.NULL, obj, name, false)) return name;
|
if (Values.hasMember(ctx, obj, name, false)) return name;
|
||||||
obj.defineProperty(Context.NULL, name, null);
|
obj.defineProperty(ctx, name, null);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
public void define(String name, Variable val) {
|
public void define(Context ctx, String name, Variable val) {
|
||||||
obj.defineProperty(Context.NULL, name,
|
obj.defineProperty(ctx, name,
|
||||||
new NativeFunction("get " + name, args -> val.get(args.ctx)),
|
new NativeFunction("get " + name, args -> val.get(args.ctx)),
|
||||||
new NativeFunction("set " + name, args -> { val.set(args.ctx, args.get(0)); return null; }),
|
new NativeFunction("set " + name, args -> { val.set(args.ctx, args.get(0)); return null; }),
|
||||||
true, true
|
true, true
|
||||||
@@ -45,11 +38,11 @@ public class GlobalScope implements ScopeRecord {
|
|||||||
public void define(Context ctx, String name, boolean readonly, Object val) {
|
public void define(Context ctx, String name, boolean readonly, Object val) {
|
||||||
obj.defineProperty(ctx, name, val, readonly, true, true);
|
obj.defineProperty(ctx, name, val, readonly, true, true);
|
||||||
}
|
}
|
||||||
public void define(String ...names) {
|
public void define(Context ctx, String ...names) {
|
||||||
for (var n : names) define(n);
|
for (var n : names) define(ctx, n);
|
||||||
}
|
}
|
||||||
public void define(boolean readonly, FunctionValue val) {
|
public void define(Context ctx, boolean readonly, FunctionValue val) {
|
||||||
define(null, val.name, readonly, val);
|
define(ctx, val.name, readonly, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object get(Context ctx, String name) {
|
public Object get(Context ctx, String name) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.scope;
|
package me.topchetoeu.jscript.runtime.scope;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.core.scope;
|
package me.topchetoeu.jscript.runtime.scope;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
|
||||||
public class ValueVariable implements Variable {
|
public class ValueVariable implements Variable {
|
||||||
public boolean readonly;
|
public boolean readonly;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.topchetoeu.jscript.core.scope;
|
package me.topchetoeu.jscript.runtime.scope;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
|
||||||
public interface Variable {
|
public interface Variable {
|
||||||
Object get(Context ctx);
|
Object get(Context ctx);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -6,7 +6,7 @@ import java.util.Comparator;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
|
||||||
// TODO: Make methods generic
|
// TODO: Make methods generic
|
||||||
public class ArrayValue extends ObjectValue implements Iterable<Object> {
|
public class ArrayValue extends ObjectValue implements Iterable<Object> {
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.FunctionBody;
|
import me.topchetoeu.jscript.common.FunctionBody;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.core.scope.ValueVariable;
|
import me.topchetoeu.jscript.runtime.scope.ValueVariable;
|
||||||
|
|
||||||
public class CodeFunction extends FunctionValue {
|
public class CodeFunction extends FunctionValue {
|
||||||
public final FunctionBody body;
|
public final FunctionBody body;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
public enum ConvertHint {
|
public enum ConvertHint {
|
||||||
TOSTRING,
|
TOSTRING,
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
|
||||||
public abstract class FunctionValue extends ObjectValue {
|
public abstract class FunctionValue extends ObjectValue {
|
||||||
public String name = "";
|
public String name = "";
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||||
|
|
||||||
public class NativeFunction extends FunctionValue {
|
public class NativeFunction extends FunctionValue {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
|
||||||
public class NativeWrapper extends ObjectValue {
|
public class NativeWrapper extends ObjectValue {
|
||||||
private static final Object NATIVE_PROTO = new Object();
|
private static final Object NATIVE_PROTO = new Object();
|
||||||
@@ -8,7 +8,7 @@ public class NativeWrapper extends ObjectValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectValue getPrototype(Context ctx) {
|
public ObjectValue getPrototype(Context ctx) {
|
||||||
if (prototype == NATIVE_PROTO) return ctx.environment.wrappers.getProto(wrapped.getClass());
|
if (ctx.environment != null && prototype == NATIVE_PROTO) return ctx.environment.wrappers.getProto(wrapped.getClass());
|
||||||
else return super.getPrototype(ctx);
|
else return super.getPrototype(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -6,8 +6,8 @@ import java.util.LinkedHashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
|
|
||||||
public class ObjectValue {
|
public class ObjectValue {
|
||||||
public static enum PlaceholderProto {
|
public static enum PlaceholderProto {
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.scope.ValueVariable;
|
import me.topchetoeu.jscript.runtime.scope.ValueVariable;
|
||||||
|
|
||||||
public class ScopeValue extends ObjectValue {
|
public class ScopeValue extends ObjectValue {
|
||||||
public final ValueVariable[] variables;
|
public final ValueVariable[] variables;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.core.values;
|
package me.topchetoeu.jscript.runtime.values;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
@@ -13,13 +13,13 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Operation;
|
import me.topchetoeu.jscript.common.Operation;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
|
||||||
import me.topchetoeu.jscript.core.debug.DebugContext;
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.ConvertException;
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
|
||||||
import me.topchetoeu.jscript.lib.PromiseLib;
|
import me.topchetoeu.jscript.lib.PromiseLib;
|
||||||
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
|
import me.topchetoeu.jscript.runtime.debug.DebugContext;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.ConvertException;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
|
|
||||||
public class Values {
|
public class Values {
|
||||||
public static enum CompareResult {
|
public static enum CompareResult {
|
||||||
@@ -4,9 +4,9 @@ import me.topchetoeu.jscript.common.Filename;
|
|||||||
import me.topchetoeu.jscript.common.FunctionBody;
|
import me.topchetoeu.jscript.common.FunctionBody;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.parsing.Parsing;
|
import me.topchetoeu.jscript.compilation.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.core.Compiler;
|
import me.topchetoeu.jscript.runtime.Compiler;
|
||||||
import me.topchetoeu.jscript.core.Extensions;
|
import me.topchetoeu.jscript.runtime.Extensions;
|
||||||
import me.topchetoeu.jscript.core.debug.DebugContext;
|
import me.topchetoeu.jscript.runtime.debug.DebugContext;
|
||||||
|
|
||||||
public class JSCompiler implements Compiler {
|
public class JSCompiler implements Compiler {
|
||||||
public final Extensions ext;
|
public final Extensions ext;
|
||||||
|
|||||||
@@ -8,18 +8,18 @@ import java.nio.file.Path;
|
|||||||
import me.topchetoeu.jscript.common.Filename;
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.common.Metadata;
|
import me.topchetoeu.jscript.common.Metadata;
|
||||||
import me.topchetoeu.jscript.common.Reading;
|
import me.topchetoeu.jscript.common.Reading;
|
||||||
import me.topchetoeu.jscript.core.Compiler;
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
|
||||||
import me.topchetoeu.jscript.core.Engine;
|
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
|
||||||
import me.topchetoeu.jscript.core.EventLoop;
|
|
||||||
import me.topchetoeu.jscript.core.debug.DebugContext;
|
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.InterruptException;
|
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
|
||||||
import me.topchetoeu.jscript.lib.Internals;
|
import me.topchetoeu.jscript.lib.Internals;
|
||||||
|
import me.topchetoeu.jscript.runtime.Compiler;
|
||||||
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
import me.topchetoeu.jscript.runtime.Engine;
|
||||||
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
|
import me.topchetoeu.jscript.runtime.EventLoop;
|
||||||
|
import me.topchetoeu.jscript.runtime.debug.DebugContext;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.InterruptException;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
import me.topchetoeu.jscript.utils.debug.DebugServer;
|
import me.topchetoeu.jscript.utils.debug.DebugServer;
|
||||||
import me.topchetoeu.jscript.utils.debug.SimpleDebugger;
|
import me.topchetoeu.jscript.utils.debug.SimpleDebugger;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.Filesystem;
|
import me.topchetoeu.jscript.utils.filesystem.Filesystem;
|
||||||
@@ -87,10 +87,10 @@ public class JScriptRepl {
|
|||||||
private static void initEnv() {
|
private static void initEnv() {
|
||||||
environment = Internals.apply(environment);
|
environment = Internals.apply(environment);
|
||||||
|
|
||||||
environment.global.define(false, new NativeFunction("exit", args -> {
|
environment.global.define(null, false, new NativeFunction("exit", args -> {
|
||||||
throw new InterruptException();
|
throw new InterruptException();
|
||||||
}));
|
}));
|
||||||
environment.global.define(false, new NativeFunction("go", args -> {
|
environment.global.define(null, false, new NativeFunction("go", args -> {
|
||||||
try {
|
try {
|
||||||
var f = Path.of("do.js");
|
var f = Path.of("do.js");
|
||||||
var func = args.ctx.compile(new Filename("do", "do/" + j++ + ".js"), new String(Files.readAllBytes(f)));
|
var func = args.ctx.compile(new Filename("do", "do/" + j++ + ".js"), new String(Files.readAllBytes(f)));
|
||||||
@@ -100,7 +100,7 @@ public class JScriptRepl {
|
|||||||
throw new EngineException("Couldn't open do.js");
|
throw new EngineException("Couldn't open do.js");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
environment.global.define(false, new NativeFunction("log", args -> {
|
environment.global.define(null, false, new NativeFunction("log", args -> {
|
||||||
for (var el : args.args) {
|
for (var el : args.args) {
|
||||||
Values.printValue(args.ctx, el);
|
Values.printValue(args.ctx, el);
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ public class JScriptRepl {
|
|||||||
var fs = new RootFilesystem(PermissionsProvider.get(environment));
|
var fs = new RootFilesystem(PermissionsProvider.get(environment));
|
||||||
fs.protocols.put("temp", new MemoryFilesystem(Mode.READ_WRITE));
|
fs.protocols.put("temp", new MemoryFilesystem(Mode.READ_WRITE));
|
||||||
fs.protocols.put("file", new PhysicalFilesystem("."));
|
fs.protocols.put("file", new PhysicalFilesystem("."));
|
||||||
fs.protocols.put("std", STDFilesystem.ofStd(System.in, System.out, System.err));
|
fs.protocols.put("std", new STDFilesystem(System.in, System.out, System.err));
|
||||||
|
|
||||||
environment.add(PermissionsProvider.KEY, PermissionsManager.ALL_PERMS);
|
environment.add(PermissionsProvider.KEY, PermissionsManager.ALL_PERMS);
|
||||||
environment.add(Filesystem.KEY, fs);
|
environment.add(Filesystem.KEY, fs);
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import me.topchetoeu.jscript.common.events.Notifier;
|
|||||||
import me.topchetoeu.jscript.common.json.JSON;
|
import me.topchetoeu.jscript.common.json.JSON;
|
||||||
import me.topchetoeu.jscript.common.json.JSONList;
|
import me.topchetoeu.jscript.common.json.JSONList;
|
||||||
import me.topchetoeu.jscript.common.json.JSONMap;
|
import me.topchetoeu.jscript.common.json.JSONMap;
|
||||||
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
import me.topchetoeu.jscript.utils.debug.WebSocketMessage.Type;
|
import me.topchetoeu.jscript.utils.debug.WebSocketMessage.Type;
|
||||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
|
||||||
|
|
||||||
public class DebugServer {
|
public class DebugServer {
|
||||||
public static String browserDisplayName = Metadata.name() + "/" + Metadata.version();
|
public static String browserDisplayName = Metadata.name() + "/" + Metadata.version();
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package me.topchetoeu.jscript.utils.debug;
|
package me.topchetoeu.jscript.utils.debug;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.debug.DebugHandler;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import me.topchetoeu.jscript.runtime.debug.DebugHandler;
|
||||||
|
|
||||||
public interface Debugger extends DebugHandler {
|
public interface Debugger extends DebugHandler {
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
|||||||
@@ -23,19 +23,19 @@ import me.topchetoeu.jscript.common.json.JSONList;
|
|||||||
import me.topchetoeu.jscript.common.json.JSONMap;
|
import me.topchetoeu.jscript.common.json.JSONMap;
|
||||||
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
||||||
import me.topchetoeu.jscript.compilation.parsing.Parsing;
|
import me.topchetoeu.jscript.compilation.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Engine;
|
import me.topchetoeu.jscript.runtime.Engine;
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
import me.topchetoeu.jscript.core.EventLoop;
|
import me.topchetoeu.jscript.runtime.EventLoop;
|
||||||
import me.topchetoeu.jscript.core.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.core.debug.DebugContext;
|
import me.topchetoeu.jscript.runtime.debug.DebugContext;
|
||||||
import me.topchetoeu.jscript.core.scope.GlobalScope;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.ArrayValue;
|
import me.topchetoeu.jscript.runtime.scope.GlobalScope;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.Symbol;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Symbol;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
|
||||||
// very simple indeed
|
// very simple indeed
|
||||||
public class SimpleDebugger implements Debugger {
|
public class SimpleDebugger implements Debugger {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public abstract class BaseFile<T> implements File {
|
|||||||
protected abstract long onSeek(long offset, int pos);
|
protected abstract long onSeek(long offset, int pos);
|
||||||
protected abstract boolean onClose();
|
protected abstract boolean onClose();
|
||||||
|
|
||||||
@Override public int read(byte[] buff) {
|
@Override public synchronized int read(byte[] buff) {
|
||||||
try {
|
try {
|
||||||
if (handle == null) throw new FilesystemException(ErrorReason.CLOSED);
|
if (handle == null) throw new FilesystemException(ErrorReason.CLOSED);
|
||||||
if (!mode.readable) throw new FilesystemException(ErrorReason.NO_PERMISSION, "File not open for reading.");
|
if (!mode.readable) throw new FilesystemException(ErrorReason.NO_PERMISSION, "File not open for reading.");
|
||||||
@@ -21,7 +21,7 @@ public abstract class BaseFile<T> implements File {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setAction(ActionType.READ); }
|
catch (FilesystemException e) { throw e.setAction(ActionType.READ); }
|
||||||
}
|
}
|
||||||
@Override public void write(byte[] buff) {
|
@Override public synchronized void write(byte[] buff) {
|
||||||
try {
|
try {
|
||||||
if (handle == null) throw new FilesystemException(ErrorReason.CLOSED);
|
if (handle == null) throw new FilesystemException(ErrorReason.CLOSED);
|
||||||
if (!mode.writable) throw new FilesystemException(ErrorReason.NO_PERMISSION, "File not open for writting.");
|
if (!mode.writable) throw new FilesystemException(ErrorReason.NO_PERMISSION, "File not open for writting.");
|
||||||
@@ -29,7 +29,7 @@ public abstract class BaseFile<T> implements File {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setAction(ActionType.WRITE); }
|
catch (FilesystemException e) { throw e.setAction(ActionType.WRITE); }
|
||||||
}
|
}
|
||||||
@Override public long seek(long offset, int pos) {
|
@Override public synchronized long seek(long offset, int pos) {
|
||||||
try {
|
try {
|
||||||
if (handle == null) throw new FilesystemException(ErrorReason.CLOSED);
|
if (handle == null) throw new FilesystemException(ErrorReason.CLOSED);
|
||||||
if (!mode.writable) throw new FilesystemException(ErrorReason.NO_PERMISSION, "File not open for seeking.");
|
if (!mode.writable) throw new FilesystemException(ErrorReason.NO_PERMISSION, "File not open for seeking.");
|
||||||
@@ -37,7 +37,7 @@ public abstract class BaseFile<T> implements File {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setAction(ActionType.SEEK); }
|
catch (FilesystemException e) { throw e.setAction(ActionType.SEEK); }
|
||||||
}
|
}
|
||||||
@Override public boolean close() {
|
@Override public synchronized boolean close() {
|
||||||
if (handle != null) {
|
if (handle != null) {
|
||||||
try {
|
try {
|
||||||
var res = onClose();
|
var res = onClose();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public interface File {
|
|||||||
|
|
||||||
public static File ofStream(InputStream str) {
|
public static File ofStream(InputStream str) {
|
||||||
return new File() {
|
return new File() {
|
||||||
@Override public int read(byte[] buff) {
|
@Override public synchronized int read(byte[] buff) {
|
||||||
try {
|
try {
|
||||||
try { return str.read(buff); }
|
try { return str.read(buff); }
|
||||||
catch (NullPointerException e) { throw new FilesystemException(ErrorReason.ILLEGAL_ARGS, e.getMessage()); }
|
catch (NullPointerException e) { throw new FilesystemException(ErrorReason.ILLEGAL_ARGS, e.getMessage()); }
|
||||||
@@ -78,7 +78,7 @@ public interface File {
|
|||||||
}
|
}
|
||||||
public static File ofStream(OutputStream str) {
|
public static File ofStream(OutputStream str) {
|
||||||
return new File() {
|
return new File() {
|
||||||
@Override public void write(byte[] buff) {
|
@Override public synchronized void write(byte[] buff) {
|
||||||
try {
|
try {
|
||||||
try { str.write(buff); }
|
try { str.write(buff); }
|
||||||
catch (NullPointerException e) {throw new FilesystemException(ErrorReason.ILLEGAL_ARGS, e.getMessage()); }
|
catch (NullPointerException e) {throw new FilesystemException(ErrorReason.ILLEGAL_ARGS, e.getMessage()); }
|
||||||
@@ -91,7 +91,7 @@ public interface File {
|
|||||||
public static File ofLineWriter(LineWriter writer) {
|
public static File ofLineWriter(LineWriter writer) {
|
||||||
var buff = new Buffer();
|
var buff = new Buffer();
|
||||||
return new File() {
|
return new File() {
|
||||||
@Override public void write(byte[] val) {
|
@Override public synchronized void write(byte[] val) {
|
||||||
try {
|
try {
|
||||||
if (val == null) throw new FilesystemException(ErrorReason.ILLEGAL_ARGS, "Given buffer is null.");
|
if (val == null) throw new FilesystemException(ErrorReason.ILLEGAL_ARGS, "Given buffer is null.");
|
||||||
|
|
||||||
@@ -99,6 +99,7 @@ public interface File {
|
|||||||
if (b == '\n') {
|
if (b == '\n') {
|
||||||
try {
|
try {
|
||||||
writer.writeLine(new String(buff.data()));
|
writer.writeLine(new String(buff.data()));
|
||||||
|
buff.clear();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new FilesystemException(ErrorReason.UNKNOWN, e.getMessage());
|
throw new FilesystemException(ErrorReason.UNKNOWN, e.getMessage());
|
||||||
@@ -117,7 +118,7 @@ public interface File {
|
|||||||
private byte[] prev = new byte[0];
|
private byte[] prev = new byte[0];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] buff) {
|
public synchronized int read(byte[] buff) {
|
||||||
try {
|
try {
|
||||||
if (buff == null) throw new FilesystemException(ErrorReason.ILLEGAL_ARGS, "Given buffer is null.");
|
if (buff == null) throw new FilesystemException(ErrorReason.ILLEGAL_ARGS, "Given buffer is null.");
|
||||||
var ptr = 0;
|
var ptr = 0;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.utils.filesystem;
|
package me.topchetoeu.jscript.utils.filesystem;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Extensions;
|
import me.topchetoeu.jscript.runtime.Extensions;
|
||||||
import me.topchetoeu.jscript.core.Key;
|
import me.topchetoeu.jscript.runtime.Key;
|
||||||
|
|
||||||
public interface Filesystem {
|
public interface Filesystem {
|
||||||
public static final Key<Filesystem> KEY = new Key<>();
|
public static final Key<Filesystem> KEY = new Key<>();
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package me.topchetoeu.jscript.utils.filesystem;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
|
||||||
public class FilesystemException extends RuntimeException {
|
public class FilesystemException extends RuntimeException {
|
||||||
public final ErrorReason reason;
|
public final ErrorReason reason;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class MemoryFilesystem implements Filesystem {
|
|||||||
@Override public String normalize(String... path) {
|
@Override public String normalize(String... path) {
|
||||||
return Paths.normalize(path);
|
return Paths.normalize(path);
|
||||||
}
|
}
|
||||||
@Override public File open(String _path, Mode perms) {
|
@Override public synchronized File open(String _path, Mode perms) {
|
||||||
try {
|
try {
|
||||||
var path = realPath(_path);
|
var path = realPath(_path);
|
||||||
var pcount = path.getNameCount();
|
var pcount = path.getNameCount();
|
||||||
@@ -47,7 +47,7 @@ public class MemoryFilesystem implements Filesystem {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setPath(_path).setAction(ActionType.OPEN); }
|
catch (FilesystemException e) { throw e.setPath(_path).setAction(ActionType.OPEN); }
|
||||||
}
|
}
|
||||||
@Override public boolean create(String _path, EntryType type) {
|
@Override public synchronized boolean create(String _path, EntryType type) {
|
||||||
try {
|
try {
|
||||||
var path = realPath(_path);
|
var path = realPath(_path);
|
||||||
|
|
||||||
@@ -69,14 +69,14 @@ public class MemoryFilesystem implements Filesystem {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setPath(_path).setAction(ActionType.CREATE); }
|
catch (FilesystemException e) { throw e.setPath(_path).setAction(ActionType.CREATE); }
|
||||||
}
|
}
|
||||||
@Override public FileStat stat(String _path) {
|
@Override public synchronized FileStat stat(String _path) {
|
||||||
var path = realPath(_path);
|
var path = realPath(_path);
|
||||||
|
|
||||||
if (files.containsKey(path)) return new FileStat(mode, EntryType.FILE);
|
if (files.containsKey(path)) return new FileStat(mode, EntryType.FILE);
|
||||||
else if (folders.contains(path)) return new FileStat(mode, EntryType.FOLDER);
|
else if (folders.contains(path)) return new FileStat(mode, EntryType.FOLDER);
|
||||||
else return new FileStat(Mode.NONE, EntryType.NONE);
|
else return new FileStat(Mode.NONE, EntryType.NONE);
|
||||||
}
|
}
|
||||||
@Override public void close() throws FilesystemException {
|
@Override public synchronized void close() throws FilesystemException {
|
||||||
handles.close();
|
handles.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class PhysicalFilesystem implements Filesystem {
|
|||||||
@Override public String normalize(String... paths) {
|
@Override public String normalize(String... paths) {
|
||||||
return Paths.normalize(paths);
|
return Paths.normalize(paths);
|
||||||
}
|
}
|
||||||
@Override public File open(String _path, Mode perms) {
|
@Override public synchronized File open(String _path, Mode perms) {
|
||||||
try {
|
try {
|
||||||
var path = realPath(normalize(_path));
|
var path = realPath(normalize(_path));
|
||||||
checkMode(path, perms);
|
checkMode(path, perms);
|
||||||
@@ -39,7 +39,7 @@ public class PhysicalFilesystem implements Filesystem {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setAction(ActionType.OPEN).setPath(_path); }
|
catch (FilesystemException e) { throw e.setAction(ActionType.OPEN).setPath(_path); }
|
||||||
}
|
}
|
||||||
@Override public boolean create(String _path, EntryType type) {
|
@Override public synchronized boolean create(String _path, EntryType type) {
|
||||||
try {
|
try {
|
||||||
var path = realPath(_path);
|
var path = realPath(_path);
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class PhysicalFilesystem implements Filesystem {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@Override public FileStat stat(String _path) {
|
@Override public synchronized FileStat stat(String _path) {
|
||||||
var path = realPath(_path);
|
var path = realPath(_path);
|
||||||
|
|
||||||
if (!Files.exists(path)) return new FileStat(Mode.NONE, EntryType.NONE);
|
if (!Files.exists(path)) return new FileStat(Mode.NONE, EntryType.NONE);
|
||||||
@@ -82,7 +82,7 @@ public class PhysicalFilesystem implements Filesystem {
|
|||||||
Files.isDirectory(path) ? EntryType.FOLDER : EntryType.FILE
|
Files.isDirectory(path) ? EntryType.FOLDER : EntryType.FILE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@Override public void close() throws FilesystemException {
|
@Override public synchronized void close() throws FilesystemException {
|
||||||
try {
|
try {
|
||||||
handles.close();
|
handles.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,21 @@ import java.util.Map;
|
|||||||
|
|
||||||
import me.topchetoeu.jscript.common.Filename;
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.utils.permissions.Matcher;
|
import me.topchetoeu.jscript.utils.permissions.Matcher;
|
||||||
|
import me.topchetoeu.jscript.utils.permissions.Permission;
|
||||||
import me.topchetoeu.jscript.utils.permissions.PermissionsProvider;
|
import me.topchetoeu.jscript.utils.permissions.PermissionsProvider;
|
||||||
|
|
||||||
public class RootFilesystem implements Filesystem {
|
public class RootFilesystem implements Filesystem {
|
||||||
public final Map<String, Filesystem> protocols = new HashMap<>();
|
public final Map<String, Filesystem> protocols = new HashMap<>();
|
||||||
public final PermissionsProvider perms;
|
public final PermissionsProvider perms;
|
||||||
|
|
||||||
|
public static final Permission PERM_READ = new Permission("jscript.file.read", Matcher.fileWildcard());
|
||||||
|
public static final Permission PERM_WRITE = new Permission("jscript.file.read", Matcher.fileWildcard());
|
||||||
|
|
||||||
private boolean canRead(String _path) {
|
private boolean canRead(String _path) {
|
||||||
return perms.hasPermission("jscript.file.read:" + _path, Matcher.fileWildcard());
|
return perms.hasPermission(PERM_READ, _path);
|
||||||
}
|
}
|
||||||
private boolean canWrite(String _path) {
|
private boolean canWrite(String _path) {
|
||||||
return perms.hasPermission("jscript.file.write:" + _path, Matcher.fileWildcard());
|
return perms.hasPermission(PERM_WRITE, _path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modeAllowed(String _path, Mode mode) throws FilesystemException {
|
private void modeAllowed(String _path, Mode mode) throws FilesystemException {
|
||||||
@@ -49,7 +53,7 @@ public class RootFilesystem implements Filesystem {
|
|||||||
else return filename.protocol + "://" + protocol.normalize(paths);
|
else return filename.protocol + "://" + protocol.normalize(paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override public File open(String path, Mode perms) throws FilesystemException {
|
@Override public synchronized File open(String path, Mode perms) throws FilesystemException {
|
||||||
try {
|
try {
|
||||||
var filename = Filename.parse(path);
|
var filename = Filename.parse(path);
|
||||||
var protocol = getProtocol(filename);
|
var protocol = getProtocol(filename);
|
||||||
@@ -59,7 +63,7 @@ public class RootFilesystem implements Filesystem {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setPath(path).setAction(ActionType.OPEN); }
|
catch (FilesystemException e) { throw e.setPath(path).setAction(ActionType.OPEN); }
|
||||||
}
|
}
|
||||||
@Override public boolean create(String path, EntryType type) throws FilesystemException {
|
@Override public synchronized boolean create(String path, EntryType type) throws FilesystemException {
|
||||||
try {
|
try {
|
||||||
var filename = Filename.parse(path);
|
var filename = Filename.parse(path);
|
||||||
var protocol = getProtocol(filename);
|
var protocol = getProtocol(filename);
|
||||||
@@ -69,7 +73,7 @@ public class RootFilesystem implements Filesystem {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setPath(path).setAction(ActionType.CREATE); }
|
catch (FilesystemException e) { throw e.setPath(path).setAction(ActionType.CREATE); }
|
||||||
}
|
}
|
||||||
@Override public FileStat stat(String path) throws FilesystemException {
|
@Override public synchronized FileStat stat(String path) throws FilesystemException {
|
||||||
try {
|
try {
|
||||||
var filename = Filename.parse(path);
|
var filename = Filename.parse(path);
|
||||||
var protocol = getProtocol(filename);
|
var protocol = getProtocol(filename);
|
||||||
@@ -78,7 +82,7 @@ public class RootFilesystem implements Filesystem {
|
|||||||
}
|
}
|
||||||
catch (FilesystemException e) { throw e.setPath(path).setAction(ActionType.STAT); }
|
catch (FilesystemException e) { throw e.setPath(path).setAction(ActionType.STAT); }
|
||||||
}
|
}
|
||||||
@Override public void close() throws FilesystemException {
|
@Override public synchronized void close() throws FilesystemException {
|
||||||
try {
|
try {
|
||||||
for (var protocol : protocols.values()) {
|
for (var protocol : protocols.values()) {
|
||||||
protocol.close();
|
protocol.close();
|
||||||
|
|||||||
@@ -2,41 +2,51 @@ package me.topchetoeu.jscript.utils.filesystem;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class STDFilesystem implements Filesystem {
|
public class STDFilesystem implements Filesystem {
|
||||||
private final HashMap<String, File> handles = new HashMap<>();
|
private File in;
|
||||||
|
private File out;
|
||||||
|
private File err;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String normalize(String... path) {
|
public String normalize(String... path) {
|
||||||
var res = Paths.normalize(path);
|
var res = Paths.normalize(path);
|
||||||
while (res.startsWith("/")) res = res.substring(1);
|
while (res.startsWith("/")) res = res.substring(1);
|
||||||
|
while (res.endsWith("/")) res = res.substring(0, res.length() - 1);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public File open(String path, Mode mode) {
|
@Override public synchronized File open(String path, Mode mode) {
|
||||||
path = normalize(path);
|
path = normalize(path);
|
||||||
if (handles.containsKey(path)) return handles.get(path);
|
if (in != null && path.equals("in")) return in;
|
||||||
|
else if (out != null && path.equals("out")) return out;
|
||||||
|
else if (err != null && path.equals("err")) return err;
|
||||||
else throw new FilesystemException(ErrorReason.DOESNT_EXIST).setAction(ActionType.OPEN).setPath(path);
|
else throw new FilesystemException(ErrorReason.DOESNT_EXIST).setAction(ActionType.OPEN).setPath(path);
|
||||||
}
|
}
|
||||||
@Override public FileStat stat(String path) {
|
@Override public synchronized FileStat stat(String path) {
|
||||||
path = normalize(path);
|
path = normalize(path);
|
||||||
if (handles.containsKey(path)) return new FileStat(Mode.READ_WRITE, EntryType.FILE);
|
if (path.equals("in") || path.equals("out") || path.equals("err")) return new FileStat(Mode.READ_WRITE, EntryType.FILE);
|
||||||
else return new FileStat(Mode.NONE, EntryType.NONE);
|
else return new FileStat(Mode.NONE, EntryType.NONE);
|
||||||
}
|
}
|
||||||
@Override public void close() {
|
@Override public synchronized void close() {
|
||||||
handles.clear();
|
in = out = err = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public STDFilesystem add(String name, File handle) {
|
public STDFilesystem(File in, File out, File err) {
|
||||||
this.handles.put(name, handle);
|
this.in = in;
|
||||||
return this;
|
this.out = out;
|
||||||
|
this.err = err;
|
||||||
}
|
}
|
||||||
|
public STDFilesystem(InputStream in, OutputStream out, OutputStream err) {
|
||||||
public static STDFilesystem ofStd(InputStream in, OutputStream out, OutputStream err) {
|
if (in != null) this.in = File.ofStream(in);
|
||||||
return new STDFilesystem()
|
if (out != null) this.out = File.ofStream(out);
|
||||||
.add("in", File.ofStream(in))
|
if (err != null) this.err = File.ofStream(err);
|
||||||
.add("out", File.ofStream(out))
|
}
|
||||||
.add("err", File.ofStream(err));
|
public STDFilesystem(LineReader in, LineWriter out) {
|
||||||
|
if (in != null) this.in = File.ofLineReader(in);
|
||||||
|
if (out != null) {
|
||||||
|
this.out = File.ofLineWriter(out);
|
||||||
|
this.err = File.ofLineWriter(out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package me.topchetoeu.jscript.utils.interop;
|
|||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.values.NativeWrapper;
|
import me.topchetoeu.jscript.runtime.values.NativeWrapper;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
|
||||||
public class Arguments {
|
public class Arguments {
|
||||||
public final Object self;
|
public final Object self;
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ import java.util.HashSet;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Location;
|
import me.topchetoeu.jscript.common.Location;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
import me.topchetoeu.jscript.core.WrapperProvider;
|
import me.topchetoeu.jscript.runtime.WrapperProvider;
|
||||||
import me.topchetoeu.jscript.core.values.FunctionValue;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.core.values.NativeFunction;
|
import me.topchetoeu.jscript.runtime.exceptions.InterruptException;
|
||||||
import me.topchetoeu.jscript.core.values.ObjectValue;
|
import me.topchetoeu.jscript.runtime.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.core.values.Symbol;
|
import me.topchetoeu.jscript.runtime.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.core.values.Values;
|
import me.topchetoeu.jscript.runtime.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.values.Symbol;
|
||||||
import me.topchetoeu.jscript.core.exceptions.InterruptException;
|
import me.topchetoeu.jscript.runtime.values.Values;
|
||||||
|
|
||||||
public class NativeWrapperProvider implements WrapperProvider {
|
public class NativeWrapperProvider implements WrapperProvider {
|
||||||
private final HashMap<Class<?>, FunctionValue> constructors = new HashMap<>();
|
private final HashMap<Class<?>, FunctionValue> constructors = new HashMap<>();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.topchetoeu.jscript.utils.modules;
|
package me.topchetoeu.jscript.utils.modules;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
|
|
||||||
public abstract class Module {
|
public abstract class Module {
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package me.topchetoeu.jscript.utils.modules;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Filename;
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Extensions;
|
import me.topchetoeu.jscript.runtime.Extensions;
|
||||||
import me.topchetoeu.jscript.core.Key;
|
import me.topchetoeu.jscript.runtime.Key;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.Filesystem;
|
import me.topchetoeu.jscript.utils.filesystem.Filesystem;
|
||||||
import me.topchetoeu.jscript.utils.filesystem.Mode;
|
import me.topchetoeu.jscript.utils.filesystem.Mode;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package me.topchetoeu.jscript.utils.modules;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
|
||||||
public class RootModuleRepo implements ModuleRepo {
|
public class RootModuleRepo implements ModuleRepo {
|
||||||
public final HashMap<String, ModuleRepo> repos = new HashMap<>();
|
public final HashMap<String, ModuleRepo> repos = new HashMap<>();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package me.topchetoeu.jscript.utils.modules;
|
package me.topchetoeu.jscript.utils.modules;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Filename;
|
import me.topchetoeu.jscript.common.Filename;
|
||||||
import me.topchetoeu.jscript.core.Context;
|
import me.topchetoeu.jscript.runtime.Context;
|
||||||
import me.topchetoeu.jscript.core.Environment;
|
import me.topchetoeu.jscript.runtime.Environment;
|
||||||
|
|
||||||
public class SourceModule extends Module {
|
public class SourceModule extends Module {
|
||||||
public final Filename filename;
|
public final Filename filename;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.topchetoeu.jscript.utils.permissions;
|
package me.topchetoeu.jscript.utils.permissions;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.core.Extensions;
|
import me.topchetoeu.jscript.runtime.Extensions;
|
||||||
import me.topchetoeu.jscript.core.Key;
|
import me.topchetoeu.jscript.runtime.Key;
|
||||||
|
|
||||||
public interface PermissionsProvider {
|
public interface PermissionsProvider {
|
||||||
public static final Key<PermissionsProvider> KEY = new Key<>();
|
public static final Key<PermissionsProvider> KEY = new Key<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user