Compare commits
14 Commits
TopchetoEU
...
v0.8.4-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
c123427e77
|
|||
|
7ac5ded185
|
|||
|
769d6ae8fc
|
|||
|
afb99ffc70
|
|||
|
46136e77e2
|
|||
|
b460b87318
|
|||
|
e772f0b50d
|
|||
|
187ad55291
|
|||
|
8156a1733f
|
|||
|
d1937fdb63
|
|||
|
3f826cc85d
|
|||
|
af35d7f20b
|
|||
|
cfa0e001b9
|
|||
|
c10d071346
|
10
.github/workflows/tagged-release.yml
vendored
10
.github/workflows/tagged-release.yml
vendored
@@ -16,15 +16,17 @@ jobs:
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
- name: Clone repository
|
||||
uses: GuillaumeFalourd/clone-github-repo-action@main
|
||||
with:
|
||||
branch: 'master' # fuck this political bullshitshit, took me an hour to fix this
|
||||
branch: 'master'
|
||||
owner: 'TopchetoEU'
|
||||
repository: 'java-jscript'
|
||||
- name: "Build"
|
||||
- name: Build
|
||||
run: |
|
||||
cd java-jscript; node ./build.js release ${{ github.ref }}
|
||||
cd java-jscript; gradle build
|
||||
|
||||
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
@@ -32,4 +34,4 @@ jobs:
|
||||
prerelease: false
|
||||
files: |
|
||||
java-jscript/LICENSE
|
||||
java-jscript/dst/*.jar
|
||||
java-jscript/build/libs/*.jar
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -3,7 +3,8 @@
|
||||
!/src
|
||||
!/src/**/*
|
||||
|
||||
/src/assets/js/ts.js
|
||||
!/doc
|
||||
!/doc/**/*
|
||||
|
||||
!/tests
|
||||
!/tests/**/*
|
||||
@@ -16,3 +17,6 @@
|
||||
!/build.js
|
||||
!/LICENSE
|
||||
!/README.md
|
||||
!/settings.gradle
|
||||
!/build.gradle
|
||||
!/gradle.properties
|
||||
|
||||
@@ -11,7 +11,7 @@ JScript is an engine, capable of running EcmaScript 5, written entirely in Java.
|
||||
The following is going to execute a simple javascript statement:
|
||||
|
||||
```java
|
||||
var engine = new Engine(false);
|
||||
var engine = new Engine();
|
||||
// Initialize a standard environment, with implementations of most basic standard libraries (Object, Array, Symbol, etc.)
|
||||
var env = Internals.apply(new Environment());
|
||||
|
||||
@@ -26,4 +26,4 @@ System.out.println(awaitable.await());
|
||||
|
||||
## NOTE:
|
||||
|
||||
To setup the typescript bundle in your sources, run `node build.js init-ts`. This will download the latest version of typescript, minify it, and add it to your src/assets folder. If you are going to work with the `node build.js debug|release` command, this is not a necessary step.
|
||||
To setup the typescript bundle in your sources, run `node build.js init-ts`. This will download the latest version of typescript, minify it, and add it to your src folder. If you are going to work with the `node build.js debug|release` command, this is not a necessary step.
|
||||
|
||||
37
build.gradle
Normal file
37
build.gradle
Normal file
@@ -0,0 +1,37 @@
|
||||
plugins {
|
||||
id 'application'
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes (
|
||||
'Main-Class': project.main_class
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs = [ 'src/java' ]
|
||||
main.resources.srcDirs = [ 'src/assets' ]
|
||||
}
|
||||
|
||||
processResources {
|
||||
filesMatching('metadata.json') {
|
||||
expand (
|
||||
'version': project.project_version,
|
||||
'name': project.project_name
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass = project.main_class
|
||||
}
|
||||
|
||||
archivesBaseName = project.project_name
|
||||
version = project.project_version
|
||||
173
build.js
173
build.js
@@ -1,173 +0,0 @@
|
||||
const { spawn } = require('child_process');
|
||||
const fs = require('fs/promises');
|
||||
const pt = require('path');
|
||||
const { argv, exit } = require('process');
|
||||
const { Readable } = require('stream');
|
||||
|
||||
|
||||
async function* find(src, dst, wildcard) {
|
||||
const stat = await fs.stat(src);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
for (const el of await fs.readdir(src)) {
|
||||
for await (const res of find(pt.join(src, el), dst ? pt.join(dst, el) : undefined, wildcard)) yield res;
|
||||
}
|
||||
}
|
||||
else if (stat.isFile() && wildcard(src)) yield dst ? { src, dst } : src;
|
||||
}
|
||||
async function copy(src, dst, wildcard) {
|
||||
const promises = [];
|
||||
|
||||
for await (const el of find(src, dst, wildcard)) {
|
||||
promises.push((async () => {
|
||||
await fs.mkdir(pt.dirname(el.dst), { recursive: true });
|
||||
await fs.copyFile(el.src, el.dst);
|
||||
})());
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
function run(suppressOutput, cmd, ...args) {
|
||||
return new Promise((res, rej) => {
|
||||
const proc = spawn(cmd, args, { stdio: suppressOutput ? 'ignore' : 'inherit' });
|
||||
proc.once('exit', code => {
|
||||
if (code === 0) res(code);
|
||||
else rej(new Error(`Process ${cmd} exited with code ${code}.`));
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
async function downloadTypescript(outFile) {
|
||||
try {
|
||||
// Import the required libraries, without the need of a package.json
|
||||
console.log('Importing modules...');
|
||||
await run(true, 'npm', 'i', 'tar', 'zlib', 'uglify-js');
|
||||
await fs.mkdir(pt.dirname(outFile), { recursive: true });
|
||||
await fs.mkdir('tmp', { recursive: true });
|
||||
|
||||
const tar = require('tar');
|
||||
const zlib = require('zlib');
|
||||
const { minify } = await import('uglify-js');
|
||||
|
||||
// Download the package.json file of typescript
|
||||
const packageDesc = await (await fetch('https://registry.npmjs.org/typescript/latest')).json();
|
||||
const url = packageDesc.dist.tarball;
|
||||
|
||||
console.log('Extracting typescript...');
|
||||
await new Promise(async (res, rej) => Readable.fromWeb((await fetch(url)).body)
|
||||
.pipe(zlib.createGunzip())
|
||||
.pipe(tar.x({ cwd: 'tmp', filter: v => v === 'package/lib/typescript.js' }))
|
||||
.on('end', res)
|
||||
.on('error', rej)
|
||||
);
|
||||
|
||||
console.log('Compiling typescript to ES5...');
|
||||
|
||||
const ts = require('./tmp/package/lib/typescript');
|
||||
const program = ts.createProgram([ 'tmp/package/lib/typescript.js' ], {
|
||||
outFile: "tmp/typescript-es5.js",
|
||||
target: ts.ScriptTarget.ES5,
|
||||
module: ts.ModuleKind.None,
|
||||
downlevelIteration: true,
|
||||
allowJs: true,
|
||||
});
|
||||
program.emit();
|
||||
|
||||
console.log('Minifying typescript...');
|
||||
|
||||
const minified = minify((await fs.readFile('tmp/typescript-es5.js')).toString());
|
||||
// const minified = { code: (await fs.readFile('tmp/typescript-es5.js')).toString() };
|
||||
if (minified.error) throw minified.error;
|
||||
|
||||
// Patch unsupported regex syntax
|
||||
minified.code = minified.code.replaceAll('[-/\\\\^$*+?.()|[\\]{}]', '[-/\\\\^$*+?.()|\\[\\]{}]');
|
||||
|
||||
const stream = await fs.open(outFile, 'w');
|
||||
|
||||
// Write typescript's license
|
||||
await stream.write(new TextEncoder().encode(`
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
|
||||
The following is a minified version of the unmodified Typescript 5.2
|
||||
***************************************************************************** */
|
||||
`));
|
||||
|
||||
await stream.write(minified.code);
|
||||
console.log('Typescript bundling done!');
|
||||
}
|
||||
finally {
|
||||
// Clean up all stuff left from typescript bundling
|
||||
await fs.rm('tmp', { recursive: true, force: true });
|
||||
await fs.rm('package.json');
|
||||
await fs.rm('package-lock.json');
|
||||
await fs.rm('node_modules', { recursive: true });
|
||||
}
|
||||
}
|
||||
async function compileJava(conf) {
|
||||
try {
|
||||
await fs.writeFile('Metadata.java', (await fs.readFile('src/me/topchetoeu/jscript/Metadata.java')).toString()
|
||||
.replace('${VERSION}', conf.version)
|
||||
.replace('${NAME}', conf.name)
|
||||
.replace('${AUTHOR}', conf.author)
|
||||
);
|
||||
const args = ['--release', '11', ];
|
||||
if (argv[2] === 'debug') args.push('-g');
|
||||
args.push('-d', 'dst/classes', 'Metadata.java');
|
||||
|
||||
console.log('Compiling java project...');
|
||||
for await (const path of find('src', undefined, v => v.endsWith('.java') && !v.endsWith('Metadata.java'))) args.push(path);
|
||||
await run(false, conf.javahome + 'javac', ...args);
|
||||
console.log('Compiled java project!');
|
||||
}
|
||||
finally {
|
||||
await fs.rm('Metadata.java');
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
if (argv[2] === 'init-ts') {
|
||||
await downloadTypescript('src/assets/js/ts.js');
|
||||
}
|
||||
else {
|
||||
const conf = {
|
||||
name: "java-jscript",
|
||||
author: "TopchetoEU",
|
||||
javahome: "",
|
||||
version: argv[3]
|
||||
};
|
||||
|
||||
if (conf.version.startsWith('refs/tags/')) conf.version = conf.version.substring(10);
|
||||
if (conf.version.startsWith('v')) conf.version = conf.version.substring(1);
|
||||
|
||||
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')),
|
||||
compileJava(conf),
|
||||
]);
|
||||
|
||||
await run(true, 'jar', '-c', '-f', 'dst/jscript.jar', '-e', 'me.topchetoeu.jscript.Main', '-C', 'dst/classes', '.');
|
||||
console.log('Done!');
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (argv[2] === 'debug') throw e;
|
||||
console.log(e.toString());
|
||||
exit(-1);
|
||||
}
|
||||
})();
|
||||
3
gradle.properties
Normal file
3
gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
project_name = jscript
|
||||
project_version = 0.8.4-beta
|
||||
main_class = me.topchetoeu.jscript.utils.JScriptRepl
|
||||
0
settings.gradle
Normal file
0
settings.gradle
Normal file
113
src/assets/js/bootstrap.js
vendored
113
src/assets/js/bootstrap.js
vendored
@@ -1,113 +0,0 @@
|
||||
(function (ts, env, libs) {
|
||||
var src = '', version = 0;
|
||||
var lib = libs.concat([
|
||||
'declare function exit(): never;',
|
||||
'declare function go(): any;',
|
||||
'declare function getTsDeclarations(): string[];'
|
||||
]).join('');
|
||||
var libSnapshot = ts.ScriptSnapshot.fromString(lib);
|
||||
var environments = {};
|
||||
var declSnapshots = [];
|
||||
|
||||
var settings = {
|
||||
outDir: "/out",
|
||||
declarationDir: "/out",
|
||||
target: ts.ScriptTarget.ES5,
|
||||
lib: [ ],
|
||||
module: ts.ModuleKind.None,
|
||||
declaration: true,
|
||||
stripInternal: true,
|
||||
downlevelIteration: true,
|
||||
forceConsistentCasingInFileNames: true,
|
||||
experimentalDecorators: true,
|
||||
strict: true,
|
||||
sourceMap: true,
|
||||
};
|
||||
|
||||
var reg = ts.createDocumentRegistry();
|
||||
var service = ts.createLanguageService({
|
||||
getCurrentDirectory: function() { return "/"; },
|
||||
getDefaultLibFileName: function() { return "/lib.d.ts"; },
|
||||
getScriptFileNames: function() {
|
||||
var res = [ "/src.ts", "/lib.d.ts" ];
|
||||
for (var i = 0; i < declSnapshots.length; i++) res.push("/glob." + (i + 1) + ".d.ts");
|
||||
return res;
|
||||
},
|
||||
getCompilationSettings: function () { return settings; },
|
||||
fileExists: function(filename) { return filename === "/lib.d.ts" || filename === "/src.ts" || filename === "/glob.d.ts"; },
|
||||
|
||||
getScriptSnapshot: function(filename) {
|
||||
if (filename === "/lib.d.ts") return libSnapshot;
|
||||
if (filename === "/src.ts") return ts.ScriptSnapshot.fromString(src);
|
||||
|
||||
var index = /\/glob\.(\d+)\.d\.ts/g.exec(filename);
|
||||
if (index && index[1] && (index = Number(index[1])) && index > 0 && index <= declSnapshots.length) {
|
||||
return declSnapshots[index - 1];
|
||||
}
|
||||
|
||||
throw new Error("File '" + filename + "' doesn't exist.");
|
||||
},
|
||||
getScriptVersion: function (filename) {
|
||||
if (filename === "/lib.d.ts" || filename.startsWith("/glob.")) return 0;
|
||||
else return version;
|
||||
},
|
||||
}, reg);
|
||||
|
||||
service.getEmitOutput("/lib.d.ts");
|
||||
log("Loaded libraries!");
|
||||
|
||||
var oldCompile = env.compile;
|
||||
|
||||
function compile(code, filename, env) {
|
||||
src = code;
|
||||
version++;
|
||||
|
||||
if (!environments[env.id]) environments[env.id] = []
|
||||
var decls = declSnapshots = environments[env.id];
|
||||
var emit = service.getEmitOutput("/src.ts");
|
||||
|
||||
var diagnostics = []
|
||||
.concat(service.getCompilerOptionsDiagnostics())
|
||||
.concat(service.getSyntacticDiagnostics("/src.ts"))
|
||||
.concat(service.getSemanticDiagnostics("/src.ts"))
|
||||
.map(function (diagnostic) {
|
||||
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
||||
if (diagnostic.file) {
|
||||
var pos = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
var file = diagnostic.file.fileName.substring(1);
|
||||
if (file === "src.ts") file = filename;
|
||||
return file + ":" + (pos.line + 1) + ":" + (pos.character + 1) + ": " + message;
|
||||
}
|
||||
else return message;
|
||||
});
|
||||
|
||||
if (diagnostics.length > 0) {
|
||||
throw new SyntaxError(diagnostics.join("\n"));
|
||||
}
|
||||
|
||||
var map = JSON.parse(emit.outputFiles[0].text);
|
||||
var result = emit.outputFiles[1].text;
|
||||
var declaration = emit.outputFiles[2].text;
|
||||
|
||||
var compiled = oldCompile(result, filename, env);
|
||||
|
||||
return {
|
||||
function: function () {
|
||||
var val = compiled.function.apply(this, arguments);
|
||||
if (declaration !== '') decls.push(ts.ScriptSnapshot.fromString(declaration));
|
||||
return val;
|
||||
},
|
||||
breakpoints: compiled.breakpoints,
|
||||
mapChain: compiled.mapChain.concat(map.mappings),
|
||||
};
|
||||
}
|
||||
|
||||
function apply(env) {
|
||||
env.compile = compile;
|
||||
env.global.getTsDeclarations = function() {
|
||||
return environments[env.id];
|
||||
}
|
||||
}
|
||||
|
||||
apply(env);
|
||||
})(arguments[0], arguments[1], arguments[2]);
|
||||
623
src/assets/js/lib.d.ts
vendored
623
src/assets/js/lib.d.ts
vendored
@@ -1,623 +0,0 @@
|
||||
type PropertyDescriptor<T, ThisT> = {
|
||||
value: any;
|
||||
writable?: boolean;
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
} | {
|
||||
get?(this: ThisT): T;
|
||||
set(this: ThisT, val: T): void;
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
} | {
|
||||
get(this: ThisT): T;
|
||||
set?(this: ThisT, val: T): void;
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
};
|
||||
type Exclude<T, U> = T extends U ? never : T;
|
||||
type Extract<T, U> = T extends U ? T : never;
|
||||
type Record<KeyT extends string | number | symbol, ValT> = { [x in KeyT]: ValT }
|
||||
type ReplaceFunc = (match: string, ...args: any[]) => string;
|
||||
|
||||
type PromiseResult<T> = { type: 'fulfilled'; value: T; } | { type: 'rejected'; reason: any; }
|
||||
|
||||
// wippidy-wine, this code is now mine :D
|
||||
type Awaited<T> =
|
||||
T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
|
||||
T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
|
||||
F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument
|
||||
Awaited<V> : // recursively unwrap the value
|
||||
never : // the argument to `then` was not callable
|
||||
T;
|
||||
|
||||
type IteratorYieldResult<TReturn> =
|
||||
{ done?: false; } &
|
||||
(TReturn extends undefined ? { value?: undefined; } : { value: TReturn; });
|
||||
|
||||
type IteratorReturnResult<TReturn> =
|
||||
{ done: true } &
|
||||
(TReturn extends undefined ? { value?: undefined; } : { value: TReturn; });
|
||||
|
||||
type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
|
||||
|
||||
interface Thenable<T> {
|
||||
then<NextT = void>(onFulfilled?: (val: T) => NextT, onRejected?: (err: any) => NextT): Promise<Awaited<NextT>>;
|
||||
}
|
||||
|
||||
interface RegExpResultIndices extends Array<[number, number]> {
|
||||
groups?: { [name: string]: [number, number]; };
|
||||
}
|
||||
interface RegExpResult extends Array<string> {
|
||||
groups?: { [name: string]: string; };
|
||||
index: number;
|
||||
input: string;
|
||||
indices?: RegExpResultIndices;
|
||||
escape(raw: string, flags: string): RegExp;
|
||||
}
|
||||
|
||||
interface Matcher {
|
||||
[Symbol.match](target: string): RegExpResult | string[] | null;
|
||||
[Symbol.matchAll](target: string): IterableIterator<RegExpResult>;
|
||||
}
|
||||
interface Splitter {
|
||||
[Symbol.split](target: string, limit?: number, sensible?: boolean): string[];
|
||||
}
|
||||
interface Replacer {
|
||||
[Symbol.replace](target: string, replacement: string | ReplaceFunc): string;
|
||||
}
|
||||
interface Searcher {
|
||||
[Symbol.search](target: string, reverse?: boolean, start?: number): number;
|
||||
}
|
||||
|
||||
type FlatArray<Arr, Depth extends number> = {
|
||||
"done": Arr,
|
||||
"recur": Arr extends Array<infer InnerArr>
|
||||
? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]>
|
||||
: Arr
|
||||
}[Depth extends -1 ? "done" : "recur"];
|
||||
|
||||
interface IArguments {
|
||||
[i: number]: any;
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface Iterator<T, TReturn = any, TNext = undefined> {
|
||||
next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
|
||||
return?(value?: TReturn): IteratorResult<T, TReturn>;
|
||||
throw?(e?: any): IteratorResult<T, TReturn>;
|
||||
}
|
||||
interface Iterable<T> {
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface AsyncIterator<T, TReturn = any, TNext = undefined> {
|
||||
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
return?(value?: TReturn | Thenable<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
|
||||
}
|
||||
interface AsyncIterable<T> {
|
||||
[Symbol.asyncIterator](): AsyncIterator<T>;
|
||||
}
|
||||
interface AsyncIterableIterator<T> extends AsyncIterator<T> {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
||||
}
|
||||
|
||||
interface Generator<T = unknown, TReturn = void, TNext = unknown> extends Iterator<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): Generator<T, TReturn, TNext>;
|
||||
return(value: TReturn): IteratorResult<T, TReturn>;
|
||||
throw(e: any): IteratorResult<T, TReturn>;
|
||||
}
|
||||
interface GeneratorFunction {
|
||||
new (...args: any[]): Generator;
|
||||
(...args: any[]): Generator;
|
||||
readonly length: number;
|
||||
readonly name: string;
|
||||
readonly prototype: Generator;
|
||||
}
|
||||
|
||||
interface AsyncGenerator<T = unknown, TReturn = void, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
|
||||
return(value: TReturn | Thenable<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
throw(e: any): Promise<IteratorResult<T, TReturn>>;
|
||||
[Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
|
||||
}
|
||||
interface AsyncGeneratorFunction {
|
||||
new (...args: any[]): AsyncGenerator;
|
||||
(...args: any[]): AsyncGenerator;
|
||||
readonly length: number;
|
||||
readonly name: string;
|
||||
readonly prototype: AsyncGenerator;
|
||||
}
|
||||
|
||||
|
||||
interface MathObject {
|
||||
readonly E: number;
|
||||
readonly PI: number;
|
||||
readonly SQRT2: number;
|
||||
readonly SQRT1_2: number;
|
||||
readonly LN2: number;
|
||||
readonly LN10: number;
|
||||
readonly LOG2E: number;
|
||||
readonly LOG10E: number;
|
||||
|
||||
asin(x: number): number;
|
||||
acos(x: number): number;
|
||||
atan(x: number): number;
|
||||
atan2(y: number, x: number): number;
|
||||
asinh(x: number): number;
|
||||
acosh(x: number): number;
|
||||
atanh(x: number): number;
|
||||
sin(x: number): number;
|
||||
cos(x: number): number;
|
||||
tan(x: number): number;
|
||||
sinh(x: number): number;
|
||||
cosh(x: number): number;
|
||||
tanh(x: number): number;
|
||||
sqrt(x: number): number;
|
||||
cbrt(x: number): number;
|
||||
hypot(...vals: number[]): number;
|
||||
imul(a: number, b: number): number;
|
||||
exp(x: number): number;
|
||||
expm1(x: number): number;
|
||||
pow(x: number, y: number): number;
|
||||
log(x: number): number;
|
||||
log10(x: number): number;
|
||||
log1p(x: number): number;
|
||||
log2(x: number): number;
|
||||
ceil(x: number): number;
|
||||
floor(x: number): number;
|
||||
round(x: number): number;
|
||||
fround(x: number): number;
|
||||
trunc(x: number): number;
|
||||
abs(x: number): number;
|
||||
max(...vals: number[]): number;
|
||||
min(...vals: number[]): number;
|
||||
sign(x: number): number;
|
||||
random(): number;
|
||||
clz32(x: number): number;
|
||||
}
|
||||
|
||||
interface Array<T> extends IterableIterator<T> {
|
||||
[i: number]: T;
|
||||
|
||||
length: number;
|
||||
|
||||
toString(): string;
|
||||
// toLocaleString(): string;
|
||||
join(separator?: string): string;
|
||||
fill(val: T, start?: number, end?: number): T[];
|
||||
pop(): T | undefined;
|
||||
push(...items: T[]): number;
|
||||
concat(...items: (T | T[])[]): T[];
|
||||
concat(...items: (T | T[])[]): T[];
|
||||
join(separator?: string): string;
|
||||
reverse(): T[];
|
||||
shift(): T | undefined;
|
||||
slice(start?: number, end?: number): T[];
|
||||
sort(compareFn?: (a: T, b: T) => number): this;
|
||||
splice(start: number, deleteCount?: number | undefined, ...items: T[]): T[];
|
||||
unshift(...items: T[]): number;
|
||||
indexOf(searchElement: T, fromIndex?: number): number;
|
||||
lastIndexOf(searchElement: T, fromIndex?: number): number;
|
||||
every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean;
|
||||
some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean;
|
||||
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
|
||||
includes(el: any, start?: number): boolean;
|
||||
|
||||
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];
|
||||
filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[];
|
||||
find(predicate: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[];
|
||||
findIndex(predicate: (value: T, index: number, array: T[]) => boolean, thisArg?: any): number;
|
||||
findLast(predicate: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[];
|
||||
findLastIndex(predicate: (value: T, index: number, array: T[]) => boolean, thisArg?: any): number;
|
||||
|
||||
flat<D extends number = 1>(depth?: D): FlatArray<T, D>;
|
||||
flatMap(func: (val: T, i: number, arr: T[]) => T | T[], thisAarg?: any): FlatArray<T[], 1>;
|
||||
sort(func?: (a: T, b: T) => number): this;
|
||||
|
||||
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
|
||||
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
|
||||
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
|
||||
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
|
||||
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
|
||||
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
|
||||
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
values(): IterableIterator<T>;
|
||||
keys(): IterableIterator<number>;
|
||||
}
|
||||
interface ArrayConstructor {
|
||||
new <T>(arrayLength?: number): T[];
|
||||
new <T>(...items: T[]): T[];
|
||||
<T>(arrayLength?: number): T[];
|
||||
<T>(...items: T[]): T[];
|
||||
isArray(arg: any): arg is any[];
|
||||
prototype: Array<any>;
|
||||
}
|
||||
|
||||
interface Boolean {
|
||||
toString(): string;
|
||||
valueOf(): boolean;
|
||||
}
|
||||
interface BooleanConstructor {
|
||||
(val: any): boolean;
|
||||
new (val: any): Boolean;
|
||||
prototype: Boolean;
|
||||
}
|
||||
|
||||
interface Error {
|
||||
name: string;
|
||||
message: string;
|
||||
stack: string[];
|
||||
toString(): string;
|
||||
}
|
||||
interface ErrorConstructor {
|
||||
(msg?: any): Error;
|
||||
new (msg?: any): Error;
|
||||
prototype: Error;
|
||||
}
|
||||
|
||||
interface TypeErrorConstructor extends ErrorConstructor {
|
||||
(msg?: any): TypeError;
|
||||
new (msg?: any): TypeError;
|
||||
prototype: Error;
|
||||
}
|
||||
interface TypeError extends Error {
|
||||
name: 'TypeError';
|
||||
}
|
||||
|
||||
interface RangeErrorConstructor extends ErrorConstructor {
|
||||
(msg?: any): RangeError;
|
||||
new (msg?: any): RangeError;
|
||||
prototype: Error;
|
||||
}
|
||||
interface RangeError extends Error {
|
||||
name: 'RangeError';
|
||||
}
|
||||
|
||||
interface SyntaxErrorConstructor extends ErrorConstructor {
|
||||
(msg?: any): RangeError;
|
||||
new (msg?: any): RangeError;
|
||||
prototype: Error;
|
||||
}
|
||||
interface SyntaxError extends Error {
|
||||
name: 'SyntaxError';
|
||||
}
|
||||
|
||||
interface Function {
|
||||
apply(this: Function, thisArg: any, argArray?: any): any;
|
||||
call(this: Function, thisArg: any, ...argArray: any[]): any;
|
||||
bind(this: Function, thisArg: any, ...argArray: any[]): Function;
|
||||
|
||||
toString(): string;
|
||||
|
||||
prototype: any;
|
||||
readonly length: number;
|
||||
name: string;
|
||||
}
|
||||
interface CallableFunction extends Function {
|
||||
(...args: any[]): any;
|
||||
apply<ThisArg, Args extends any[], RetT>(this: (this: ThisArg, ...args: Args) => RetT, thisArg: ThisArg, argArray?: Args): RetT;
|
||||
call<ThisArg, Args extends any[], RetT>(this: (this: ThisArg, ...args: Args) => RetT, thisArg: ThisArg, ...argArray: Args): RetT;
|
||||
bind<ThisArg, Args extends any[], Rest extends any[], RetT>(this: (this: ThisArg, ...args: [ ...Args, ...Rest ]) => RetT, thisArg: ThisArg, ...argArray: Args): (this: void, ...args: Rest) => RetT;
|
||||
}
|
||||
interface NewableFunction extends Function {
|
||||
new(...args: any[]): any;
|
||||
apply<Args extends any[], RetT>(this: new (...args: Args) => RetT, thisArg: any, argArray?: Args): RetT;
|
||||
call<Args extends any[], RetT>(this: new (...args: Args) => RetT, thisArg: any, ...argArray: Args): RetT;
|
||||
bind<Args extends any[], RetT>(this: new (...args: Args) => RetT, thisArg: any, ...argArray: Args): new (...args: Args) => RetT;
|
||||
}
|
||||
interface FunctionConstructor extends Function {
|
||||
(...args: string[]): (...args: any[]) => any;
|
||||
new (...args: string[]): (...args: any[]) => any;
|
||||
prototype: Function;
|
||||
async<ArgsT extends any[], RetT>(
|
||||
func: (await: <T>(val: T) => Awaited<T>) => (...args: ArgsT) => RetT
|
||||
): (...args: ArgsT) => Promise<RetT>;
|
||||
asyncGenerator<ArgsT extends any[], RetT>(
|
||||
func: (await: <T>(val: T) => Awaited<T>, _yield: <T>(val: T) => void) => (...args: ArgsT) => RetT
|
||||
): (...args: ArgsT) => AsyncGenerator<RetT>;
|
||||
generator<ArgsT extends any[], T = unknown, RetT = unknown, TNext = unknown>(
|
||||
func: (_yield: <T>(val: T) => TNext) => (...args: ArgsT) => RetT
|
||||
): (...args: ArgsT) => Generator<T, RetT, TNext>;
|
||||
}
|
||||
|
||||
interface Number {
|
||||
toString(): string;
|
||||
valueOf(): number;
|
||||
}
|
||||
interface NumberConstructor {
|
||||
(val: any): number;
|
||||
new (val: any): Number;
|
||||
prototype: Number;
|
||||
parseInt(val: unknown): number;
|
||||
parseFloat(val: unknown): number;
|
||||
}
|
||||
|
||||
interface Object {
|
||||
constructor: NewableFunction;
|
||||
[Symbol.typeName]: string;
|
||||
|
||||
valueOf(): this;
|
||||
toString(): string;
|
||||
hasOwnProperty(key: any): boolean;
|
||||
}
|
||||
interface ObjectConstructor {
|
||||
(arg: string): String;
|
||||
(arg: number): Number;
|
||||
(arg: boolean): Boolean;
|
||||
(arg?: undefined | null): {};
|
||||
<T extends object>(arg: T): T;
|
||||
|
||||
new (arg: string): String;
|
||||
new (arg: number): Number;
|
||||
new (arg: boolean): Boolean;
|
||||
new (arg?: undefined | null): {};
|
||||
new <T extends object>(arg: T): T;
|
||||
|
||||
prototype: Object;
|
||||
|
||||
assign<T extends object>(target: T, ...src: object[]): T;
|
||||
create<T extends object>(proto: T, props?: { [key: string]: PropertyDescriptor<any, T> }): T;
|
||||
|
||||
keys<T extends object>(obj: T, onlyString?: true): (keyof T)[];
|
||||
keys<T extends object>(obj: T, onlyString: false): any[];
|
||||
entries<T extends object>(obj: T, onlyString?: true): [keyof T, T[keyof T]][];
|
||||
entries<T extends object>(obj: T, onlyString: false): [any, any][];
|
||||
values<T extends object>(obj: T, onlyString?: true): (T[keyof T])[];
|
||||
values<T extends object>(obj: T, onlyString: false): any[];
|
||||
|
||||
fromEntries(entries: Iterable<[any, any]>): object;
|
||||
|
||||
defineProperty<T, ThisT extends object>(obj: ThisT, key: any, desc: PropertyDescriptor<T, ThisT>): ThisT;
|
||||
defineProperties<ThisT extends object>(obj: ThisT, desc: { [key: string]: PropertyDescriptor<any, ThisT> }): ThisT;
|
||||
|
||||
getOwnPropertyNames<T extends object>(obj: T): (keyof T)[];
|
||||
getOwnPropertySymbols<T extends object>(obj: T): (keyof T)[];
|
||||
hasOwn<T extends object, KeyT>(obj: T, key: KeyT): boolean;
|
||||
|
||||
getOwnPropertyDescriptor<T extends object, KeyT extends keyof T>(obj: T, key: KeyT): PropertyDescriptor<T[KeyT], T>;
|
||||
getOwnPropertyDescriptors<T extends object>(obj: T): { [x in keyof T]: PropertyDescriptor<T[x], T> };
|
||||
|
||||
getPrototypeOf(obj: any): object | null;
|
||||
setPrototypeOf<T>(obj: T, proto: object | null): T;
|
||||
|
||||
preventExtensions<T extends object>(obj: T): T;
|
||||
seal<T extends object>(obj: T): T;
|
||||
freeze<T extends object>(obj: T): T;
|
||||
|
||||
isExtensible(obj: object): boolean;
|
||||
isSealed(obj: object): boolean;
|
||||
isFrozen(obj: object): boolean;
|
||||
}
|
||||
|
||||
interface String {
|
||||
[i: number]: string;
|
||||
|
||||
toString(): string;
|
||||
valueOf(): string;
|
||||
|
||||
charAt(pos: number): string;
|
||||
charCodeAt(pos: number): number;
|
||||
substring(start?: number, end?: number): string;
|
||||
slice(start?: number, end?: number): string;
|
||||
substr(start?: number, length?: number): string;
|
||||
|
||||
startsWith(str: string, pos?: number): string;
|
||||
endsWith(str: string, pos?: number): string;
|
||||
|
||||
replace(pattern: string | Replacer, val: string | ReplaceFunc): string;
|
||||
replaceAll(pattern: string | Replacer, val: string | ReplaceFunc): string;
|
||||
|
||||
match(pattern: string | Matcher): RegExpResult | string[] | null;
|
||||
matchAll(pattern: string | Matcher): IterableIterator<RegExpResult>;
|
||||
|
||||
split(pattern: string | Splitter, limit?: number, sensible?: boolean): string;
|
||||
|
||||
concat(...others: string[]): string;
|
||||
indexOf(term: string | Searcher, start?: number): number;
|
||||
lastIndexOf(term: string | Searcher, start?: number): number;
|
||||
|
||||
toLowerCase(): string;
|
||||
toUpperCase(): string;
|
||||
|
||||
trim(): string;
|
||||
|
||||
includes(term: string, start?: number): boolean;
|
||||
|
||||
length: number;
|
||||
}
|
||||
interface StringConstructor {
|
||||
(val: any): string;
|
||||
new (val: any): String;
|
||||
|
||||
fromCharCode(val: number): string;
|
||||
|
||||
prototype: String;
|
||||
}
|
||||
|
||||
interface Symbol {
|
||||
valueOf(): symbol;
|
||||
}
|
||||
interface SymbolConstructor {
|
||||
(val?: any): symbol;
|
||||
new(...args: any[]): never;
|
||||
prototype: Symbol;
|
||||
for(key: string): symbol;
|
||||
keyFor(sym: symbol): string;
|
||||
|
||||
readonly typeName: unique symbol;
|
||||
readonly match: unique symbol;
|
||||
readonly matchAll: unique symbol;
|
||||
readonly split: unique symbol;
|
||||
readonly replace: unique symbol;
|
||||
readonly search: unique symbol;
|
||||
readonly iterator: unique symbol;
|
||||
readonly asyncIterator: unique symbol;
|
||||
}
|
||||
|
||||
|
||||
interface Promise<T> extends Thenable<T> {
|
||||
catch<ResT = void>(func: (err: unknown) => ResT): Promise<ResT>;
|
||||
finally(func: () => void): Promise<T>;
|
||||
constructor: PromiseConstructor;
|
||||
}
|
||||
interface PromiseConstructorLike {
|
||||
new <T>(func: (res: (val: T) => void, rej: (err: unknown) => void) => void): Thenable<Awaited<T>>;
|
||||
}
|
||||
interface PromiseConstructor extends PromiseConstructorLike {
|
||||
prototype: Promise<any>;
|
||||
|
||||
new <T>(func: (res: (val: T) => void, rej: (err: unknown) => void) => void): Promise<Awaited<T>>;
|
||||
resolve<T>(val: T): Promise<Awaited<T>>;
|
||||
reject(val: any): Promise<never>;
|
||||
|
||||
isAwaitable(val: unknown): val is Thenable<any>;
|
||||
any<T>(promises: T[]): Promise<Awaited<T>>;
|
||||
race<T>(promises: (Promise<T>|T)[]): Promise<T>;
|
||||
all<T extends any[]>(promises: T): Promise<{ [Key in keyof T]: Awaited<T[Key]> }>;
|
||||
allSettled<T extends any[]>(...promises: T): Promise<[...{ [P in keyof T]: PromiseResult<Awaited<T[P]>>}]>;
|
||||
}
|
||||
|
||||
interface FileStat {
|
||||
type: 'file' | 'folder';
|
||||
mode: 'r' | 'rw';
|
||||
}
|
||||
interface File {
|
||||
readonly pointer: Promise<number>;
|
||||
readonly length: Promise<number>;
|
||||
|
||||
read(n: number): Promise<number[]>;
|
||||
write(buff: number[]): Promise<void>;
|
||||
close(): Promise<void>;
|
||||
seek(offset: number, whence: number): Promise<void>;
|
||||
}
|
||||
interface Filesystem {
|
||||
readonly SEEK_SET: 0;
|
||||
readonly SEEK_CUR: 1;
|
||||
readonly SEEK_END: 2;
|
||||
|
||||
open(path: string, mode: 'r' | 'rw'): Promise<File>;
|
||||
ls(path: string): AsyncIterableIterator<string>;
|
||||
mkdir(path: string): Promise<void>;
|
||||
mkfile(path: string): Promise<void>;
|
||||
rm(path: string, recursive?: boolean): Promise<void>;
|
||||
stat(path: string): Promise<FileStat>;
|
||||
exists(path: string): Promise<boolean>;
|
||||
normalize(...paths: string[]): string;
|
||||
}
|
||||
|
||||
interface Encoding {
|
||||
encode(val: string): number[];
|
||||
decode(val: number[]): string;
|
||||
}
|
||||
|
||||
declare var String: StringConstructor;
|
||||
//@ts-ignore
|
||||
declare const arguments: IArguments;
|
||||
declare var NaN: number;
|
||||
declare var Infinity: number;
|
||||
|
||||
declare var setTimeout: <T extends any[]>(handle: (...args: [ ...T, ...any[] ]) => void, delay?: number, ...args: T) => number;
|
||||
declare var setInterval: <T extends any[]>(handle: (...args: [ ...T, ...any[] ]) => void, delay?: number, ...args: T) => number;
|
||||
|
||||
declare var clearTimeout: (id: number) => void;
|
||||
declare var clearInterval: (id: number) => void;
|
||||
|
||||
declare var parseInt: typeof Number.parseInt;
|
||||
declare var parseFloat: typeof Number.parseFloat;
|
||||
|
||||
declare function log(...vals: any[]): void;
|
||||
declare function require(name: string): any;
|
||||
|
||||
declare var Array: ArrayConstructor;
|
||||
declare var Boolean: BooleanConstructor;
|
||||
declare var Promise: PromiseConstructor;
|
||||
declare var Function: FunctionConstructor;
|
||||
declare var Number: NumberConstructor;
|
||||
declare var Object: ObjectConstructor;
|
||||
declare var Symbol: SymbolConstructor;
|
||||
declare var Promise: PromiseConstructor;
|
||||
declare var Math: MathObject;
|
||||
declare var Encoding: Encoding;
|
||||
declare var Filesystem: Filesystem;
|
||||
|
||||
declare var Error: ErrorConstructor;
|
||||
declare var RangeError: RangeErrorConstructor;
|
||||
declare var TypeError: TypeErrorConstructor;
|
||||
declare var SyntaxError: SyntaxErrorConstructor;
|
||||
declare var self: typeof globalThis;
|
||||
|
||||
declare class Map<KeyT, ValueT> {
|
||||
public [Symbol.iterator](): IterableIterator<[KeyT, ValueT]>;
|
||||
|
||||
public clear(): void;
|
||||
public delete(key: KeyT): boolean;
|
||||
|
||||
public entries(): IterableIterator<[KeyT, ValueT]>;
|
||||
public keys(): IterableIterator<KeyT>;
|
||||
public values(): IterableIterator<ValueT>;
|
||||
|
||||
public get(key: KeyT): ValueT;
|
||||
public set(key: KeyT, val: ValueT): this;
|
||||
public has(key: KeyT): boolean;
|
||||
|
||||
public get size(): number;
|
||||
|
||||
public forEach(func: (val: ValueT, key: KeyT, map: Map<KeyT, ValueT>) => void, thisArg?: any): void;
|
||||
|
||||
public constructor();
|
||||
}
|
||||
declare class Set<T> {
|
||||
public [Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
public entries(): IterableIterator<[T, T]>;
|
||||
public keys(): IterableIterator<T>;
|
||||
public values(): IterableIterator<T>;
|
||||
|
||||
public clear(): void;
|
||||
|
||||
public add(val: T): this;
|
||||
public delete(val: T): boolean;
|
||||
public has(key: T): boolean;
|
||||
|
||||
public get size(): number;
|
||||
|
||||
public forEach(func: (key: T, value: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
|
||||
public constructor();
|
||||
}
|
||||
|
||||
declare class RegExp implements Matcher, Splitter, Replacer, Searcher {
|
||||
static escape(raw: any, flags?: string): RegExp;
|
||||
|
||||
prototype: RegExp;
|
||||
|
||||
exec(val: string): RegExpResult | null;
|
||||
test(val: string): boolean;
|
||||
toString(): string;
|
||||
|
||||
[Symbol.match](target: string): RegExpResult | string[] | null;
|
||||
[Symbol.matchAll](target: string): IterableIterator<RegExpResult>;
|
||||
[Symbol.split](target: string, limit?: number, sensible?: boolean): string[];
|
||||
[Symbol.replace](target: string, replacement: string | ReplaceFunc): string;
|
||||
[Symbol.search](target: string, reverse?: boolean, start?: number): number;
|
||||
|
||||
readonly dotAll: boolean;
|
||||
readonly global: boolean;
|
||||
readonly hasIndices: boolean;
|
||||
readonly ignoreCase: boolean;
|
||||
readonly multiline: boolean;
|
||||
readonly sticky: boolean;
|
||||
readonly unicode: boolean;
|
||||
|
||||
readonly source: string;
|
||||
readonly flags: string;
|
||||
|
||||
lastIndex: number;
|
||||
|
||||
constructor(pattern?: string, flags?: string);
|
||||
constructor(pattern?: RegExp, flags?: string);
|
||||
}
|
||||
5
src/assets/metadata.json
Normal file
5
src/assets/metadata.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "${version}",
|
||||
"name": "${name}",
|
||||
"author": "TopchetoEU"
|
||||
}
|
||||
@@ -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,9 +1,18 @@
|
||||
package me.topchetoeu.jscript;
|
||||
package me.topchetoeu.jscript.common;
|
||||
|
||||
import me.topchetoeu.jscript.common.json.JSON;
|
||||
|
||||
public class Metadata {
|
||||
private static final String VERSION = "${VERSION}";
|
||||
private static final String AUTHOR = "${AUTHOR}";
|
||||
private static final String NAME = "${NAME}";
|
||||
private static final String VERSION;
|
||||
private static final String AUTHOR;
|
||||
private static final String NAME;
|
||||
|
||||
static {
|
||||
var data = JSON.parse(null, Reading.resourceToString("metadata.json")).map();
|
||||
VERSION = data.string("version");
|
||||
AUTHOR = data.string("author");
|
||||
NAME = data.string("name");
|
||||
}
|
||||
|
||||
public static String version() {
|
||||
if (VERSION.equals("$" + "{VERSION}")) return "1337-devel";
|
||||
@@ -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.mapping;
|
||||
package me.topchetoeu.jscript.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -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),
|
||||
@@ -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,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,10 +407,10 @@ 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);
|
||||
|
||||
|
||||
if (ret != null && func instanceof FunctionValue && ((FunctionValue)func).special) return ret;
|
||||
return res;
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.parsing;
|
||||
package me.topchetoeu.jscript.core.parsing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -8,19 +8,19 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.*;
|
||||
import me.topchetoeu.jscript.compilation.VariableDeclareStatement.Pair;
|
||||
import me.topchetoeu.jscript.compilation.control.*;
|
||||
import me.topchetoeu.jscript.compilation.control.SwitchStatement.SwitchCase;
|
||||
import me.topchetoeu.jscript.compilation.values.*;
|
||||
import me.topchetoeu.jscript.engine.Environment;
|
||||
import me.topchetoeu.jscript.engine.Operation;
|
||||
import me.topchetoeu.jscript.engine.scope.LocalScopeRecord;
|
||||
import me.topchetoeu.jscript.engine.values.Values;
|
||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.parsing.ParseRes.State;
|
||||
import me.topchetoeu.jscript.common.Filename;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.compilation.*;
|
||||
import me.topchetoeu.jscript.core.compilation.VariableDeclareStatement.Pair;
|
||||
import me.topchetoeu.jscript.core.compilation.control.*;
|
||||
import me.topchetoeu.jscript.core.compilation.control.SwitchStatement.SwitchCase;
|
||||
import me.topchetoeu.jscript.core.compilation.values.*;
|
||||
import me.topchetoeu.jscript.core.engine.Environment;
|
||||
import me.topchetoeu.jscript.core.engine.Operation;
|
||||
import me.topchetoeu.jscript.core.engine.scope.LocalScopeRecord;
|
||||
import me.topchetoeu.jscript.core.engine.values.Values;
|
||||
import me.topchetoeu.jscript.core.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.core.parsing.ParseRes.State;
|
||||
|
||||
// TODO: this has to be rewritten
|
||||
public class Parsing {
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.parsing;
|
||||
package me.topchetoeu.jscript.core.parsing;
|
||||
|
||||
public class RawToken {
|
||||
public final String value;
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.topchetoeu.jscript.parsing;
|
||||
package me.topchetoeu.jscript.core.parsing;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.parsing.ParseRes.State;
|
||||
import me.topchetoeu.jscript.common.Location;
|
||||
import me.topchetoeu.jscript.core.parsing.ParseRes.State;
|
||||
|
||||
public class TestRes {
|
||||
public final State state;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user