refactor: split up code in 4 modules

This commit is contained in:
TopchetoEU 2024-01-10 11:21:09 +02:00
parent 5e6e6fea61
commit b791f3277e
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
172 changed files with 983 additions and 934 deletions

5
.gitignore vendored
View File

@ -2,12 +2,15 @@
!/src !/src
!/src/**/* !/src/**/*
/src/assets/js/ts.js /src/assets/js/ts.js
!/doc
!/doc/**/*
!/tests !/tests
!/tests/**/* !/tests/**/*
!/.github !/.github
!/.github/**/* !/.github/**/*

View File

@ -118,7 +118,7 @@ The following is a minified version of the unmodified Typescript 5.2
} }
async function compileJava(conf) { async function compileJava(conf) {
try { try {
await fs.writeFile('Metadata.java', (await fs.readFile('src/me/topchetoeu/jscript/Metadata.java')).toString() await fs.writeFile('Metadata.java', (await fs.readFile('src/me/topchetoeu/jscript/common/Metadata.java')).toString()
.replace('${VERSION}', conf.version) .replace('${VERSION}', conf.version)
.replace('${NAME}', conf.name) .replace('${NAME}', conf.name)
.replace('${AUTHOR}', conf.author) .replace('${AUTHOR}', conf.author)
@ -136,11 +136,22 @@ async function compileJava(conf) {
await fs.rm('Metadata.java'); await fs.rm('Metadata.java');
} }
} }
async function jar(conf, project, mainClass) {
const args = [
'jar', '-c',
'-f', `dst/${project}-v${conf.version}.jar`,
];
if (mainClass) args.push('-e', mainClass);
args.push('-C', 'dst/classes', project.replaceAll('.', '/'));
console.log(args.join(' '));
await run(true, ...args);
}
(async () => { (async () => {
try { try {
if (argv[2] === 'init-ts') { if (argv[2] === 'init-ts') {
await downloadTypescript('src/assets/js/ts.js'); await downloadTypescript('src/me/topchetoeu/jscript/utils/assets/js/ts.js');
} }
else { else {
const conf = { const conf = {
@ -156,12 +167,21 @@ async function compileJava(conf) {
try { await fs.rm('dst', { recursive: true }); } catch {} try { await fs.rm('dst', { recursive: true }); } catch {}
await Promise.all([ await Promise.all([
downloadTypescript('dst/classes/assets/js/ts.js'), (async () => {
copy('src', 'dst/classes', v => !v.endsWith('.java')), await copy('src', 'dst/classes', v => !v.endsWith('.java'));
// await downloadTypescript('dst/classes/me/topchetoeu/jscript/utils/assets/js/ts.js');
})(),
compileJava(conf), compileJava(conf),
]); ]);
await run(true, 'jar', '-c', '-f', 'dst/jscript.jar', '-e', 'me.topchetoeu.jscript.Main', '-C', 'dst/classes', '.'); await Promise.all([
jar(conf, 'me.topchetoeu.jscript.common'),
jar(conf, 'me.topchetoeu.jscript.core'),
jar(conf, 'me.topchetoeu.jscript.lib'),
jar(conf, 'me.topchetoeu.jscript.utils'),
jar(conf, 'me.topchetoeu.jscript', 'me.topchetoeu.jscript.utils.JScriptRepl'),
]);
console.log('Done!'); console.log('Done!');
} }
} }

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript; package me.topchetoeu.jscript.common;
public class Buffer { public class Buffer {
private byte[] data; private byte[] data;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript; package me.topchetoeu.jscript.common;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript; package me.topchetoeu.jscript.common;
public class Location implements Comparable<Location> { public class Location implements Comparable<Location> {
public static final Location INTERNAL = new Location(0, 0, new Filename("jscript", "native")); public static final Location INTERNAL = new Location(0, 0, new Filename("jscript", "native"));

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript; package me.topchetoeu.jscript.common;
public class Metadata { public class Metadata {
private static final String VERSION = "${VERSION}"; private static final String VERSION = "${VERSION}";

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript; package me.topchetoeu.jscript.common;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript; package me.topchetoeu.jscript.common;
public interface ResultRunnable<T> { public interface ResultRunnable<T> {
T run(); T run();

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.events; package me.topchetoeu.jscript.common.events;
public interface Awaitable<T> { public interface Awaitable<T> {
public static interface ResultHandler<T> { public static interface ResultHandler<T> {

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.events; package me.topchetoeu.jscript.common.events;
public class DataNotifier<T> implements Awaitable<T> { public class DataNotifier<T> implements Awaitable<T> {
private Notifier notifier = new Notifier(); private Notifier notifier = new Notifier();

View File

@ -1,6 +1,6 @@
package me.topchetoeu.jscript.events; package me.topchetoeu.jscript.common.events;
import me.topchetoeu.jscript.exceptions.InterruptException; import me.topchetoeu.jscript.core.exceptions.InterruptException;
public class Notifier { public class Notifier {
private boolean ok = false; private boolean ok = false;

View File

@ -1,20 +1,20 @@
package me.topchetoeu.jscript.json; package me.topchetoeu.jscript.common.json;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.topchetoeu.jscript.Filename; import me.topchetoeu.jscript.common.Filename;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.values.ArrayValue; import me.topchetoeu.jscript.core.engine.values.ArrayValue;
import me.topchetoeu.jscript.engine.values.ObjectValue; import me.topchetoeu.jscript.core.engine.values.ObjectValue;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
import me.topchetoeu.jscript.exceptions.SyntaxException; import me.topchetoeu.jscript.core.exceptions.SyntaxException;
import me.topchetoeu.jscript.parsing.Operator; import me.topchetoeu.jscript.core.parsing.Operator;
import me.topchetoeu.jscript.parsing.ParseRes; import me.topchetoeu.jscript.core.parsing.ParseRes;
import me.topchetoeu.jscript.parsing.Parsing; import me.topchetoeu.jscript.core.parsing.Parsing;
import me.topchetoeu.jscript.parsing.Token; import me.topchetoeu.jscript.core.parsing.Token;
public class JSON { public class JSON {
public static Object toJs(JSONElement val) { public static Object toJs(JSONElement val) {

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.json; package me.topchetoeu.jscript.common.json;
public class JSONElement { public class JSONElement {
public static enum Type { public static enum Type {

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.json; package me.topchetoeu.jscript.common.json;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.json; package me.topchetoeu.jscript.common.json;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,7 +1,7 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
public abstract class AssignableStatement extends Statement { public abstract class AssignableStatement extends Statement {
public abstract Statement toAssign(Statement val, Operation operation); public abstract Statement toAssign(Statement val, Operation operation);

View File

@ -1,6 +1,6 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
public final class CalculateResult { public final class CalculateResult {
public final boolean exists; public final boolean exists;

View File

@ -1,14 +1,14 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.Vector; import java.util.Vector;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.Environment; import me.topchetoeu.jscript.core.engine.Environment;
import me.topchetoeu.jscript.engine.values.CodeFunction; import me.topchetoeu.jscript.core.engine.values.CodeFunction;
public class CompileTarget { public class CompileTarget {
public final Vector<Instruction> target = new Vector<>(); public final Vector<Instruction> target = new Vector<>();

View File

@ -1,12 +1,12 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.compilation.values.FunctionStatement; import me.topchetoeu.jscript.core.compilation.values.FunctionStatement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class CompoundStatement extends Statement { public class CompoundStatement extends Statement {
public final Statement[] statements; public final Statement[] statements;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
public class FunctionBody { public class FunctionBody {
public final Instruction[] instructions; public final Instruction[] instructions;

View File

@ -1,8 +1,8 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.exceptions.SyntaxException; import me.topchetoeu.jscript.core.exceptions.SyntaxException;
public class Instruction { public class Instruction {
public static enum Type { public static enum Type {

View File

@ -1,8 +1,8 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public abstract class Statement { public abstract class Statement {
private Location _loc; private Location _loc;

View File

@ -1,7 +1,7 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
import me.topchetoeu.jscript.exceptions.SyntaxException; import me.topchetoeu.jscript.core.exceptions.SyntaxException;
public class ThrowSyntaxStatement extends Statement { public class ThrowSyntaxStatement extends Statement {
public final String name; public final String name;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation; package me.topchetoeu.jscript.core.compilation;
import java.util.List; import java.util.List;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.compilation.values.FunctionStatement; import me.topchetoeu.jscript.core.compilation.values.FunctionStatement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class VariableDeclareStatement extends Statement { public class VariableDeclareStatement extends Statement {
public static class Pair { public static class Pair {

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class BreakStatement extends Statement { public class BreakStatement extends Statement {
public final String label; public final String label;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ContinueStatement extends Statement { public class ContinueStatement extends Statement {
public final String label; public final String label;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class DebugStatement extends Statement { public class DebugStatement extends Statement {
@Override @Override

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class DeleteStatement extends Statement { public class DeleteStatement extends Statement {
public final Statement key; public final Statement key;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class DoWhileStatement extends Statement { public class DoWhileStatement extends Statement {
public final Statement condition, body; public final Statement condition, body;

View File

@ -1,12 +1,12 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ForInStatement extends Statement { public class ForInStatement extends Statement {
public final String varName; public final String varName;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ForStatement extends Statement { public class ForStatement extends Statement {
public final Statement declaration, assignment, condition, body; public final Statement declaration, assignment, condition, body;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class IfStatement extends Statement { public class IfStatement extends Statement {
public final Statement condition, body, elseBody; public final Statement condition, body, elseBody;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ReturnStatement extends Statement { public class ReturnStatement extends Statement {
public final Statement value; public final Statement value;

View File

@ -1,15 +1,15 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import java.util.HashMap; import java.util.HashMap;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.compilation.Instruction.Type; import me.topchetoeu.jscript.core.compilation.Instruction.Type;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class SwitchStatement extends Statement { public class SwitchStatement extends Statement {
public static class SwitchCase { public static class SwitchCase {

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ThrowStatement extends Statement { public class ThrowStatement extends Statement {
public final Statement value; public final Statement value;

View File

@ -1,13 +1,13 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.scope.GlobalScope; import me.topchetoeu.jscript.core.engine.scope.GlobalScope;
import me.topchetoeu.jscript.engine.scope.LocalScopeRecord; import me.topchetoeu.jscript.core.engine.scope.LocalScopeRecord;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class TryStatement extends Statement { public class TryStatement extends Statement {
public final Statement tryBody; public final Statement tryBody;

View File

@ -1,12 +1,12 @@
package me.topchetoeu.jscript.compilation.control; package me.topchetoeu.jscript.core.compilation.control;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.compilation.Instruction.Type; import me.topchetoeu.jscript.core.compilation.Instruction.Type;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class WhileStatement extends Statement { public class WhileStatement extends Statement {
public final Statement condition, body; public final Statement condition, body;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ArrayStatement extends Statement { public class ArrayStatement extends Statement {
public final Statement[] statements; public final Statement[] statements;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class CallStatement extends Statement { public class CallStatement extends Statement {
public final Statement func; public final Statement func;

View File

@ -1,12 +1,12 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.AssignableStatement; import me.topchetoeu.jscript.core.compilation.AssignableStatement;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ChangeStatement extends Statement { public class ChangeStatement extends Statement {
public final AssignableStatement value; public final AssignableStatement value;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ConstantStatement extends Statement { public class ConstantStatement extends Statement {
public final Object value; public final Object value;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class DiscardStatement extends Statement { public class DiscardStatement extends Statement {
public final Statement value; public final Statement value;

View File

@ -1,17 +1,17 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import java.util.Random; import java.util.Random;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.CompoundStatement; import me.topchetoeu.jscript.core.compilation.CompoundStatement;
import me.topchetoeu.jscript.compilation.FunctionBody; import me.topchetoeu.jscript.core.compilation.FunctionBody;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.compilation.Instruction.Type; import me.topchetoeu.jscript.core.compilation.Instruction.Type;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
import me.topchetoeu.jscript.exceptions.SyntaxException; import me.topchetoeu.jscript.core.exceptions.SyntaxException;
public class FunctionStatement extends Statement { public class FunctionStatement extends Statement {
public final CompoundStatement body; public final CompoundStatement body;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class GlobalThisStatement extends Statement { public class GlobalThisStatement extends Statement {
@Override public boolean pure() { return true; } @Override public boolean pure() { return true; }

View File

@ -1,12 +1,12 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class IndexAssignStatement extends Statement { public class IndexAssignStatement extends Statement {
public final Statement object; public final Statement object;

View File

@ -1,13 +1,13 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.AssignableStatement; import me.topchetoeu.jscript.core.compilation.AssignableStatement;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType; import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class IndexStatement extends AssignableStatement { public class IndexStatement extends AssignableStatement {
public final Statement object; public final Statement object;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
public class LazyAndStatement extends Statement { public class LazyAndStatement extends Statement {
public final Statement first, second; public final Statement first, second;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
public class LazyOrStatement extends Statement { public class LazyOrStatement extends Statement {
public final Statement first, second; public final Statement first, second;

View File

@ -1,13 +1,13 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class ObjectStatement extends Statement { public class ObjectStatement extends Statement {
public final Map<Object, Statement> map; public final Map<Object, Statement> map;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class OperationStatement extends Statement { public class OperationStatement extends Statement {
public final Statement[] args; public final Statement[] args;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class RegexStatement extends Statement { public class RegexStatement extends Statement {
public final String pattern, flags; public final String pattern, flags;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class TypeofStatement extends Statement { public class TypeofStatement extends Statement {
public final Statement value; public final Statement value;

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class VariableAssignStatement extends Statement { public class VariableAssignStatement extends Statement {
public final String name; public final String name;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class VariableIndexStatement extends Statement { public class VariableIndexStatement extends Statement {
public final int index; public final int index;

View File

@ -1,12 +1,12 @@
package me.topchetoeu.jscript.compilation.values; package me.topchetoeu.jscript.core.compilation.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.AssignableStatement; import me.topchetoeu.jscript.core.compilation.AssignableStatement;
import me.topchetoeu.jscript.compilation.CompileTarget; import me.topchetoeu.jscript.core.compilation.CompileTarget;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.compilation.Statement; import me.topchetoeu.jscript.core.compilation.Statement;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ScopeRecord; import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
public class VariableStatement extends AssignableStatement { public class VariableStatement extends AssignableStatement {
public final String name; public final String name;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine; package me.topchetoeu.jscript.core.engine;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -9,17 +9,17 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
import me.topchetoeu.jscript.Filename; import me.topchetoeu.jscript.common.Filename;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.engine.debug.DebugContext; import me.topchetoeu.jscript.core.engine.debug.DebugContext;
import me.topchetoeu.jscript.engine.frame.CodeFrame; import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
import me.topchetoeu.jscript.engine.values.ArrayValue; import me.topchetoeu.jscript.core.engine.values.ArrayValue;
import me.topchetoeu.jscript.engine.values.FunctionValue; import me.topchetoeu.jscript.core.engine.values.FunctionValue;
import me.topchetoeu.jscript.engine.values.Symbol; import me.topchetoeu.jscript.core.engine.values.Symbol;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
import me.topchetoeu.jscript.lib.EnvironmentLib; import me.topchetoeu.jscript.lib.EnvironmentLib;
import me.topchetoeu.jscript.mapping.SourceMap; import me.topchetoeu.jscript.utils.mapping.SourceMap;
public class Context implements Extensions { public class Context implements Extensions {
public static final Context NULL = new Context(null); public static final Context NULL = new Context(null);

View File

@ -1,12 +1,12 @@
package me.topchetoeu.jscript.engine; package me.topchetoeu.jscript.core.engine;
import java.util.HashMap; import java.util.HashMap;
import me.topchetoeu.jscript.Filename; import me.topchetoeu.jscript.common.Filename;
import me.topchetoeu.jscript.compilation.FunctionBody; import me.topchetoeu.jscript.common.events.Awaitable;
import me.topchetoeu.jscript.engine.values.FunctionValue; import me.topchetoeu.jscript.core.compilation.FunctionBody;
import me.topchetoeu.jscript.engine.values.Symbol; import me.topchetoeu.jscript.core.engine.values.FunctionValue;
import me.topchetoeu.jscript.events.Awaitable; import me.topchetoeu.jscript.core.engine.values.Symbol;
public class Engine extends EventLoop implements Extensions { public class Engine extends EventLoop implements Extensions {
public static final HashMap<Long, FunctionBody> functions = new HashMap<>(); public static final HashMap<Long, FunctionBody> functions = new HashMap<>();

View File

@ -1,21 +1,21 @@
package me.topchetoeu.jscript.engine; package me.topchetoeu.jscript.core.engine;
import java.util.HashMap; import java.util.HashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.topchetoeu.jscript.Filename; import me.topchetoeu.jscript.common.Filename;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.engine.debug.DebugContext; import me.topchetoeu.jscript.core.engine.debug.DebugContext;
import me.topchetoeu.jscript.engine.scope.GlobalScope; import me.topchetoeu.jscript.core.engine.scope.GlobalScope;
import me.topchetoeu.jscript.engine.values.ArrayValue; import me.topchetoeu.jscript.core.engine.values.ArrayValue;
import me.topchetoeu.jscript.engine.values.FunctionValue; import me.topchetoeu.jscript.core.engine.values.FunctionValue;
import me.topchetoeu.jscript.engine.values.NativeFunction; import me.topchetoeu.jscript.core.engine.values.NativeFunction;
import me.topchetoeu.jscript.engine.values.ObjectValue; import me.topchetoeu.jscript.core.engine.values.ObjectValue;
import me.topchetoeu.jscript.engine.values.Symbol; import me.topchetoeu.jscript.core.engine.values.Symbol;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
import me.topchetoeu.jscript.interop.NativeWrapperProvider; import me.topchetoeu.jscript.core.parsing.Parsing;
import me.topchetoeu.jscript.parsing.Parsing; import me.topchetoeu.jscript.utils.interop.NativeWrapperProvider;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class Environment implements Extensions { public class Environment implements Extensions {
@ -45,7 +45,7 @@ public class Environment implements Extensions {
private HashMap<Symbol, Object> data = new HashMap<>(); private HashMap<Symbol, Object> data = new HashMap<>();
public GlobalScope global; public GlobalScope global;
public WrappersProvider wrappers; public WrapperProvider wrappers;
@Override public <T> void add(Symbol key, T obj) { @Override public <T> void add(Symbol key, T obj) {
data.put(key, obj); data.put(key, obj);
@ -115,7 +115,7 @@ public class Environment implements Extensions {
return new Context(engine, this); return new Context(engine, this);
} }
public Environment(WrappersProvider nativeConverter, GlobalScope global) { public Environment(WrapperProvider nativeConverter, GlobalScope global) {
if (nativeConverter == null) nativeConverter = new NativeWrapperProvider(this); if (nativeConverter == null) nativeConverter = new NativeWrapperProvider(this);
if (global == null) global = new GlobalScope(); if (global == null) global = new GlobalScope();

View File

@ -1,11 +1,11 @@
package me.topchetoeu.jscript.engine; package me.topchetoeu.jscript.core.engine;
import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.PriorityBlockingQueue;
import me.topchetoeu.jscript.ResultRunnable; import me.topchetoeu.jscript.common.ResultRunnable;
import me.topchetoeu.jscript.events.Awaitable; import me.topchetoeu.jscript.common.events.Awaitable;
import me.topchetoeu.jscript.events.DataNotifier; import me.topchetoeu.jscript.common.events.DataNotifier;
import me.topchetoeu.jscript.exceptions.InterruptException; import me.topchetoeu.jscript.core.exceptions.InterruptException;
public class EventLoop { public class EventLoop {
private static class Task implements Comparable<Task> { private static class Task implements Comparable<Task> {

View File

@ -1,6 +1,6 @@
package me.topchetoeu.jscript.engine; package me.topchetoeu.jscript.core.engine;
import me.topchetoeu.jscript.engine.values.Symbol; import me.topchetoeu.jscript.core.engine.values.Symbol;
public interface Extensions { public interface Extensions {
<T> T get(Symbol key); <T> T get(Symbol key);

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine; package me.topchetoeu.jscript.core.engine;
public enum Operation { public enum Operation {
INSTANCEOF(2, false), INSTANCEOF(2, false),

View File

@ -0,0 +1,12 @@
package me.topchetoeu.jscript.core.engine;
import me.topchetoeu.jscript.core.engine.values.FunctionValue;
import me.topchetoeu.jscript.core.engine.values.ObjectValue;
public interface WrapperProvider {
public ObjectValue getProto(Class<?> obj);
public ObjectValue getNamespace(Class<?> obj);
public FunctionValue getConstr(Class<?> obj);
public WrapperProvider fork(Environment env);
}

View File

@ -1,17 +1,17 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import java.util.HashMap; import java.util.HashMap;
import java.util.TreeSet; import java.util.TreeSet;
import me.topchetoeu.jscript.Filename; import me.topchetoeu.jscript.common.Filename;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.Extensions; import me.topchetoeu.jscript.core.engine.Extensions;
import me.topchetoeu.jscript.engine.frame.CodeFrame; import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
import me.topchetoeu.jscript.engine.values.Symbol; import me.topchetoeu.jscript.core.engine.values.Symbol;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
import me.topchetoeu.jscript.mapping.SourceMap; import me.topchetoeu.jscript.utils.mapping.SourceMap;
public class DebugContext implements DebugController { public class DebugContext implements DebugController {
public static final Symbol ENV_KEY = Symbol.get("Engine.debug"); public static final Symbol ENV_KEY = Symbol.get("Engine.debug");

View File

@ -1,14 +1,14 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import java.util.TreeSet; import java.util.TreeSet;
import me.topchetoeu.jscript.Filename; import me.topchetoeu.jscript.common.Filename;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.frame.CodeFrame; import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
import me.topchetoeu.jscript.mapping.SourceMap; import me.topchetoeu.jscript.utils.mapping.SourceMap;
public interface DebugController { public interface DebugController {
/** /**

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import java.io.IOException; import java.io.IOException;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
@ -9,14 +9,14 @@ import java.security.MessageDigest;
import java.util.Base64; import java.util.Base64;
import java.util.HashMap; import java.util.HashMap;
import me.topchetoeu.jscript.Metadata; import me.topchetoeu.jscript.common.Metadata;
import me.topchetoeu.jscript.Reading; import me.topchetoeu.jscript.common.Reading;
import me.topchetoeu.jscript.engine.debug.WebSocketMessage.Type; import me.topchetoeu.jscript.common.events.Notifier;
import me.topchetoeu.jscript.events.Notifier; import me.topchetoeu.jscript.common.json.JSON;
import me.topchetoeu.jscript.exceptions.SyntaxException; import me.topchetoeu.jscript.common.json.JSONList;
import me.topchetoeu.jscript.json.JSON; import me.topchetoeu.jscript.common.json.JSONMap;
import me.topchetoeu.jscript.json.JSONList; import me.topchetoeu.jscript.core.engine.debug.WebSocketMessage.Type;
import me.topchetoeu.jscript.json.JSONMap; 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();
@ -226,9 +226,9 @@ public class DebugServer {
public DebugServer() { public DebugServer() {
try { try {
this.favicon = Reading.resourceToStream("assets/debugger/favicon.png").readAllBytes(); this.favicon = Reading.resourceToStream("me/topchetoeu/jscript/utils/assets/debugger/favicon.png").readAllBytes();
this.protocol = Reading.resourceToStream("assets/debugger/protocol.json").readAllBytes(); this.protocol = Reading.resourceToStream("me/topchetoeu/jscript/utils/assets/debugger/protocol.json").readAllBytes();
this.index = Reading.resourceToString("assets/debugger/index.html") this.index = Reading.resourceToString("me/topchetoeu/jscript/utils/assets/debugger/index.html")
.replace("${NAME}", Metadata.name()) .replace("${NAME}", Metadata.name())
.replace("${VERSION}", Metadata.version()) .replace("${VERSION}", Metadata.version())
.replace("${AUTHOR}", Metadata.author()) .replace("${AUTHOR}", Metadata.author())

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
public interface Debugger extends DebugHandler, DebugController { public interface Debugger extends DebugHandler, DebugController {
void close(); void close();

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
public interface DebuggerProvider { public interface DebuggerProvider {
Debugger getDebugger(WebSocket socket, HttpRequest req); Debugger getDebugger(WebSocket socket, HttpRequest req);

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,29 +10,29 @@ import java.util.TreeSet;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.topchetoeu.jscript.Filename; import me.topchetoeu.jscript.common.Filename;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.common.events.Notifier;
import me.topchetoeu.jscript.compilation.Instruction.Type; import me.topchetoeu.jscript.common.json.JSON;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.common.json.JSONElement;
import me.topchetoeu.jscript.engine.Engine; import me.topchetoeu.jscript.common.json.JSONList;
import me.topchetoeu.jscript.engine.Environment; import me.topchetoeu.jscript.common.json.JSONMap;
import me.topchetoeu.jscript.engine.frame.CodeFrame; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.engine.scope.GlobalScope; import me.topchetoeu.jscript.core.compilation.Instruction.Type;
import me.topchetoeu.jscript.engine.values.ArrayValue; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.values.CodeFunction; import me.topchetoeu.jscript.core.engine.Engine;
import me.topchetoeu.jscript.engine.values.FunctionValue; import me.topchetoeu.jscript.core.engine.Environment;
import me.topchetoeu.jscript.engine.values.ObjectValue; import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
import me.topchetoeu.jscript.engine.values.Symbol; import me.topchetoeu.jscript.core.engine.scope.GlobalScope;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.ArrayValue;
import me.topchetoeu.jscript.events.Notifier; import me.topchetoeu.jscript.core.engine.values.CodeFunction;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.engine.values.FunctionValue;
import me.topchetoeu.jscript.json.JSON; import me.topchetoeu.jscript.core.engine.values.ObjectValue;
import me.topchetoeu.jscript.json.JSONElement; import me.topchetoeu.jscript.core.engine.values.Symbol;
import me.topchetoeu.jscript.json.JSONList; import me.topchetoeu.jscript.core.engine.values.Values;
import me.topchetoeu.jscript.json.JSONMap; import me.topchetoeu.jscript.core.exceptions.EngineException;
import me.topchetoeu.jscript.mapping.SourceMap; import me.topchetoeu.jscript.core.parsing.Parsing;
import me.topchetoeu.jscript.parsing.Parsing; import me.topchetoeu.jscript.utils.mapping.SourceMap;
// very simple indeed // very simple indeed
public class SimpleDebugger implements Debugger { public class SimpleDebugger implements Debugger {

View File

@ -1,7 +1,7 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import me.topchetoeu.jscript.json.JSON; import me.topchetoeu.jscript.common.json.JSON;
import me.topchetoeu.jscript.json.JSONMap; import me.topchetoeu.jscript.common.json.JSONMap;
public class V8Error { public class V8Error {
public final String message; public final String message;

View File

@ -1,7 +1,7 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import me.topchetoeu.jscript.json.JSON; import me.topchetoeu.jscript.common.json.JSON;
import me.topchetoeu.jscript.json.JSONMap; import me.topchetoeu.jscript.common.json.JSONMap;
public class V8Event { public class V8Event {
public final String name; public final String name;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import java.util.Map; import java.util.Map;
import me.topchetoeu.jscript.json.JSON; import me.topchetoeu.jscript.common.json.JSON;
import me.topchetoeu.jscript.json.JSONElement; import me.topchetoeu.jscript.common.json.JSONElement;
import me.topchetoeu.jscript.json.JSONMap; import me.topchetoeu.jscript.common.json.JSONMap;
public class V8Message { public class V8Message {
public final String name; public final String name;

View File

@ -1,7 +1,7 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import me.topchetoeu.jscript.json.JSON; import me.topchetoeu.jscript.common.json.JSON;
import me.topchetoeu.jscript.json.JSONMap; import me.topchetoeu.jscript.common.json.JSONMap;
public class V8Result { public class V8Result {
public final int id; public final int id;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -6,7 +6,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
import me.topchetoeu.jscript.engine.debug.WebSocketMessage.Type; import me.topchetoeu.jscript.core.engine.debug.WebSocketMessage.Type;
public class WebSocket implements AutoCloseable { public class WebSocket implements AutoCloseable {
public long maxLength = 1 << 20; public long maxLength = 1 << 20;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.debug; package me.topchetoeu.jscript.core.engine.debug;
public class WebSocketMessage { public class WebSocketMessage {
public static enum Type { public static enum Type {

View File

@ -1,21 +1,21 @@
package me.topchetoeu.jscript.engine.frame; package me.topchetoeu.jscript.core.engine.frame;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.debug.DebugContext; import me.topchetoeu.jscript.core.engine.debug.DebugContext;
import me.topchetoeu.jscript.engine.scope.LocalScope; import me.topchetoeu.jscript.core.engine.scope.LocalScope;
import me.topchetoeu.jscript.engine.scope.ValueVariable; import me.topchetoeu.jscript.core.engine.scope.ValueVariable;
import me.topchetoeu.jscript.engine.values.ArrayValue; import me.topchetoeu.jscript.core.engine.values.ArrayValue;
import me.topchetoeu.jscript.engine.values.CodeFunction; import me.topchetoeu.jscript.core.engine.values.CodeFunction;
import me.topchetoeu.jscript.engine.values.ObjectValue; import me.topchetoeu.jscript.core.engine.values.ObjectValue;
import me.topchetoeu.jscript.engine.values.ScopeValue; import me.topchetoeu.jscript.core.engine.values.ScopeValue;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
import me.topchetoeu.jscript.exceptions.InterruptException; import me.topchetoeu.jscript.core.exceptions.InterruptException;
public class CodeFrame { public class CodeFrame {
public static enum TryState { public static enum TryState {

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.frame; package me.topchetoeu.jscript.core.engine.frame;
public enum ConvertHint { public enum ConvertHint {
TOSTRING, TOSTRING,

View File

@ -1,20 +1,20 @@
package me.topchetoeu.jscript.engine.frame; package me.topchetoeu.jscript.core.engine.frame;
import java.util.Collections; import java.util.Collections;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.Engine; import me.topchetoeu.jscript.core.engine.Engine;
import me.topchetoeu.jscript.engine.Environment; import me.topchetoeu.jscript.core.engine.Environment;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.scope.ValueVariable; import me.topchetoeu.jscript.core.engine.scope.ValueVariable;
import me.topchetoeu.jscript.engine.values.ArrayValue; import me.topchetoeu.jscript.core.engine.values.ArrayValue;
import me.topchetoeu.jscript.engine.values.CodeFunction; import me.topchetoeu.jscript.core.engine.values.CodeFunction;
import me.topchetoeu.jscript.engine.values.FunctionValue; import me.topchetoeu.jscript.core.engine.values.FunctionValue;
import me.topchetoeu.jscript.engine.values.ObjectValue; import me.topchetoeu.jscript.core.engine.values.ObjectValue;
import me.topchetoeu.jscript.engine.values.Symbol; import me.topchetoeu.jscript.core.engine.values.Symbol;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
public class Runners { public class Runners {
public static Object execReturn(Context ctx, Instruction instr, CodeFrame frame) { public static Object execReturn(Context ctx, Instruction instr, CodeFrame frame) {

View File

@ -1,14 +1,14 @@
package me.topchetoeu.jscript.engine.scope; package me.topchetoeu.jscript.core.engine.scope;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.values.FunctionValue; import me.topchetoeu.jscript.core.engine.values.FunctionValue;
import me.topchetoeu.jscript.engine.values.NativeFunction; import me.topchetoeu.jscript.core.engine.values.NativeFunction;
import me.topchetoeu.jscript.engine.values.ObjectValue; import me.topchetoeu.jscript.core.engine.values.ObjectValue;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
public class GlobalScope implements ScopeRecord { public class GlobalScope implements ScopeRecord {
public final ObjectValue obj; public final ObjectValue obj;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.scope; package me.topchetoeu.jscript.core.engine.scope;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.scope; package me.topchetoeu.jscript.core.engine.scope;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.scope; package me.topchetoeu.jscript.core.engine.scope;
public interface ScopeRecord { public interface ScopeRecord {
public Object getKey(String name); public Object getKey(String name);

View File

@ -1,7 +1,7 @@
package me.topchetoeu.jscript.engine.scope; package me.topchetoeu.jscript.core.engine.scope;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
public class ValueVariable implements Variable { public class ValueVariable implements Variable {
public boolean readonly; public boolean readonly;

View File

@ -1,6 +1,6 @@
package me.topchetoeu.jscript.engine.scope; package me.topchetoeu.jscript.core.engine.scope;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
public interface Variable { public interface Variable {
Object get(Context ctx); Object get(Context ctx);

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.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.engine.Context; import me.topchetoeu.jscript.core.engine.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> {

View File

@ -1,12 +1,12 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.values;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.compilation.FunctionBody; import me.topchetoeu.jscript.core.compilation.FunctionBody;
import me.topchetoeu.jscript.compilation.Instruction; import me.topchetoeu.jscript.core.compilation.Instruction;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.Environment; import me.topchetoeu.jscript.core.engine.Environment;
import me.topchetoeu.jscript.engine.frame.CodeFrame; import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
import me.topchetoeu.jscript.engine.scope.ValueVariable; import me.topchetoeu.jscript.core.engine.scope.ValueVariable;
public class CodeFunction extends FunctionValue { public class CodeFunction extends FunctionValue {
public final int localsN; public final int localsN;

View File

@ -1,8 +1,8 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.values;
import java.util.List; import java.util.List;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
public abstract class FunctionValue extends ObjectValue { public abstract class FunctionValue extends ObjectValue {
public String name = ""; public String name = "";

View File

@ -1,7 +1,7 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.values;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.interop.Arguments; import me.topchetoeu.jscript.utils.interop.Arguments;
public class NativeFunction extends FunctionValue { public class NativeFunction extends FunctionValue {
public static interface NativeFunctionRunner { public static interface NativeFunctionRunner {

View File

@ -1,6 +1,6 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.values;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.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();

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.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.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.Environment; import me.topchetoeu.jscript.core.engine.Environment;
public class ObjectValue { public class ObjectValue {
public static enum PlaceholderProto { public static enum PlaceholderProto {

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.values;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.scope.ValueVariable; import me.topchetoeu.jscript.core.engine.scope.ValueVariable;
public class ScopeValue extends ObjectValue { public class ScopeValue extends ObjectValue {
public final ValueVariable[] variables; public final ValueVariable[] variables;
@ -23,7 +23,7 @@ public class ScopeValue extends ObjectValue {
} }
var proto = getPrototype(ctx); var proto = getPrototype(ctx);
if (proto != null && proto.hasField(ctx, key) && proto.setField(ctx, key, val)) return true; if (proto != null && proto.hasMember(ctx, key, false) && proto.setField(ctx, key, val)) return true;
return super.setField(ctx, key, val); return super.setField(ctx, key, val);
} }

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.values;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,5 +1,7 @@
package me.topchetoeu.jscript.engine.values; package me.topchetoeu.jscript.core.engine.values;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,13 +12,13 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.Environment; import me.topchetoeu.jscript.core.engine.Environment;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
import me.topchetoeu.jscript.engine.frame.ConvertHint; import me.topchetoeu.jscript.core.engine.frame.ConvertHint;
import me.topchetoeu.jscript.exceptions.ConvertException; import me.topchetoeu.jscript.core.exceptions.ConvertException;
import me.topchetoeu.jscript.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.EngineException;
import me.topchetoeu.jscript.exceptions.SyntaxException; import me.topchetoeu.jscript.core.exceptions.SyntaxException;
import me.topchetoeu.jscript.lib.PromiseLib; import me.topchetoeu.jscript.lib.PromiseLib;
public class Values { public class Values {
@ -663,104 +665,107 @@ public class Values {
if (protoObj.values.size() + protoObj.properties.size() != 1) return false; if (protoObj.values.size() + protoObj.properties.size() != 1) return false;
return true; return true;
} }
private static void printValue(Context ctx, Object val, HashSet<Object> passed, int tab) { private static String toReadable(Context ctx, Object val, HashSet<Object> passed, int tab) {
if (tab == 0 && val instanceof String) { if (tab == 0 && val instanceof String) return (String)val;
System.out.print(val);
return;
}
if (passed.contains(val)) { if (passed.contains(val)) return "[circular]";
System.out.print("[circular]");
return;
}
var printed = true; var printed = true;
var res = new StringBuilder();
if (val instanceof FunctionValue) { if (val instanceof FunctionValue) {
System.out.print(val.toString()); res.append(val.toString());
var loc = val instanceof CodeFunction ? ((CodeFunction)val).loc() : null; var loc = val instanceof CodeFunction ? ((CodeFunction)val).loc() : null;
if (loc != null) System.out.print(" @ " + loc); if (loc != null) res.append(" @ " + loc);
} }
else if (val instanceof ArrayValue) { else if (val instanceof ArrayValue) {
System.out.print("["); res.append("[");
var obj = ((ArrayValue)val); var obj = ((ArrayValue)val);
for (int i = 0; i < obj.size(); i++) { for (int i = 0; i < obj.size(); i++) {
if (i != 0) System.out.print(", "); if (i != 0) res.append(", ");
else System.out.print(" "); else res.append(" ");
if (obj.has(i)) printValue(ctx, obj.get(i), passed, tab); if (obj.has(i)) res.append(toReadable(ctx, obj.get(i), passed, tab));
else System.out.print("<empty>"); else res.append("<empty>");
} }
System.out.print(" ] "); res.append(" ] ");
} }
else if (val instanceof NativeWrapper) { else if (val instanceof NativeWrapper) {
var obj = ((NativeWrapper)val).wrapped; var obj = ((NativeWrapper)val).wrapped;
System.out.print("Native " + obj.toString() + " "); res.append("Native " + obj.toString() + " ");
} }
else printed = false; else printed = false;
if (val instanceof ObjectValue) { if (val instanceof ObjectValue) {
if (tab > 3) { if (tab > 3) {
System.out.print("{...}"); return "{...}";
return;
} }
passed.add(val); passed.add(val);
var obj = (ObjectValue)val; var obj = (ObjectValue)val;
if (obj.values.size() + obj.properties.size() == 0 || isEmptyFunc(obj)) { if (obj.values.size() + obj.properties.size() == 0 || isEmptyFunc(obj)) {
if (!printed) System.out.println("{}"); if (!printed) res.append("{}\n");
} }
else { else {
System.out.println("{"); res.append("{\n");
for (var el : obj.values.entrySet()) { for (var el : obj.values.entrySet()) {
for (int i = 0; i < tab + 1; i++) System.out.print(" "); for (int i = 0; i < tab + 1; i++) System.out.print(" ");
printValue(ctx, el.getKey(), passed, tab + 1); res.append(toReadable(ctx, el.getKey(), passed, tab + 1));
System.out.print(": "); res.append(": ");
printValue(ctx, el.getValue(), passed, tab + 1); res.append(toReadable(ctx, el.getValue(), passed, tab + 1));
System.out.println(","); res.append(",\n");
} }
for (var el : obj.properties.entrySet()) { for (var el : obj.properties.entrySet()) {
for (int i = 0; i < tab + 1; i++) System.out.print(" "); for (int i = 0; i < tab + 1; i++) System.out.print(" ");
printValue(ctx, el.getKey(), passed, tab + 1); res.append(toReadable(ctx, el.getKey(), passed, tab + 1));
System.out.println(": [prop],"); res.append(": [prop],\n");
} }
for (int i = 0; i < tab; i++) System.out.print(" "); for (int i = 0; i < tab; i++) res.append(" ");
System.out.print("}"); res.append("}");
} }
passed.remove(val); passed.remove(val);
} }
else if (val == null) System.out.print("undefined"); else if (val == null) return "undefined";
else if (val == Values.NULL) System.out.print("null"); else if (val == Values.NULL) return "null";
else if (val instanceof String) System.out.print("'" + val + "'"); else if (val instanceof String) return "'" + val + "'";
else System.out.print(Values.toString(ctx, val)); else return Values.toString(ctx, val);
return res.toString();
} }
public static void printValue(Context ctx, Object val) {
printValue(ctx, val, new HashSet<>(), 0); public static String toReadable(Context ctx, Object val) {
return toReadable(ctx, val, new HashSet<>(), 0);
} }
public static void printError(RuntimeException err, String prefix) { public static String errorToReadable(RuntimeException err, String prefix) {
prefix = prefix == null ? "Uncaught" : "Uncaught " + prefix; prefix = prefix == null ? "Uncaught" : "Uncaught " + prefix;
try {
if (err instanceof EngineException) { if (err instanceof EngineException) {
var ee = ((EngineException)err); var ee = ((EngineException)err);
System.out.println(prefix + " " + ee.toString(new Context(ee.engine, ee.env))); try {
} return prefix + " " + ee.toString(new Context(ee.engine, ee.env));
else if (err instanceof SyntaxException) {
System.out.println("Syntax error:" + ((SyntaxException)err).msg);
}
else if (err.getCause() instanceof InterruptedException) return;
else {
System.out.println("Internal error ocurred:");
err.printStackTrace();
}
} }
catch (EngineException ex) { catch (EngineException ex) {
System.out.println("Uncaught "); return prefix + " " + toReadable(new Context(ee.engine, ee.env), ee.value);
Values.printValue(null, ((EngineException)err).value);
System.out.println();
} }
} }
else if (err instanceof SyntaxException) {
return prefix + " SyntaxError " + ((SyntaxException)err).msg;
}
else if (err.getCause() instanceof InterruptedException) return "";
else {
var str = new ByteArrayOutputStream();
err.printStackTrace(new PrintStream(str));
return prefix + " internal error " + str.toString();
}
}
public static void printValue(Context ctx, Object val) {
System.out.print(toReadable(ctx, val));
}
public static void printError(RuntimeException err, String prefix) {
System.out.println(errorToReadable(err, prefix));
}
} }

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.exceptions; package me.topchetoeu.jscript.core.exceptions;
public class ConvertException extends RuntimeException { public class ConvertException extends RuntimeException {
public final String source, target; public final String source, target;

View File

@ -1,16 +1,16 @@
package me.topchetoeu.jscript.exceptions; package me.topchetoeu.jscript.core.exceptions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.core.engine.Context;
import me.topchetoeu.jscript.engine.Engine; import me.topchetoeu.jscript.core.engine.Engine;
import me.topchetoeu.jscript.engine.Environment; import me.topchetoeu.jscript.core.engine.Environment;
import me.topchetoeu.jscript.engine.debug.DebugContext; import me.topchetoeu.jscript.core.engine.debug.DebugContext;
import me.topchetoeu.jscript.engine.values.ObjectValue; import me.topchetoeu.jscript.core.engine.values.ObjectValue;
import me.topchetoeu.jscript.engine.values.Values; import me.topchetoeu.jscript.core.engine.values.Values;
import me.topchetoeu.jscript.engine.values.ObjectValue.PlaceholderProto; import me.topchetoeu.jscript.core.engine.values.ObjectValue.PlaceholderProto;
public class EngineException extends RuntimeException { public class EngineException extends RuntimeException {
public static class StackElement { public static class StackElement {

View File

@ -1,4 +1,4 @@
package me.topchetoeu.jscript.exceptions; package me.topchetoeu.jscript.core.exceptions;
public class InterruptException extends RuntimeException { public class InterruptException extends RuntimeException {
public InterruptException() { } public InterruptException() { }

View File

@ -1,6 +1,6 @@
package me.topchetoeu.jscript.exceptions; package me.topchetoeu.jscript.core.exceptions;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
public class SyntaxException extends RuntimeException { public class SyntaxException extends RuntimeException {
public final Location loc; public final Location loc;

View File

@ -1,9 +1,9 @@
package me.topchetoeu.jscript.parsing; package me.topchetoeu.jscript.core.parsing;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import me.topchetoeu.jscript.engine.Operation; import me.topchetoeu.jscript.core.engine.Operation;
public enum Operator { public enum Operator {
MULTIPLY("*", Operation.MULTIPLY, 13), MULTIPLY("*", Operation.MULTIPLY, 13),

View File

@ -1,10 +1,10 @@
package me.topchetoeu.jscript.parsing; package me.topchetoeu.jscript.core.parsing;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.common.Location;
import me.topchetoeu.jscript.parsing.Parsing.Parser; import me.topchetoeu.jscript.core.parsing.Parsing.Parser;
public class ParseRes<T> { public class ParseRes<T> {
public static enum State { public static enum State {

Some files were not shown because too many files have changed in this diff Show More