Compare commits
2 Commits
master
...
TopchetoEU
Author | SHA1 | Date | |
---|---|---|---|
b791f3277e | |||
5e6e6fea61 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -2,12 +2,15 @@
|
||||
|
||||
!/src
|
||||
!/src/**/*
|
||||
|
||||
/src/assets/js/ts.js
|
||||
|
||||
!/doc
|
||||
!/doc/**/*
|
||||
|
||||
!/tests
|
||||
!/tests/**/*
|
||||
|
||||
|
||||
!/.github
|
||||
!/.github/**/*
|
||||
|
||||
|
30
build.js
30
build.js
@ -118,7 +118,7 @@ The following is a minified version of the unmodified Typescript 5.2
|
||||
}
|
||||
async function compileJava(conf) {
|
||||
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('${NAME}', conf.name)
|
||||
.replace('${AUTHOR}', conf.author)
|
||||
@ -136,11 +136,22 @@ async function compileJava(conf) {
|
||||
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 () => {
|
||||
try {
|
||||
if (argv[2] === 'init-ts') {
|
||||
await downloadTypescript('src/assets/js/ts.js');
|
||||
await downloadTypescript('src/me/topchetoeu/jscript/utils/assets/js/ts.js');
|
||||
}
|
||||
else {
|
||||
const conf = {
|
||||
@ -156,12 +167,21 @@ async function compileJava(conf) {
|
||||
try { await fs.rm('dst', { recursive: true }); } catch {}
|
||||
|
||||
await Promise.all([
|
||||
downloadTypescript('dst/classes/assets/js/ts.js'),
|
||||
copy('src', 'dst/classes', v => !v.endsWith('.java')),
|
||||
(async () => {
|
||||
await copy('src', 'dst/classes', v => !v.endsWith('.java'));
|
||||
// await downloadTypescript('dst/classes/me/topchetoeu/jscript/utils/assets/js/ts.js');
|
||||
})(),
|
||||
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!');
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript;
|
||||
package me.topchetoeu.jscript.common;
|
||||
|
||||
public class Buffer {
|
||||
private byte[] data;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript;
|
||||
package me.topchetoeu.jscript.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript;
|
||||
package me.topchetoeu.jscript.common;
|
||||
|
||||
public class Location implements Comparable<Location> {
|
||||
public static final Location INTERNAL = new Location(0, 0, new Filename("jscript", "native"));
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript;
|
||||
package me.topchetoeu.jscript.common;
|
||||
|
||||
public class Metadata {
|
||||
private static final String VERSION = "${VERSION}";
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript;
|
||||
package me.topchetoeu.jscript.common;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript;
|
||||
package me.topchetoeu.jscript.common;
|
||||
|
||||
public interface ResultRunnable<T> {
|
||||
T run();
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.events;
|
||||
package me.topchetoeu.jscript.common.events;
|
||||
|
||||
public interface Awaitable<T> {
|
||||
public static interface ResultHandler<T> {
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.events;
|
||||
package me.topchetoeu.jscript.common.events;
|
||||
|
||||
public class DataNotifier<T> implements Awaitable<T> {
|
||||
private Notifier notifier = new Notifier();
|
@ -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 {
|
||||
private boolean ok = false;
|
@ -1,20 +1,20 @@
|
||||
package me.topchetoeu.jscript.json;
|
||||
package me.topchetoeu.jscript.common.json;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.parsing.Operator;
|
||||
import me.topchetoeu.jscript.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.parsing.Token;
|
||||
import me.topchetoeu.jscript.common.Filename;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.core.parsing.Operator;
|
||||
import me.topchetoeu.jscript.core.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.core.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.core.parsing.Token;
|
||||
|
||||
public class JSON {
|
||||
public static Object toJs(JSONElement val) {
|
||||
@ -58,8 +58,8 @@ public class JSON {
|
||||
|
||||
var res = new JSONMap();
|
||||
|
||||
for (var el : ((ObjectValue)val).keys(false)) {
|
||||
var jsonEl = fromJs(ctx, ((ObjectValue)val).getMember(ctx, el), prev);
|
||||
for (var el : Values.getMembers(ctx, val, false, false)) {
|
||||
var jsonEl = fromJs(ctx, Values.getMember(ctx, val, el), prev);
|
||||
if (jsonEl == null) continue;
|
||||
if (el instanceof String || el instanceof Number) res.put(el.toString(), jsonEl);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.json;
|
||||
package me.topchetoeu.jscript.common.json;
|
||||
|
||||
public class JSONElement {
|
||||
public static enum Type {
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.json;
|
||||
package me.topchetoeu.jscript.common.json;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.json;
|
||||
package me.topchetoeu.jscript.common.json;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
@ -1,7 +1,7 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.jscript.core.compilation;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
|
||||
public abstract class AssignableStatement extends Statement {
|
||||
public abstract Statement toAssign(Statement val, Operation operation);
|
@ -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 boolean exists;
|
@ -1,14 +1,14 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.jscript.core.compilation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.Environment;
|
||||
import me.topchetoeu.jscript.engine.values.CodeFunction;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.Environment;
|
||||
import me.topchetoeu.jscript.core.engine.values.CodeFunction;
|
||||
|
||||
public class CompileTarget {
|
||||
public final Vector<Instruction> target = new Vector<>();
|
@ -1,12 +1,12 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.jscript.core.compilation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.compilation.values.FunctionStatement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.compilation.values.FunctionStatement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class CompoundStatement extends Statement {
|
||||
public final Statement[] statements;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.jscript.core.compilation;
|
||||
|
||||
public class FunctionBody {
|
||||
public final Instruction[] instructions;
|
@ -1,8 +1,8 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.jscript.core.compilation;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
||||
|
||||
public class Instruction {
|
||||
public static enum Type {
|
@ -1,8 +1,8 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.jscript.core.compilation;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public abstract class Statement {
|
||||
private Location _loc;
|
@ -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.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
||||
|
||||
public class ThrowSyntaxStatement extends Statement {
|
||||
public final String name;
|
@ -1,11 +1,11 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.jscript.core.compilation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.compilation.values.FunctionStatement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.compilation.values.FunctionStatement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class VariableDeclareStatement extends Statement {
|
||||
public static class Pair {
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class BreakStatement extends Statement {
|
||||
public final String label;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ContinueStatement extends Statement {
|
||||
public final String label;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class DebugStatement extends Statement {
|
||||
@Override
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class DeleteStatement extends Statement {
|
||||
public final Statement key;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class DoWhileStatement extends Statement {
|
||||
public final Statement condition, body;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ForInStatement extends Statement {
|
||||
public final String varName;
|
@ -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.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ForStatement extends Statement {
|
||||
public final Statement declaration, assignment, condition, body;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class IfStatement extends Statement {
|
||||
public final Statement condition, body, elseBody;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ReturnStatement extends Statement {
|
||||
public final Statement value;
|
@ -1,15 +1,15 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.jscript.core.compilation.control;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.Type;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.Type;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class SwitchStatement extends Statement {
|
||||
public static class SwitchCase {
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ThrowStatement extends Statement {
|
||||
public final Statement value;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.scope.GlobalScope;
|
||||
import me.topchetoeu.jscript.engine.scope.LocalScopeRecord;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.scope.GlobalScope;
|
||||
import me.topchetoeu.jscript.core.engine.scope.LocalScopeRecord;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class TryStatement extends Statement {
|
||||
public final Statement tryBody;
|
@ -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.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.Type;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.Type;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class WhileStatement extends Statement {
|
||||
public final Statement condition, body;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ArrayStatement extends Statement {
|
||||
public final Statement[] statements;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class CallStatement extends Statement {
|
||||
public final Statement func;
|
@ -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.compilation.AssignableStatement;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.AssignableStatement;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ChangeStatement extends Statement {
|
||||
public final AssignableStatement value;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ConstantStatement extends Statement {
|
||||
public final Object value;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class DiscardStatement extends Statement {
|
||||
public final Statement value;
|
@ -1,17 +1,17 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.jscript.core.compilation.values;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.CompoundStatement;
|
||||
import me.topchetoeu.jscript.compilation.FunctionBody;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.Type;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.CompoundStatement;
|
||||
import me.topchetoeu.jscript.core.compilation.FunctionBody;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.Type;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
||||
|
||||
public class FunctionStatement extends Statement {
|
||||
public final CompoundStatement body;
|
@ -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.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class GlobalThisStatement extends Statement {
|
||||
@Override public boolean pure() { return true; }
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class IndexAssignStatement extends Statement {
|
||||
public final Statement object;
|
@ -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.compilation.AssignableStatement;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.AssignableStatement;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class IndexStatement extends AssignableStatement {
|
||||
public final Statement object;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
|
||||
public class LazyAndStatement extends Statement {
|
||||
public final Statement first, second;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
|
||||
public class LazyOrStatement extends Statement {
|
||||
public final Statement first, second;
|
@ -1,13 +1,13 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.jscript.core.compilation.values;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class ObjectStatement extends Statement {
|
||||
public final Map<Object, Statement> map;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class OperationStatement extends Statement {
|
||||
public final Statement[] args;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class RegexStatement extends Statement {
|
||||
public final String pattern, flags;
|
@ -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.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class TypeofStatement extends Statement {
|
||||
public final Statement value;
|
@ -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.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class VariableAssignStatement extends Statement {
|
||||
public final String name;
|
@ -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.compilation.Statement;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class VariableIndexStatement extends Statement {
|
||||
public final int index;
|
@ -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.compilation.AssignableStatement;
|
||||
import me.topchetoeu.jscript.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Statement;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ScopeRecord;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.AssignableStatement;
|
||||
import me.topchetoeu.jscript.core.compilation.CompileTarget;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Statement;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ScopeRecord;
|
||||
|
||||
public class VariableStatement extends AssignableStatement {
|
||||
public final String name;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine;
|
||||
package me.topchetoeu.jscript.core.engine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -9,19 +9,21 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.engine.debug.DebugContext;
|
||||
import me.topchetoeu.jscript.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.common.Filename;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.engine.debug.DebugContext;
|
||||
import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.core.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
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 static final Context NULL = new Context(null);
|
||||
|
||||
public final Context parent;
|
||||
public final Environment environment;
|
||||
public final CodeFrame frame;
|
@ -1,12 +1,12 @@
|
||||
package me.topchetoeu.jscript.engine;
|
||||
package me.topchetoeu.jscript.core.engine;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.compilation.FunctionBody;
|
||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.events.Awaitable;
|
||||
import me.topchetoeu.jscript.common.Filename;
|
||||
import me.topchetoeu.jscript.common.events.Awaitable;
|
||||
import me.topchetoeu.jscript.core.compilation.FunctionBody;
|
||||
import me.topchetoeu.jscript.core.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Symbol;
|
||||
|
||||
public class Engine extends EventLoop implements Extensions {
|
||||
public static final HashMap<Long, FunctionBody> functions = new HashMap<>();
|
@ -1,21 +1,21 @@
|
||||
package me.topchetoeu.jscript.engine;
|
||||
package me.topchetoeu.jscript.core.engine;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.engine.debug.DebugContext;
|
||||
import me.topchetoeu.jscript.engine.scope.GlobalScope;
|
||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.engine.values.NativeFunction;
|
||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.interop.NativeWrapperProvider;
|
||||
import me.topchetoeu.jscript.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.Filename;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.engine.debug.DebugContext;
|
||||
import me.topchetoeu.jscript.core.engine.scope.GlobalScope;
|
||||
import me.topchetoeu.jscript.core.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.NativeFunction;
|
||||
import me.topchetoeu.jscript.core.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.core.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.utils.interop.NativeWrapperProvider;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Environment implements Extensions {
|
||||
@ -45,7 +45,7 @@ public class Environment implements Extensions {
|
||||
private HashMap<Symbol, Object> data = new HashMap<>();
|
||||
|
||||
public GlobalScope global;
|
||||
public WrappersProvider wrappers;
|
||||
public WrapperProvider wrappers;
|
||||
|
||||
@Override public <T> void add(Symbol key, T obj) {
|
||||
data.put(key, obj);
|
||||
@ -71,7 +71,7 @@ public class Environment implements Extensions {
|
||||
return ext.init(COMPILE_FUNC, new NativeFunction("compile", args -> {
|
||||
var source = args.getString(0);
|
||||
var filename = args.getString(1);
|
||||
var env = Values.wrapper(args.convert(2, ObjectValue.class).getMember(args.ctx, Symbol.get("env")), Environment.class);
|
||||
var env = Values.wrapper(Values.getMember(args.ctx, args.get(2), Symbol.get("env")), Environment.class);
|
||||
var isDebug = DebugContext.enabled(args.ctx);
|
||||
var res = new ObjectValue();
|
||||
|
||||
@ -115,7 +115,7 @@ public class Environment implements Extensions {
|
||||
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 (global == null) global = new GlobalScope();
|
||||
|
@ -1,11 +1,11 @@
|
||||
package me.topchetoeu.jscript.engine;
|
||||
package me.topchetoeu.jscript.core.engine;
|
||||
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
|
||||
import me.topchetoeu.jscript.ResultRunnable;
|
||||
import me.topchetoeu.jscript.events.Awaitable;
|
||||
import me.topchetoeu.jscript.events.DataNotifier;
|
||||
import me.topchetoeu.jscript.exceptions.InterruptException;
|
||||
import me.topchetoeu.jscript.common.ResultRunnable;
|
||||
import me.topchetoeu.jscript.common.events.Awaitable;
|
||||
import me.topchetoeu.jscript.common.events.DataNotifier;
|
||||
import me.topchetoeu.jscript.core.exceptions.InterruptException;
|
||||
|
||||
public class EventLoop {
|
||||
private static class Task implements Comparable<Task> {
|
@ -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 {
|
||||
<T> T get(Symbol key);
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine;
|
||||
package me.topchetoeu.jscript.core.engine;
|
||||
|
||||
public enum Operation {
|
||||
INSTANCEOF(2, false),
|
12
src/me/topchetoeu/jscript/core/engine/WrapperProvider.java
Normal file
12
src/me/topchetoeu/jscript/core/engine/WrapperProvider.java
Normal 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);
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.Extensions;
|
||||
import me.topchetoeu.jscript.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.mapping.SourceMap;
|
||||
import me.topchetoeu.jscript.common.Filename;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Extensions;
|
||||
import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.core.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.utils.mapping.SourceMap;
|
||||
|
||||
public class DebugContext implements DebugController {
|
||||
public static final Symbol ENV_KEY = Symbol.get("Engine.debug");
|
@ -1,14 +1,14 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.mapping.SourceMap;
|
||||
import me.topchetoeu.jscript.common.Filename;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.utils.mapping.SourceMap;
|
||||
|
||||
public interface DebugController {
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
@ -9,14 +9,14 @@ import java.security.MessageDigest;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
|
||||
import me.topchetoeu.jscript.Metadata;
|
||||
import me.topchetoeu.jscript.Reading;
|
||||
import me.topchetoeu.jscript.engine.debug.WebSocketMessage.Type;
|
||||
import me.topchetoeu.jscript.events.Notifier;
|
||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.json.JSON;
|
||||
import me.topchetoeu.jscript.json.JSONList;
|
||||
import me.topchetoeu.jscript.json.JSONMap;
|
||||
import me.topchetoeu.jscript.common.Metadata;
|
||||
import me.topchetoeu.jscript.common.Reading;
|
||||
import me.topchetoeu.jscript.common.events.Notifier;
|
||||
import me.topchetoeu.jscript.common.json.JSON;
|
||||
import me.topchetoeu.jscript.common.json.JSONList;
|
||||
import me.topchetoeu.jscript.common.json.JSONMap;
|
||||
import me.topchetoeu.jscript.core.engine.debug.WebSocketMessage.Type;
|
||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
||||
|
||||
public class DebugServer {
|
||||
public static String browserDisplayName = Metadata.name() + "/" + Metadata.version();
|
||||
@ -226,9 +226,9 @@ public class DebugServer {
|
||||
|
||||
public DebugServer() {
|
||||
try {
|
||||
this.favicon = Reading.resourceToStream("assets/debugger/favicon.png").readAllBytes();
|
||||
this.protocol = Reading.resourceToStream("assets/debugger/protocol.json").readAllBytes();
|
||||
this.index = Reading.resourceToString("assets/debugger/index.html")
|
||||
this.favicon = Reading.resourceToStream("me/topchetoeu/jscript/utils/assets/debugger/favicon.png").readAllBytes();
|
||||
this.protocol = Reading.resourceToStream("me/topchetoeu/jscript/utils/assets/debugger/protocol.json").readAllBytes();
|
||||
this.index = Reading.resourceToString("me/topchetoeu/jscript/utils/assets/debugger/index.html")
|
||||
.replace("${NAME}", Metadata.name())
|
||||
.replace("${VERSION}", Metadata.version())
|
||||
.replace("${AUTHOR}", Metadata.author())
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
public interface Debugger extends DebugHandler, DebugController {
|
||||
void close();
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
public interface DebuggerProvider {
|
||||
Debugger getDebugger(WebSocket socket, HttpRequest req);
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -10,29 +10,29 @@ import java.util.TreeSet;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.Type;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.Engine;
|
||||
import me.topchetoeu.jscript.engine.Environment;
|
||||
import me.topchetoeu.jscript.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.engine.scope.GlobalScope;
|
||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.engine.values.CodeFunction;
|
||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.events.Notifier;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.json.JSON;
|
||||
import me.topchetoeu.jscript.json.JSONElement;
|
||||
import me.topchetoeu.jscript.json.JSONList;
|
||||
import me.topchetoeu.jscript.json.JSONMap;
|
||||
import me.topchetoeu.jscript.mapping.SourceMap;
|
||||
import me.topchetoeu.jscript.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.Filename;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.common.events.Notifier;
|
||||
import me.topchetoeu.jscript.common.json.JSON;
|
||||
import me.topchetoeu.jscript.common.json.JSONElement;
|
||||
import me.topchetoeu.jscript.common.json.JSONList;
|
||||
import me.topchetoeu.jscript.common.json.JSONMap;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction.Type;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Engine;
|
||||
import me.topchetoeu.jscript.core.engine.Environment;
|
||||
import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.core.engine.scope.GlobalScope;
|
||||
import me.topchetoeu.jscript.core.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.CodeFunction;
|
||||
import me.topchetoeu.jscript.core.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.core.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.utils.mapping.SourceMap;
|
||||
|
||||
// very simple indeed
|
||||
public class SimpleDebugger implements Debugger {
|
||||
@ -124,8 +124,7 @@ public class SimpleDebugger implements Debugger {
|
||||
this.global = frame.function.environment.global.obj;
|
||||
this.local = frame.getLocalScope(true);
|
||||
this.capture = frame.getCaptureScope(true);
|
||||
this.local.setPrototype(frame.ctx, capture);
|
||||
this.capture.setPrototype(frame.ctx, global);
|
||||
Values.makePrototypeChain(frame.ctx, global, capture, local);
|
||||
this.valstack = frame.getValStackScope();
|
||||
|
||||
this.serialized = new JSONMap()
|
||||
@ -841,7 +840,7 @@ public class SimpleDebugger implements Debugger {
|
||||
}
|
||||
else {
|
||||
propDesc.set("name", Values.toString(ctx, key));
|
||||
propDesc.set("value", serializeObj(ctx, obj.getMember(ctx, key)));
|
||||
propDesc.set("value", serializeObj(ctx, Values.getMember(ctx, obj, key)));
|
||||
propDesc.set("writable", obj.memberWritable(key));
|
||||
propDesc.set("enumerable", obj.memberEnumerable(key));
|
||||
propDesc.set("configurable", obj.memberConfigurable(key));
|
||||
@ -850,7 +849,7 @@ public class SimpleDebugger implements Debugger {
|
||||
}
|
||||
}
|
||||
|
||||
var proto = obj.getPrototype(ctx);
|
||||
var proto = Values.getPrototype(ctx, obj);
|
||||
|
||||
var protoDesc = new JSONMap();
|
||||
protoDesc.set("name", "__proto__");
|
@ -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.json.JSONMap;
|
||||
import me.topchetoeu.jscript.common.json.JSON;
|
||||
import me.topchetoeu.jscript.common.json.JSONMap;
|
||||
|
||||
public class V8Error {
|
||||
public final String message;
|
@ -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.json.JSONMap;
|
||||
import me.topchetoeu.jscript.common.json.JSON;
|
||||
import me.topchetoeu.jscript.common.json.JSONMap;
|
||||
|
||||
public class V8Event {
|
||||
public final String name;
|
@ -1,10 +1,10 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.topchetoeu.jscript.json.JSON;
|
||||
import me.topchetoeu.jscript.json.JSONElement;
|
||||
import me.topchetoeu.jscript.json.JSONMap;
|
||||
import me.topchetoeu.jscript.common.json.JSON;
|
||||
import me.topchetoeu.jscript.common.json.JSONElement;
|
||||
import me.topchetoeu.jscript.common.json.JSONMap;
|
||||
|
||||
public class V8Message {
|
||||
public final String name;
|
@ -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.json.JSONMap;
|
||||
import me.topchetoeu.jscript.common.json.JSON;
|
||||
import me.topchetoeu.jscript.common.json.JSONMap;
|
||||
|
||||
public class V8Result {
|
||||
public final int id;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -6,7 +6,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
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 long maxLength = 1 << 20;
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.debug;
|
||||
package me.topchetoeu.jscript.core.engine.debug;
|
||||
|
||||
public class WebSocketMessage {
|
||||
public static enum Type {
|
@ -1,21 +1,21 @@
|
||||
package me.topchetoeu.jscript.engine.frame;
|
||||
package me.topchetoeu.jscript.core.engine.frame;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.debug.DebugContext;
|
||||
import me.topchetoeu.jscript.engine.scope.LocalScope;
|
||||
import me.topchetoeu.jscript.engine.scope.ValueVariable;
|
||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.engine.values.CodeFunction;
|
||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.engine.values.ScopeValue;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.exceptions.InterruptException;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.debug.DebugContext;
|
||||
import me.topchetoeu.jscript.core.engine.scope.LocalScope;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ValueVariable;
|
||||
import me.topchetoeu.jscript.core.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.CodeFunction;
|
||||
import me.topchetoeu.jscript.core.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.ScopeValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.core.exceptions.InterruptException;
|
||||
|
||||
public class CodeFrame {
|
||||
public static enum TryState {
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.frame;
|
||||
package me.topchetoeu.jscript.core.engine.frame;
|
||||
|
||||
public enum ConvertHint {
|
||||
TOSTRING,
|
@ -1,20 +1,20 @@
|
||||
package me.topchetoeu.jscript.engine.frame;
|
||||
package me.topchetoeu.jscript.core.engine.frame;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.Engine;
|
||||
import me.topchetoeu.jscript.engine.Environment;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.ValueVariable;
|
||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.engine.values.CodeFunction;
|
||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Engine;
|
||||
import me.topchetoeu.jscript.core.engine.Environment;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ValueVariable;
|
||||
import me.topchetoeu.jscript.core.engine.values.ArrayValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.CodeFunction;
|
||||
import me.topchetoeu.jscript.core.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Symbol;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
|
||||
public class Runners {
|
||||
public static Object execReturn(Context ctx, Instruction instr, CodeFrame frame) {
|
@ -1,19 +1,20 @@
|
||||
package me.topchetoeu.jscript.engine.scope;
|
||||
package me.topchetoeu.jscript.core.engine.scope;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.engine.values.NativeFunction;
|
||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.values.FunctionValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.NativeFunction;
|
||||
import me.topchetoeu.jscript.core.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.exceptions.EngineException;
|
||||
|
||||
public class GlobalScope implements ScopeRecord {
|
||||
public final ObjectValue obj;
|
||||
|
||||
public boolean has(Context ctx, String name) {
|
||||
return obj.hasMember(ctx, name, false);
|
||||
return Values.hasMember(null, obj, name, false);
|
||||
}
|
||||
public Object getKey(String name) {
|
||||
return name;
|
||||
@ -21,7 +22,7 @@ public class GlobalScope implements ScopeRecord {
|
||||
|
||||
public GlobalScope globalChild() {
|
||||
var obj = new ObjectValue();
|
||||
obj.setPrototype(null, this.obj);
|
||||
Values.setPrototype(null, obj, this.obj);
|
||||
return new GlobalScope(obj);
|
||||
}
|
||||
public LocalScopeRecord child() {
|
||||
@ -29,12 +30,12 @@ public class GlobalScope implements ScopeRecord {
|
||||
}
|
||||
|
||||
public Object define(String name) {
|
||||
if (obj.hasMember(null, name, true)) return name;
|
||||
obj.defineProperty(null, name, null);
|
||||
if (Values.hasMember(Context.NULL, obj, name, false)) return name;
|
||||
obj.defineProperty(Context.NULL, name, null);
|
||||
return name;
|
||||
}
|
||||
public void define(String name, Variable val) {
|
||||
obj.defineProperty(null, name,
|
||||
obj.defineProperty(Context.NULL, name,
|
||||
new NativeFunction("get " + name, args -> val.get(args.ctx)),
|
||||
new NativeFunction("set " + name, args -> { val.set(args.ctx, args.get(0)); return null; }),
|
||||
true, true
|
||||
@ -51,12 +52,12 @@ public class GlobalScope implements ScopeRecord {
|
||||
}
|
||||
|
||||
public Object get(Context ctx, String name) {
|
||||
if (!obj.hasMember(ctx, name, false)) throw EngineException.ofSyntax("The variable '" + name + "' doesn't exist.");
|
||||
else return obj.getMember(ctx, name);
|
||||
if (!Values.hasMember(ctx, obj, name, false)) throw EngineException.ofSyntax("The variable '" + name + "' doesn't exist.");
|
||||
else return Values.getMember(ctx, obj, name);
|
||||
}
|
||||
public void set(Context ctx, String name, Object val) {
|
||||
if (!obj.hasMember(ctx, name, false)) throw EngineException.ofSyntax("The variable '" + name + "' doesn't exist.");
|
||||
if (!obj.setMember(ctx, name, val, false)) throw EngineException.ofSyntax("The global '" + name + "' is readonly.");
|
||||
if (!Values.hasMember(ctx, obj, name, false)) throw EngineException.ofSyntax("The variable '" + name + "' doesn't exist.");
|
||||
if (!Values.setMember(ctx, obj, name, val)) throw EngineException.ofSyntax("The global '" + name + "' is readonly.");
|
||||
}
|
||||
|
||||
public Set<String> keys() {
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.scope;
|
||||
package me.topchetoeu.jscript.core.engine.scope;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.scope;
|
||||
package me.topchetoeu.jscript.core.engine.scope;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.scope;
|
||||
package me.topchetoeu.jscript.core.engine.scope;
|
||||
|
||||
public interface ScopeRecord {
|
||||
public Object getKey(String name);
|
@ -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.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
|
||||
public class ValueVariable implements Variable {
|
||||
public boolean readonly;
|
@ -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 {
|
||||
Object get(Context ctx);
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.values;
|
||||
package me.topchetoeu.jscript.core.engine.values;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -6,7 +6,7 @@ import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
|
||||
// TODO: Make methods generic
|
||||
public class ArrayValue extends ObjectValue implements Iterable<Object> {
|
@ -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.compilation.FunctionBody;
|
||||
import me.topchetoeu.jscript.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.Environment;
|
||||
import me.topchetoeu.jscript.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.engine.scope.ValueVariable;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.FunctionBody;
|
||||
import me.topchetoeu.jscript.core.compilation.Instruction;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Environment;
|
||||
import me.topchetoeu.jscript.core.engine.frame.CodeFrame;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ValueVariable;
|
||||
|
||||
public class CodeFunction extends FunctionValue {
|
||||
public final int localsN;
|
@ -1,8 +1,8 @@
|
||||
package me.topchetoeu.jscript.engine.values;
|
||||
package me.topchetoeu.jscript.core.engine.values;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
|
||||
public abstract class FunctionValue extends ObjectValue {
|
||||
public String name = "";
|
@ -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.interop.Arguments;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.utils.interop.Arguments;
|
||||
|
||||
public class NativeFunction extends FunctionValue {
|
||||
public static interface NativeFunctionRunner {
|
@ -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 {
|
||||
private static final Object NATIVE_PROTO = new Object();
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.values;
|
||||
package me.topchetoeu.jscript.core.engine.values;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@ -6,8 +6,8 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.Environment;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Environment;
|
||||
|
||||
public class ObjectValue {
|
||||
public static enum PlaceholderProto {
|
||||
@ -54,6 +54,13 @@ public class ObjectValue {
|
||||
public LinkedHashSet<Object> nonConfigurableSet = new LinkedHashSet<>();
|
||||
public LinkedHashSet<Object> nonEnumerableSet = new LinkedHashSet<>();
|
||||
|
||||
private Property getProperty(Context ctx, Object key) {
|
||||
if (properties.containsKey(key)) return properties.get(key);
|
||||
var proto = getPrototype(ctx);
|
||||
if (proto != null) return proto.getProperty(ctx, key);
|
||||
else return null;
|
||||
}
|
||||
|
||||
public final boolean memberWritable(Object key) {
|
||||
if (state == State.FROZEN) return false;
|
||||
return !values.containsKey(key) || !nonWritableSet.contains(key);
|
||||
@ -159,6 +166,113 @@ public class ObjectValue {
|
||||
|
||||
return (ObjectValue)prototype;
|
||||
}
|
||||
public final boolean setPrototype(PlaceholderProto val) {
|
||||
if (!extensible()) return false;
|
||||
switch (val) {
|
||||
case OBJECT: prototype = OBJ_PROTO; break;
|
||||
case FUNCTION: prototype = FUNC_PROTO; break;
|
||||
case ARRAY: prototype = ARR_PROTO; break;
|
||||
case ERROR: prototype = ERR_PROTO; break;
|
||||
case SYNTAX_ERROR: prototype = SYNTAX_ERR_PROTO; break;
|
||||
case TYPE_ERROR: prototype = TYPE_ERR_PROTO; break;
|
||||
case RANGE_ERROR: prototype = RANGE_ERR_PROTO; break;
|
||||
case NONE: prototype = null; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A method, used to get the value of a field. If a property is bound to
|
||||
* this key, but not a field, this method should return null.
|
||||
*/
|
||||
protected Object getField(Context ctx, Object key) {
|
||||
if (values.containsKey(key)) return values.get(key);
|
||||
var proto = getPrototype(ctx);
|
||||
if (proto != null) return proto.getField(ctx, key);
|
||||
else return null;
|
||||
}
|
||||
/**
|
||||
* Changes the value of a field, that is bound to the given key. If no field is
|
||||
* bound to this key, a new field should be created with the given value
|
||||
* @return Whether or not the operation was successful
|
||||
*/
|
||||
protected boolean setField(Context ctx, Object key, Object val) {
|
||||
if (val instanceof FunctionValue && ((FunctionValue)val).name.equals("")) {
|
||||
((FunctionValue)val).name = Values.toString(ctx, key);
|
||||
}
|
||||
|
||||
values.put(key, val);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Deletes the field bound to the given key.
|
||||
*/
|
||||
protected void deleteField(Context ctx, Object key) {
|
||||
values.remove(key);
|
||||
}
|
||||
/**
|
||||
* Returns whether or not there is a field bound to the given key.
|
||||
* This must ignore properties
|
||||
*/
|
||||
protected boolean hasField(Context ctx, Object key) {
|
||||
return values.containsKey(key);
|
||||
}
|
||||
|
||||
public final Object getMember(Context ctx, Object key, Object thisArg) {
|
||||
key = Values.normalize(ctx, key);
|
||||
|
||||
if ("__proto__".equals(key)) {
|
||||
var res = getPrototype(ctx);
|
||||
return res == null ? Values.NULL : res;
|
||||
}
|
||||
|
||||
var prop = getProperty(ctx, key);
|
||||
|
||||
if (prop != null) {
|
||||
if (prop.getter == null) return null;
|
||||
else return prop.getter.call(ctx, Values.normalize(ctx, thisArg));
|
||||
}
|
||||
else return getField(ctx, key);
|
||||
}
|
||||
public final boolean setMember(Context ctx, Object key, Object val, Object thisArg, boolean onlyProps) {
|
||||
key = Values.normalize(ctx, key); val = Values.normalize(ctx, val);
|
||||
|
||||
var prop = getProperty(ctx, key);
|
||||
if (prop != null) {
|
||||
if (prop.setter == null) return false;
|
||||
prop.setter.call(ctx, Values.normalize(ctx, thisArg), val);
|
||||
return true;
|
||||
}
|
||||
else if (onlyProps) return false;
|
||||
else if (!extensible() && !values.containsKey(key)) return false;
|
||||
else if (key == null) {
|
||||
values.put(key, val);
|
||||
return true;
|
||||
}
|
||||
else if ("__proto__".equals(key)) return setPrototype(ctx, val);
|
||||
else if (nonWritableSet.contains(key)) return false;
|
||||
else return setField(ctx, key, val);
|
||||
}
|
||||
public final boolean hasMember(Context ctx, Object key, boolean own) {
|
||||
key = Values.normalize(ctx, key);
|
||||
|
||||
if (key != null && "__proto__".equals(key)) return true;
|
||||
if (hasField(ctx, key)) return true;
|
||||
if (properties.containsKey(key)) return true;
|
||||
if (own) return false;
|
||||
var proto = getPrototype(ctx);
|
||||
return proto != null && proto.hasMember(ctx, key, own);
|
||||
}
|
||||
public final boolean deleteMember(Context ctx, Object key) {
|
||||
key = Values.normalize(ctx, key);
|
||||
|
||||
if (!memberConfigurable(key)) return false;
|
||||
properties.remove(key);
|
||||
nonWritableSet.remove(key);
|
||||
nonEnumerableSet.remove(key);
|
||||
deleteField(ctx, key);
|
||||
return true;
|
||||
}
|
||||
public final boolean setPrototype(Context ctx, Object val) {
|
||||
val = Values.normalize(ctx, val);
|
||||
|
||||
@ -186,111 +300,6 @@ public class ObjectValue {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public final boolean setPrototype(PlaceholderProto val) {
|
||||
if (!extensible()) return false;
|
||||
switch (val) {
|
||||
case OBJECT: prototype = OBJ_PROTO; break;
|
||||
case FUNCTION: prototype = FUNC_PROTO; break;
|
||||
case ARRAY: prototype = ARR_PROTO; break;
|
||||
case ERROR: prototype = ERR_PROTO; break;
|
||||
case SYNTAX_ERROR: prototype = SYNTAX_ERR_PROTO; break;
|
||||
case TYPE_ERROR: prototype = TYPE_ERR_PROTO; break;
|
||||
case RANGE_ERROR: prototype = RANGE_ERR_PROTO; break;
|
||||
case NONE: prototype = null; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Property getProperty(Context ctx, Object key) {
|
||||
if (properties.containsKey(key)) return properties.get(key);
|
||||
var proto = getPrototype(ctx);
|
||||
if (proto != null) return proto.getProperty(ctx, key);
|
||||
else return null;
|
||||
}
|
||||
protected Object getField(Context ctx, Object key) {
|
||||
if (values.containsKey(key)) return values.get(key);
|
||||
var proto = getPrototype(ctx);
|
||||
if (proto != null) return proto.getField(ctx, key);
|
||||
else return null;
|
||||
}
|
||||
protected boolean setField(Context ctx, Object key, Object val) {
|
||||
if (val instanceof FunctionValue && ((FunctionValue)val).name.equals("")) {
|
||||
((FunctionValue)val).name = Values.toString(ctx, key);
|
||||
}
|
||||
|
||||
values.put(key, val);
|
||||
return true;
|
||||
}
|
||||
protected void deleteField(Context ctx, Object key) {
|
||||
values.remove(key);
|
||||
}
|
||||
protected boolean hasField(Context ctx, Object key) {
|
||||
return values.containsKey(key);
|
||||
}
|
||||
|
||||
public final Object getMember(Context ctx, Object key, Object thisArg) {
|
||||
key = Values.normalize(ctx, key);
|
||||
|
||||
if ("__proto__".equals(key)) {
|
||||
var res = getPrototype(ctx);
|
||||
return res == null ? Values.NULL : res;
|
||||
}
|
||||
|
||||
var prop = getProperty(ctx, key);
|
||||
|
||||
if (prop != null) {
|
||||
if (prop.getter == null) return null;
|
||||
else return prop.getter.call(ctx, Values.normalize(ctx, thisArg));
|
||||
}
|
||||
else return getField(ctx, key);
|
||||
}
|
||||
public final Object getMember(Context ctx, Object key) {
|
||||
return getMember(ctx, key, this);
|
||||
}
|
||||
|
||||
public final boolean setMember(Context ctx, Object key, Object val, Object thisArg, boolean onlyProps) {
|
||||
key = Values.normalize(ctx, key); val = Values.normalize(ctx, val);
|
||||
|
||||
var prop = getProperty(ctx, key);
|
||||
if (prop != null) {
|
||||
if (prop.setter == null) return false;
|
||||
prop.setter.call(ctx, Values.normalize(ctx, thisArg), val);
|
||||
return true;
|
||||
}
|
||||
else if (onlyProps) return false;
|
||||
else if (!extensible() && !values.containsKey(key)) return false;
|
||||
else if (key == null) {
|
||||
values.put(key, val);
|
||||
return true;
|
||||
}
|
||||
else if ("__proto__".equals(key)) return setPrototype(ctx, val);
|
||||
else if (nonWritableSet.contains(key)) return false;
|
||||
else return setField(ctx, key, val);
|
||||
}
|
||||
public final boolean setMember(Context ctx, Object key, Object val, boolean onlyProps) {
|
||||
return setMember(ctx, Values.normalize(ctx, key), Values.normalize(ctx, val), this, onlyProps);
|
||||
}
|
||||
|
||||
public final boolean hasMember(Context ctx, Object key, boolean own) {
|
||||
key = Values.normalize(ctx, key);
|
||||
|
||||
if (key != null && "__proto__".equals(key)) return true;
|
||||
if (hasField(ctx, key)) return true;
|
||||
if (properties.containsKey(key)) return true;
|
||||
if (own) return false;
|
||||
var proto = getPrototype(ctx);
|
||||
return proto != null && proto.hasMember(ctx, key, own);
|
||||
}
|
||||
public final boolean deleteMember(Context ctx, Object key) {
|
||||
key = Values.normalize(ctx, key);
|
||||
|
||||
if (!memberConfigurable(key)) return false;
|
||||
properties.remove(key);
|
||||
nonWritableSet.remove(key);
|
||||
nonEnumerableSet.remove(key);
|
||||
deleteField(ctx, key);
|
||||
return true;
|
||||
}
|
||||
|
||||
public final ObjectValue getMemberDescriptor(Context ctx, Object key) {
|
||||
key = Values.normalize(ctx, key);
|
@ -1,10 +1,10 @@
|
||||
package me.topchetoeu.jscript.engine.values;
|
||||
package me.topchetoeu.jscript.core.engine.values;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.scope.ValueVariable;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.scope.ValueVariable;
|
||||
|
||||
public class ScopeValue extends ObjectValue {
|
||||
public final ValueVariable[] variables;
|
||||
@ -23,7 +23,7 @@ public class ScopeValue extends ObjectValue {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.engine.values;
|
||||
package me.topchetoeu.jscript.core.engine.values;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -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.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
@ -10,13 +12,13 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.Environment;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.frame.ConvertHint;
|
||||
import me.topchetoeu.jscript.exceptions.ConvertException;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Environment;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.frame.ConvertHint;
|
||||
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;
|
||||
|
||||
public class Values {
|
||||
@ -281,7 +283,7 @@ public class Values {
|
||||
obj = normalize(ctx, obj); key = normalize(ctx, key);
|
||||
if (obj == null) throw new IllegalArgumentException("Tried to access member of undefined.");
|
||||
if (obj == NULL) throw new IllegalArgumentException("Tried to access member of null.");
|
||||
if (obj instanceof ObjectValue) return object(obj).getMember(ctx, key);
|
||||
if (obj instanceof ObjectValue) return ((ObjectValue)obj).getMember(ctx, key, obj);
|
||||
|
||||
if (obj instanceof String && key instanceof Number) {
|
||||
var i = number(key);
|
||||
@ -307,7 +309,7 @@ public class Values {
|
||||
if (obj == null) throw EngineException.ofType("Tried to access member of undefined.");
|
||||
if (obj == NULL) throw EngineException.ofType("Tried to access member of null.");
|
||||
if (key != null && "__proto__".equals(key)) return setPrototype(ctx, obj, val);
|
||||
if (obj instanceof ObjectValue) return object(obj).setMember(ctx, key, val, false);
|
||||
if (obj instanceof ObjectValue) return ((ObjectValue)obj).setMember(ctx, key, val, obj, false);
|
||||
|
||||
var proto = getPrototype(ctx, obj);
|
||||
return proto.setMember(ctx, key, val, obj, true);
|
||||
@ -340,7 +342,7 @@ public class Values {
|
||||
public static ObjectValue getPrototype(Context ctx, Object obj) {
|
||||
if (obj == null || obj == NULL) return null;
|
||||
obj = normalize(ctx, obj);
|
||||
if (obj instanceof ObjectValue) return object(obj).getPrototype(ctx);
|
||||
if (obj instanceof ObjectValue) return ((ObjectValue)obj).getPrototype(ctx);
|
||||
if (ctx == null) return null;
|
||||
|
||||
if (obj instanceof String) return ctx.get(Environment.STRING_PROTO);
|
||||
@ -352,7 +354,12 @@ public class Values {
|
||||
}
|
||||
public static boolean setPrototype(Context ctx, Object obj, Object proto) {
|
||||
obj = normalize(ctx, obj);
|
||||
return obj instanceof ObjectValue && object(obj).setPrototype(ctx, proto);
|
||||
return obj instanceof ObjectValue && ((ObjectValue)obj).setPrototype(ctx, proto);
|
||||
}
|
||||
public static void makePrototypeChain(Context ctx, Object... chain) {
|
||||
for(var i = 1; i < chain.length; i++) {
|
||||
setPrototype(ctx, chain[i], chain[i - 1]);
|
||||
}
|
||||
}
|
||||
public static List<Object> getMembers(Context ctx, Object obj, boolean own, boolean includeNonEnumerable) {
|
||||
List<Object> res = new ArrayList<>();
|
||||
@ -367,7 +374,7 @@ public class Values {
|
||||
|
||||
while (proto != null) {
|
||||
res.addAll(proto.keys(includeNonEnumerable));
|
||||
proto = proto.getPrototype(ctx);
|
||||
proto = getPrototype(ctx, proto);
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,7 +407,7 @@ public class Values {
|
||||
var res = new ObjectValue();
|
||||
try {
|
||||
var proto = Values.getMember(ctx, func, "prototype");
|
||||
res.setPrototype(ctx, proto);
|
||||
setPrototype(ctx, res, proto);
|
||||
|
||||
var ret = call(ctx, func, res, args);
|
||||
|
||||
@ -569,11 +576,11 @@ public class Values {
|
||||
private void loadNext() {
|
||||
if (next == null) value = null;
|
||||
else if (consumed) {
|
||||
var curr = object(next.call(ctx, iterator));
|
||||
var curr = next.call(ctx, iterator);
|
||||
if (curr == null) { next = null; value = null; }
|
||||
if (toBoolean(curr.getMember(ctx, "done"))) { next = null; value = null; }
|
||||
if (toBoolean(Values.getMember(ctx, curr, "done"))) { next = null; value = null; }
|
||||
else {
|
||||
this.value = curr.getMember(ctx, "value");
|
||||
this.value = Values.getMember(ctx, curr, "value");
|
||||
consumed = false;
|
||||
}
|
||||
}
|
||||
@ -658,104 +665,107 @@ public class Values {
|
||||
if (protoObj.values.size() + protoObj.properties.size() != 1) return false;
|
||||
return true;
|
||||
}
|
||||
private static void printValue(Context ctx, Object val, HashSet<Object> passed, int tab) {
|
||||
if (tab == 0 && val instanceof String) {
|
||||
System.out.print(val);
|
||||
return;
|
||||
}
|
||||
private static String toReadable(Context ctx, Object val, HashSet<Object> passed, int tab) {
|
||||
if (tab == 0 && val instanceof String) return (String)val;
|
||||
|
||||
if (passed.contains(val)) {
|
||||
System.out.print("[circular]");
|
||||
return;
|
||||
}
|
||||
if (passed.contains(val)) return "[circular]";
|
||||
|
||||
var printed = true;
|
||||
var res = new StringBuilder();
|
||||
|
||||
if (val instanceof FunctionValue) {
|
||||
System.out.print(val.toString());
|
||||
res.append(val.toString());
|
||||
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) {
|
||||
System.out.print("[");
|
||||
res.append("[");
|
||||
var obj = ((ArrayValue)val);
|
||||
for (int i = 0; i < obj.size(); i++) {
|
||||
if (i != 0) System.out.print(", ");
|
||||
else System.out.print(" ");
|
||||
if (obj.has(i)) printValue(ctx, obj.get(i), passed, tab);
|
||||
else System.out.print("<empty>");
|
||||
if (i != 0) res.append(", ");
|
||||
else res.append(" ");
|
||||
if (obj.has(i)) res.append(toReadable(ctx, obj.get(i), passed, tab));
|
||||
else res.append("<empty>");
|
||||
}
|
||||
System.out.print(" ] ");
|
||||
res.append(" ] ");
|
||||
}
|
||||
else if (val instanceof NativeWrapper) {
|
||||
var obj = ((NativeWrapper)val).wrapped;
|
||||
System.out.print("Native " + obj.toString() + " ");
|
||||
res.append("Native " + obj.toString() + " ");
|
||||
}
|
||||
else printed = false;
|
||||
|
||||
if (val instanceof ObjectValue) {
|
||||
if (tab > 3) {
|
||||
System.out.print("{...}");
|
||||
return;
|
||||
return "{...}";
|
||||
}
|
||||
|
||||
passed.add(val);
|
||||
|
||||
var obj = (ObjectValue)val;
|
||||
if (obj.values.size() + obj.properties.size() == 0 || isEmptyFunc(obj)) {
|
||||
if (!printed) System.out.println("{}");
|
||||
if (!printed) res.append("{}\n");
|
||||
}
|
||||
else {
|
||||
System.out.println("{");
|
||||
res.append("{\n");
|
||||
|
||||
for (var el : obj.values.entrySet()) {
|
||||
for (int i = 0; i < tab + 1; i++) System.out.print(" ");
|
||||
printValue(ctx, el.getKey(), passed, tab + 1);
|
||||
System.out.print(": ");
|
||||
printValue(ctx, el.getValue(), passed, tab + 1);
|
||||
System.out.println(",");
|
||||
res.append(toReadable(ctx, el.getKey(), passed, tab + 1));
|
||||
res.append(": ");
|
||||
res.append(toReadable(ctx, el.getValue(), passed, tab + 1));
|
||||
res.append(",\n");
|
||||
}
|
||||
for (var el : obj.properties.entrySet()) {
|
||||
for (int i = 0; i < tab + 1; i++) System.out.print(" ");
|
||||
printValue(ctx, el.getKey(), passed, tab + 1);
|
||||
System.out.println(": [prop],");
|
||||
res.append(toReadable(ctx, el.getKey(), passed, tab + 1));
|
||||
res.append(": [prop],\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < tab; i++) System.out.print(" ");
|
||||
System.out.print("}");
|
||||
|
||||
for (int i = 0; i < tab; i++) res.append(" ");
|
||||
res.append("}");
|
||||
}
|
||||
|
||||
passed.remove(val);
|
||||
}
|
||||
else if (val == null) System.out.print("undefined");
|
||||
else if (val == Values.NULL) System.out.print("null");
|
||||
else if (val instanceof String) System.out.print("'" + val + "'");
|
||||
else System.out.print(Values.toString(ctx, val));
|
||||
else if (val == null) return "undefined";
|
||||
else if (val == Values.NULL) return "null";
|
||||
else if (val instanceof String) return "'" + val + "'";
|
||||
else return Values.toString(ctx, val);
|
||||
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
public static String toReadable(Context ctx, Object val) {
|
||||
return toReadable(ctx, val, new HashSet<>(), 0);
|
||||
}
|
||||
public static String errorToReadable(RuntimeException err, String prefix) {
|
||||
prefix = prefix == null ? "Uncaught" : "Uncaught " + prefix;
|
||||
if (err instanceof EngineException) {
|
||||
var ee = ((EngineException)err);
|
||||
try {
|
||||
return prefix + " " + ee.toString(new Context(ee.engine, ee.env));
|
||||
}
|
||||
catch (EngineException ex) {
|
||||
return prefix + " " + toReadable(new Context(ee.engine, ee.env), ee.value);
|
||||
}
|
||||
}
|
||||
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) {
|
||||
printValue(ctx, val, new HashSet<>(), 0);
|
||||
System.out.print(toReadable(ctx, val));
|
||||
}
|
||||
public static void printError(RuntimeException err, String prefix) {
|
||||
prefix = prefix == null ? "Uncaught" : "Uncaught " + prefix;
|
||||
try {
|
||||
if (err instanceof EngineException) {
|
||||
var ee = ((EngineException)err);
|
||||
System.out.println(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) {
|
||||
System.out.println("Uncaught ");
|
||||
Values.printValue(null, ((EngineException)err).value);
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println(errorToReadable(err, prefix));
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.exceptions;
|
||||
package me.topchetoeu.jscript.core.exceptions;
|
||||
|
||||
public class ConvertException extends RuntimeException {
|
||||
public final String source, target;
|
@ -1,16 +1,16 @@
|
||||
package me.topchetoeu.jscript.exceptions;
|
||||
package me.topchetoeu.jscript.core.exceptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.engine.Engine;
|
||||
import me.topchetoeu.jscript.engine.Environment;
|
||||
import me.topchetoeu.jscript.engine.debug.DebugContext;
|
||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.engine.values.ObjectValue.PlaceholderProto;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.engine.Context;
|
||||
import me.topchetoeu.jscript.core.engine.Engine;
|
||||
import me.topchetoeu.jscript.core.engine.Environment;
|
||||
import me.topchetoeu.jscript.core.engine.debug.DebugContext;
|
||||
import me.topchetoeu.jscript.core.engine.values.ObjectValue;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.engine.values.ObjectValue.PlaceholderProto;
|
||||
|
||||
public class EngineException extends RuntimeException {
|
||||
public static class StackElement {
|
@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.exceptions;
|
||||
package me.topchetoeu.jscript.core.exceptions;
|
||||
|
||||
public class InterruptException extends RuntimeException {
|
||||
public InterruptException() { }
|
@ -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 final Location loc;
|
@ -1,9 +1,9 @@
|
||||
package me.topchetoeu.jscript.parsing;
|
||||
package me.topchetoeu.jscript.core.parsing;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
|
||||
public enum Operator {
|
||||
MULTIPLY("*", Operation.MULTIPLY, 13),
|
@ -1,10 +1,10 @@
|
||||
package me.topchetoeu.jscript.parsing;
|
||||
package me.topchetoeu.jscript.core.parsing;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.parsing.Parsing.Parser;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.parsing.Parsing.Parser;
|
||||
|
||||
public class ParseRes<T> {
|
||||
public static enum State {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user