Compare commits
31 Commits
b97e4bf163
...
v0.10.2-be
| Author | SHA1 | Date | |
|---|---|---|---|
|
1d50ff14c5
|
|||
|
a6c458cb23
|
|||
|
31e2e95bc8
|
|||
|
98dde69751
|
|||
|
ec1edb981e
|
|||
|
36f9839485
|
|||
|
22f36267c0
|
|||
|
f8b9776f28
|
|||
|
12cff84666
|
|||
|
7058a689a2
|
|||
|
fde8b42e36
|
|||
|
4ea14ca1f5
|
|||
|
f6ce261485
|
|||
|
51b347e0d7
|
|||
|
0b6484e0b4
|
|||
|
07e0d0ba3b
|
|||
|
93cae33bb0
|
|||
|
b1e0db627c
|
|||
|
4fd05e9e6f
|
|||
|
de93adde8f
|
|||
|
5c68c1717c
|
|||
|
7883af7fff
|
|||
|
3d5be60fc7
|
|||
|
ba0b4e06ad
|
|||
|
58e3546459
|
|||
|
57097e46ca
|
|||
| 28e72503a6 | |||
| d0a0796e14 | |||
| 0de54e5505 | |||
| 96c9d29a6a | |||
| 37dc844cc4 |
25
.github/workflows/tagged-release.yml
vendored
25
.github/workflows/tagged-release.yml
vendored
@@ -11,27 +11,24 @@ jobs:
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
java-version: '17'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
- name: Clone repository
|
||||
uses: GuillaumeFalourd/clone-github-repo-action@main
|
||||
with:
|
||||
branch: 'master'
|
||||
owner: 'TopchetoEU'
|
||||
repository: 'java-jscript'
|
||||
cache-disabled: true
|
||||
gradle-version: "8.10"
|
||||
- name: Build
|
||||
run: |
|
||||
cd java-jscript; gradle build
|
||||
|
||||
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||
run: gradle build
|
||||
- name: Create release
|
||||
uses: "https://gitea.com/actions/gitea-release-action@main"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
prerelease: false
|
||||
# api_key: "${{secrets.TOKEN}}"
|
||||
files: |
|
||||
java-jscript/LICENSE
|
||||
java-jscript/build/libs/*.jar
|
||||
LICENSE
|
||||
build/libs/*.jar
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,3 +16,4 @@
|
||||
|
||||
!/package.json
|
||||
!/rollup.config.js
|
||||
!/tsconfig.json
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
# JScript
|
||||
|
||||
**NOTE: This had nothing to do with Microsoft's dialect of EcmaScript**
|
||||
# J2S (Java-JavaScript or Java to JavaScript)
|
||||
|
||||
**WARNING: Currently, this code is undocumented. Proceed with caution and a psychiatrist.**
|
||||
|
||||
JScript is an engine, capable of running EcmaScript 5, written entirely in Java. This engine has been developed with the goal of being easy to integrate with your preexisting codebase, **THE GOAL OF THIS ENGINE IS NOT PERFORMANCE**. My crude experiments show that this engine is 50x-100x slower than V8, which, although bad, is acceptable for most simple scripting purposes. Note that although the codebase has a Main class, this isn't meant to be a standalone program, but instead a library for running JavaScript code.
|
||||
J2S is an engine, capable of running EcmaScript 5, written entirely in Java. This engine has been developed with the goal of being easy to integrate with your preexisting codebase, **THE GOAL OF THIS ENGINE IS NOT PERFORMANCE**. My crude experiments show that this engine is 50x-100x slower than V8, which, although bad, is acceptable for most simple scripting purposes. Note that although the codebase has a Main class, this isn't meant to be a standalone program, but instead a library for running JavaScript code.
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ node {
|
||||
}
|
||||
|
||||
task compileEnv(type: NpmTask) {
|
||||
dependsOn npmInstall;
|
||||
|
||||
inputs.files('rollup.config.js');
|
||||
inputs.dir('src/lib/libs');
|
||||
outputs.files("build/js/env.js");
|
||||
@@ -30,6 +32,8 @@ task compileEnv(type: NpmTask) {
|
||||
args = ['run', 'build-env'];
|
||||
}
|
||||
task compileTypescript(type: NpmTask) {
|
||||
dependsOn npmInstall;
|
||||
|
||||
inputs.files('rollup.config.js');
|
||||
inputs.dir('src/lib/transpiler');
|
||||
outputs.files("build/js/ts.js");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
project_group = me.topchetoeu
|
||||
project_name = jscript
|
||||
project_version = 0.9.41-beta
|
||||
main_class = me.topchetoeu.jscript.repl.SimpleRepl
|
||||
project_name = j2s
|
||||
project_version = 0.10.2-beta
|
||||
main_class = me.topchetoeu.j2s.repl.SimpleRepl
|
||||
|
||||
@@ -7,7 +7,7 @@ const nodeResolve = require("@rollup/plugin-node-resolve");
|
||||
const json = require("@rollup/plugin-json");
|
||||
const { resolve } = require("path");
|
||||
|
||||
const shouldMinify = () => false;
|
||||
const shouldMinify = () => true;
|
||||
const shouldEmitSourcemaps = () => true;
|
||||
const shouldPolyfill = () => !!process.env.POLYFILLS;
|
||||
|
||||
@@ -99,6 +99,7 @@ const construct = (input, output) => defineConfig({
|
||||
shouldMinify() && terser({
|
||||
sourceMap: shouldEmitSourcemaps(),
|
||||
keep_classnames: true,
|
||||
keep_fnames: true,
|
||||
}),
|
||||
],
|
||||
output: {
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
import { object, setGlobalPrototypes, target } from "./primordials.ts";
|
||||
import { Error, RangeError, SyntaxError, TypeError } from "./errors.ts";
|
||||
import { Boolean } from "./boolean.ts";
|
||||
import { Function } from "./function.ts";
|
||||
import { Number } from "./number.ts";
|
||||
import { Object } from "./object.ts";
|
||||
import { String } from "./string.ts";
|
||||
import { Symbol } from "./symbol.ts";
|
||||
import { Array } from "./array.ts";
|
||||
import { Map, WeakMap } from "./map.ts";
|
||||
import { RegExp } from "./regex.ts";
|
||||
import { Date } from "./date.ts";
|
||||
import { Math as _Math } from "./math.ts";
|
||||
import { Set, WeakSet } from "./set.ts";
|
||||
import { JSON } from "./json.ts";
|
||||
import { console } from "./console.ts";
|
||||
import { Error, RangeError, SyntaxError, TypeError } from "./values/errors.ts";
|
||||
import { Boolean } from "./values/boolean.ts";
|
||||
import { Function } from "./values/function.ts";
|
||||
import { Number } from "./values/number.ts";
|
||||
import { Object } from "./values/object.ts";
|
||||
import { String } from "./values/string.ts";
|
||||
import { Symbol } from "./values/symbol.ts";
|
||||
import { Array } from "./values/array.ts";
|
||||
import { Map, WeakMap } from "./classes/map.ts";
|
||||
import { RegExp } from "./values/regex.ts";
|
||||
import { Date } from "./classes/date.ts";
|
||||
import { Math as _Math } from "./namespaces/math.ts";
|
||||
import { Set, WeakSet } from "./classes/set.ts";
|
||||
import { JSON } from "./namespaces/json.ts";
|
||||
import { console } from "./namespaces/console.ts";
|
||||
import { encodeURI, encodeURIComponent } from "./url.ts";
|
||||
import { Promise } from "./promise.ts";
|
||||
import { Promise } from "./classes/promise.ts";
|
||||
import { ArrayBuffer } from "./arrays/ArrayBuffer.ts";
|
||||
import { Uint8Array } from "./arrays/Uint8Array.ts";
|
||||
import { Int32Array } from "./arrays/Int32Array.ts";
|
||||
import { TypedArray } from "./arrays/TypedArray.ts";
|
||||
|
||||
declare global {
|
||||
function print(...args: any[]): void;
|
||||
@@ -46,6 +50,11 @@ target.RangeError = RangeError;
|
||||
target.SyntaxError = SyntaxError;
|
||||
target.TypeError = TypeError;
|
||||
|
||||
fixup(TypedArray);
|
||||
target.ArrayBuffer = fixup(ArrayBuffer);
|
||||
target.Uint8Array = Uint8Array;
|
||||
target.Int32Array = Int32Array;
|
||||
|
||||
target.Map = fixup(Map);
|
||||
target.WeakMap = fixup(WeakMap);
|
||||
target.Set = fixup(Set);
|
||||
@@ -56,7 +65,6 @@ target.Promise = fixup(Promise);
|
||||
target.Math = object.setPrototype(_Math, Object.prototype);
|
||||
target.JSON = object.setPrototype(JSON, Object.prototype);
|
||||
target.console = object.setPrototype(console, Object.prototype);
|
||||
target.TYPED_ARRAY_SUPPORT = false;
|
||||
|
||||
target.parseInt = Number.parseInt;
|
||||
target.parseFloat = Number.parseFloat;
|
||||
@@ -77,5 +85,7 @@ setGlobalPrototypes({
|
||||
syntax: SyntaxError.prototype,
|
||||
range: RangeError.prototype,
|
||||
type: TypeError.prototype,
|
||||
uint8: Uint8Array.prototype,
|
||||
int32: Int32Array.prototype,
|
||||
regex: RegExp,
|
||||
});
|
||||
|
||||
30
src/lib/libs/arrays/ArrayBuffer.ts
Normal file
30
src/lib/libs/arrays/ArrayBuffer.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { buffer, type InternalBuffer, map, symbol } from "../primordials.ts";
|
||||
|
||||
export const abs = new map(true);
|
||||
export const abKey: unique symbol = symbol.getSymbol("ArrayBuffer.impl") as any;
|
||||
|
||||
export class ArrayBuffer {
|
||||
public [abKey]!: InternalBuffer;
|
||||
|
||||
public get byteLength() {
|
||||
return this[abKey].length;
|
||||
}
|
||||
public get byteOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public constructor(val: unknown) {
|
||||
if (buffer.isBuff(val)) this[abKey] = val;
|
||||
else this[abKey] = buffer.buff(Number(val));
|
||||
}
|
||||
}
|
||||
|
||||
export function getAB(buff: InternalBuffer): ArrayBuffer {
|
||||
let res = abs.get(buff);
|
||||
if (res == null) {
|
||||
res = new ArrayBuffer(buff);
|
||||
abs.set(buff, res);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
25
src/lib/libs/arrays/Int32Array.ts
Normal file
25
src/lib/libs/arrays/Int32Array.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { buffer } from "../primordials.ts";
|
||||
import { abstractIgnore, TypedArray, typedArrayFuncs } from "./TypedArray.ts";
|
||||
|
||||
const factory = buffer.int32;
|
||||
const funcs = typedArrayFuncs(4, factory);
|
||||
|
||||
export class Int32Array extends TypedArray {
|
||||
public subarray(this: number[], start?: number, end?: number) {
|
||||
return funcs.subarray(this, start, end);
|
||||
}
|
||||
public slice(this: any[], start?: number, end?: number) {
|
||||
return funcs.slice(this, start, end);
|
||||
}
|
||||
public map(this: any[], cb: (val: number, i: number, self: any) => number, self?: any) {
|
||||
return funcs.map(this, cb, self);
|
||||
}
|
||||
public filter(this: any[], cb: (val: number, i: number, self: any) => boolean, self?: any) {
|
||||
return funcs.filter(this, cb, self);
|
||||
}
|
||||
|
||||
public constructor(obj: any, start?: number, end?: number) {
|
||||
super(abstractIgnore);
|
||||
return funcs.construct(obj, start, end) as any;
|
||||
}
|
||||
}
|
||||
220
src/lib/libs/arrays/TypedArray.ts
Normal file
220
src/lib/libs/arrays/TypedArray.ts
Normal file
@@ -0,0 +1,220 @@
|
||||
import { buffer, func, type InternalBuffer, object, string, symbol } from "../primordials.ts";
|
||||
import { symbols, wrapI } from "../utils.ts";
|
||||
import { Error, TypeError } from "../values/errors.ts";
|
||||
import { abKey, ArrayBuffer, getAB } from "./ArrayBuffer.ts";
|
||||
|
||||
export const abstractIgnore = symbol.getSymbol("TypedArray.abstractIgnore");
|
||||
|
||||
export function typedArrayFuncs(perEl: number, constructor: (buff: InternalBuffer, start: number, end: number) => number[]) {
|
||||
return {
|
||||
map(self: number[], cb: (val: number, i: number, self: number[]) => number, fnSelf: any) {
|
||||
const res = constructor(buffer.buff(self.length * perEl), 0, self.length);
|
||||
|
||||
for (let i = 0; i < self.length; i++) {
|
||||
res[i] = func.invoke(cb, fnSelf, [self[i], i, self]);
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
filter(self: number[], cb: (val: number, i: number, self: number[]) => boolean, fnSelf: any) {
|
||||
const bigger = constructor(buffer.buff(self.length * perEl), 0, self.length);
|
||||
let j = 0;
|
||||
|
||||
for (let i = 0; i < self.length; i++) {
|
||||
if (func.invoke(cb, self, [self[i], i, fnSelf])) bigger[j++] = self[i];
|
||||
}
|
||||
|
||||
const res = constructor(buffer.buff(j * perEl), 0, j);
|
||||
for (let i = 0; i < j; i++) res[i] = bigger[i];
|
||||
return res;
|
||||
},
|
||||
slice(self: number[], start = 0, end = self.length) {
|
||||
start = wrapI(start, self.length);
|
||||
end = wrapI(end, self.length);
|
||||
|
||||
if (end <= start) return constructor(buffer.buff(0), 0, 0);
|
||||
|
||||
const res = constructor(buffer.buff((end - start) * perEl), 0, end - start);
|
||||
|
||||
for (let i = 0; i < end - start; i++) {
|
||||
res[i] = self[start + i];
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
subarray(self: number[], start = 0, end = self.length) {
|
||||
start = wrapI(start, self.length);
|
||||
end = wrapI(end, self.length);
|
||||
|
||||
if (end <= start) return constructor(buffer.buff(0), 0, 0);
|
||||
|
||||
const offset = buffer.start(self);
|
||||
return constructor(buffer.backer(self), offset + start, offset + end);
|
||||
},
|
||||
construct(self: ArrayBuffer | number[] | number | Iterable<number>, start?: number, end?: number) {
|
||||
if (typeof self === "number") {
|
||||
return constructor(buffer.buff(self * perEl), 0, self);
|
||||
}
|
||||
if (self instanceof ArrayBuffer) {
|
||||
const internal = self[abKey];
|
||||
if (start === undefined) start = 0;
|
||||
if (end === undefined) end = (internal.length / perEl) | 0;
|
||||
return constructor(internal, start, end);
|
||||
}
|
||||
if (symbols.iterator in self && typeof self[symbols.iterator] === "function") {
|
||||
const arr: number[] = [];
|
||||
let i = 0;
|
||||
const gen: Iterator<number> = self[symbols.iterator]();
|
||||
|
||||
for (let it = gen.next(); !it.done; it = gen.next()) {
|
||||
arr[i++] = Number(it.value);
|
||||
}
|
||||
|
||||
const res = constructor(buffer.buff(i * perEl), 0, i);
|
||||
for (let j = 0; j < i; j++) res[j] = arr[j];
|
||||
return res;
|
||||
}
|
||||
|
||||
const res = constructor(buffer.buff((self as number[]).length * perEl), 0, (self as number[]).length);
|
||||
for (let i = 0; i < (self as number[]).length; i++) res[i] = (self as number[])[i];
|
||||
return res;
|
||||
},
|
||||
byteOffset(self: number[]) {
|
||||
return buffer.start(self) * perEl;
|
||||
},
|
||||
byteLength(self: number[]) {
|
||||
return (buffer.end(self) - buffer.start(self)) * perEl;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export class TypedArray {
|
||||
public get buffer() {
|
||||
return getAB(buffer.backer(this as any));
|
||||
}
|
||||
public get byteOffset(): number {
|
||||
throw new Error("abstract");
|
||||
}
|
||||
public get byteLength(): number {
|
||||
throw new Error("abstract");
|
||||
}
|
||||
|
||||
public forEach(this: number[], cb: (val: number, i: number, self: this) => void, self?: any) {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (i in this) func.invoke(cb, self, [this[i], i, this]);
|
||||
}
|
||||
}
|
||||
public join(this: number[], delim = ",") {
|
||||
delim = String(delim);
|
||||
const parts = [];
|
||||
if (delim) {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (i) parts[parts.length] = delim;
|
||||
parts[parts.length] = (i in this) ? String(this[i]) : "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
parts[i] = (i in this) ? String(this[i]) : "";
|
||||
}
|
||||
}
|
||||
|
||||
return string.stringBuild(parts);
|
||||
}
|
||||
|
||||
public subarray(this: number[], start = 0, end = this.length) {
|
||||
throw new Error("'slice' is an abstract method");
|
||||
}
|
||||
|
||||
public slice(this: number[], start = 0, end = this.length) {
|
||||
throw new Error("'slice' is an abstract method");
|
||||
}
|
||||
|
||||
public map(this: number[], cb: (val: number, i: number, self: this) => number, self?: any) {
|
||||
throw new Error("'map' is an abstract method");
|
||||
}
|
||||
public filter(this: number[], cb: (val: number, i: number, self: this) => boolean, self?: any) {
|
||||
throw new Error("'filter' is an abstract method");
|
||||
}
|
||||
public reduce(this: number[], cb: (a: number, b: number, i: number, self: number[]) => number, initial?: number) {
|
||||
let i = 0;
|
||||
if (arguments.length <= 1) initial = this[i++];
|
||||
|
||||
for (; i < this.length; i++) {
|
||||
initial = cb(initial!, this[i], i, this);
|
||||
}
|
||||
|
||||
return initial;
|
||||
}
|
||||
public some(this: number[], cb: (val: number, i: number, self: number[]) => boolean, self?: any) {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (func.invoke(cb, self, [this[i], i, this])) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public every(this: number[], cb: (val: number, i: number, self: number[]) => boolean, self?: any) {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (!func.invoke(cb, self, [this[i], i, this])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public find(this: number[], cb: (val: number, i: number, self: number[]) => boolean, self?: any) {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (func.invoke(cb, self, [this[i], i, this])) return this[i];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
public indexOf(this: number[], val: number, start = 0) {
|
||||
start |= 0;
|
||||
if (start < 0) start = 0;
|
||||
for (let i = start; i < this.length; i++) {
|
||||
if (this[i] === val) return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
public lastIndexOf(this: number[], val: number, start = 0) {
|
||||
start |= 0;
|
||||
if (start < 0) start = 0;
|
||||
|
||||
for (let i = this.length - 1; i >= start; i--) {
|
||||
if (this[i] === val) return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
public includes(this: number[], val: number) {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (this[i] === val) return i;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public sort(this: number[], cb?: (a: number, b: number) => number) {
|
||||
cb ||= (a, b) => a - b;
|
||||
|
||||
return object.sort(this, cb);
|
||||
}
|
||||
public reverse(this: number[]) {
|
||||
const mid = this.length >> 1;
|
||||
const end = this.length - 1;
|
||||
|
||||
for (let i = 0; i < mid; i++) {
|
||||
const tmp = this[i];
|
||||
this[i] = this[end - i];
|
||||
this[end - i] = tmp;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public constructor(token?: typeof abstractIgnore) {
|
||||
if (token !== abstractIgnore) {
|
||||
throw new TypeError("TypedArray constructor can't be called");
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/lib/libs/arrays/Uint8Array.ts
Normal file
32
src/lib/libs/arrays/Uint8Array.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { buffer } from "../primordials.ts";
|
||||
import { abstractIgnore, TypedArray, typedArrayFuncs } from "./TypedArray.ts";
|
||||
|
||||
const factory = buffer.uint8;
|
||||
const funcs = typedArrayFuncs(1, factory);
|
||||
|
||||
export class Uint8Array extends TypedArray {
|
||||
public override get byteOffset() {
|
||||
return funcs.byteOffset(this as any);
|
||||
}
|
||||
public override get byteLength() {
|
||||
return funcs.byteLength(this as any);
|
||||
}
|
||||
|
||||
public override subarray(this: number[], start?: number, end?: number) {
|
||||
return funcs.subarray(this, start, end);
|
||||
}
|
||||
public override slice(this: any[], start?: number, end?: number) {
|
||||
return funcs.slice(this, start, end);
|
||||
}
|
||||
public override map(this: any[], cb: (val: number, i: number, self: any) => number, self?: any) {
|
||||
return funcs.map(this, cb, self);
|
||||
}
|
||||
public override filter(this: any[], cb: (val: number, i: number, self: any) => boolean, self?: any) {
|
||||
return funcs.filter(this, cb, self);
|
||||
}
|
||||
|
||||
public constructor(obj: any, start?: number, end?: number) {
|
||||
super(abstractIgnore);
|
||||
return funcs.construct(obj, start, end) as any;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { now, symbol } from "./primordials.ts";
|
||||
import { now, symbol } from "../primordials.ts";
|
||||
|
||||
const timeKey: unique symbol = symbol.makeSymbol("") as any;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Array } from "./array.ts";
|
||||
import { func, map, symbol } from "./primordials.ts";
|
||||
import { symbols } from "./utils.ts";
|
||||
import { Array } from "../values/array.ts";
|
||||
import { func, map, symbol } from "../primordials.ts";
|
||||
import { symbols } from "../utils.ts";
|
||||
|
||||
const mapKey: unique symbol = symbol.makeSymbol("Map.impl") as any;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { func, next, object, symbol } from "./primordials.ts";
|
||||
import { func, next, object, symbol } from "../primordials.ts";
|
||||
|
||||
enum PromiseState {
|
||||
Pending = "pend",
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Array } from "./array.ts";
|
||||
import { func, map, symbol } from "./primordials.ts";
|
||||
import { symbols } from "./utils.ts";
|
||||
import { Array } from "../values/array.ts";
|
||||
import { func, map, symbol } from "../primordials.ts";
|
||||
import { symbols } from "../utils.ts";
|
||||
|
||||
const mapKey: unique symbol = symbol.makeSymbol("Set.impl") as any;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { func, json, object } from "./primordials";
|
||||
import { func, json, object } from "../primordials.ts";
|
||||
|
||||
export const console = {};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { json, object } from "./primordials";
|
||||
import { json, object } from "../primordials.ts";
|
||||
|
||||
export const JSON = {};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { number, object } from "./primordials";
|
||||
import { number, object } from "../primordials.ts";
|
||||
|
||||
export const Math = {};
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export default function _possibleConstructorReturn() {
|
||||
}
|
||||
export default function _possibleConstructorReturn(_, res) { return res; }
|
||||
@@ -1,3 +1,10 @@
|
||||
const buffSymbol: unique symbol = undefined as any;
|
||||
|
||||
export interface InternalBuffer {
|
||||
length: number;
|
||||
[buffSymbol]: "buffer";
|
||||
}
|
||||
|
||||
export interface SymbolPrimordials {
|
||||
makeSymbol(name: string): symbol;
|
||||
getSymbol(name: string): symbol;
|
||||
@@ -46,6 +53,22 @@ export interface ObjectPrimordials {
|
||||
memcpy(src: any[], dst: any[], srcI: number, dstI: number, n: number): void;
|
||||
sort(arr: any[], cb: Function): any[];
|
||||
}
|
||||
export interface BufferPrimordials {
|
||||
buff(n: number): InternalBuffer;
|
||||
backer(arr: number[]): InternalBuffer;
|
||||
start(arr: number[]): number;
|
||||
end(arr: number[]): number;
|
||||
|
||||
uint8(buff: InternalBuffer, start: number, end: number): number[];
|
||||
int8(buff: InternalBuffer, start: number, end: number): number[];
|
||||
int32(buff: InternalBuffer, start: number, end: number): number[];
|
||||
|
||||
isUint8(val: any): val is number[];
|
||||
isInt8(val: any): val is number[];
|
||||
isInt32(val: any): val is number[];
|
||||
is(val: any): val is number[];
|
||||
isBuff(val: any): val is InternalBuffer;
|
||||
}
|
||||
export interface FunctionPrimordials {
|
||||
invokeType(args: IArguments, self: any): "new" | "call";
|
||||
invokeTypeInfer(): "new" | "call";
|
||||
@@ -67,6 +90,7 @@ export interface Primordials {
|
||||
object: ObjectPrimordials;
|
||||
function: FunctionPrimordials;
|
||||
json: JSONPrimordials;
|
||||
buffer: BufferPrimordials;
|
||||
map: new (weak?: boolean) => {
|
||||
get(key: any): any;
|
||||
has(key: any): boolean;
|
||||
@@ -88,7 +112,8 @@ export interface Primordials {
|
||||
schedule(func: () => void, delay: number): () => void;
|
||||
}
|
||||
|
||||
globalThis.undefined = void 0;
|
||||
// prevent optimization to "undefined", which doesn't exist yet
|
||||
globalThis.undefined = ({} as any).bogus;
|
||||
export const target = (globalThis as any).target;
|
||||
export const primordials: Primordials = (globalThis as any).primordials;
|
||||
|
||||
@@ -97,6 +122,7 @@ export const {
|
||||
number,
|
||||
string,
|
||||
object,
|
||||
buffer,
|
||||
function: func,
|
||||
json,
|
||||
map,
|
||||
|
||||
@@ -25,7 +25,7 @@ export interface TypeMap {
|
||||
|
||||
export function unwrapThis<T extends keyof TypeMap>(self: any, type: T, constr: Function, name: string, arg = "this", defaultVal?: TypeMap[T]): TypeMap[T] {
|
||||
if (typeof self === type) return self;
|
||||
if (self instanceof constr && valueKey in self) self = (self as any)[valueKey];
|
||||
if (self instanceof constr && valueKey in self) self = self[valueKey];
|
||||
if (typeof self === type) return self;
|
||||
if (defaultVal !== undefined) return defaultVal;
|
||||
throw new TypeError(name + " requires that '" + arg + "' be a " + constr.name);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Error } from "./errors.ts";
|
||||
import { func, object, string } from "./primordials.ts";
|
||||
import { String } from "./string.ts";
|
||||
import { limitI, symbols, wrapI } from "./utils.ts";
|
||||
import { Error } from "../values/errors.ts";
|
||||
import { func, object, string } from "../primordials.ts";
|
||||
import { String } from "../values/string.ts";
|
||||
import { limitI, symbols, wrapI } from "../utils.ts";
|
||||
|
||||
export const Array = (() => {
|
||||
class Array {
|
||||
@@ -33,7 +33,7 @@ export const Array = (() => {
|
||||
for (let i = arguments.length - 1; i >= 0; i--) {
|
||||
this[start + i] = arguments[i];
|
||||
}
|
||||
return arguments.length;
|
||||
return this.length;
|
||||
}
|
||||
public pop(this: any[]) {
|
||||
if (this.length === 0) return undefined;
|
||||
@@ -51,7 +51,7 @@ export const Array = (() => {
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
this[i] = arguments[i];
|
||||
}
|
||||
return arguments.length;
|
||||
return this.length;
|
||||
}
|
||||
public shift(this: any[]) {
|
||||
if (this.length === 0) return undefined;
|
||||
@@ -71,7 +71,7 @@ export const Array = (() => {
|
||||
const res: any[] = [];
|
||||
|
||||
function add(arr: any) {
|
||||
if (Array.isArray(arr) || symbols.isConcatSpreadable in arr) {
|
||||
if (Array.isArray(arr) || arr != null && typeof arr === "object" && symbols.isConcatSpreadable in arr) {
|
||||
const start = res.length;
|
||||
res.length += arr.length;
|
||||
|
||||
@@ -209,7 +209,7 @@ export const Array = (() => {
|
||||
}
|
||||
public includes(this: any[], val: any) {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (i in this && this[i] === val) return i;
|
||||
if (i in this && this[i] === val) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1,5 +1,5 @@
|
||||
import { func } from "./primordials.ts";
|
||||
import { unwrapThis, valueKey } from "./utils.ts";
|
||||
import { func } from "../primordials.ts";
|
||||
import { unwrapThis, valueKey } from "../utils.ts";
|
||||
|
||||
export const Boolean = (() => {
|
||||
class Boolean {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { func, object } from "./primordials.ts";
|
||||
import { func, object } from "../primordials.ts";
|
||||
import { String } from "./string.ts";
|
||||
|
||||
export class Error {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { compile, func, string } from "./primordials.ts";
|
||||
import { compile, func, string } from "../primordials.ts";
|
||||
import { String } from "./string.ts";
|
||||
|
||||
export const Function = (() => {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { func, number, object } from "./primordials.ts";
|
||||
import { unwrapThis, valueKey } from "./utils.ts";
|
||||
import { func, number, object } from "../primordials.ts";
|
||||
import { unwrapThis, valueKey } from "../utils.ts";
|
||||
|
||||
export const Number = (() => {
|
||||
class Number {
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Boolean } from "./boolean.ts";
|
||||
import { TypeError } from "./errors.ts";
|
||||
import { Number } from "./number.ts";
|
||||
import { func, object } from "./primordials.ts";
|
||||
import { func, object } from "../primordials.ts";
|
||||
import { String } from "./string.ts";
|
||||
import { symbols, valueKey } from "./utils.ts";
|
||||
import { Symbol } from "./symbol.ts";
|
||||
import { symbols, valueKey } from "../utils.ts";
|
||||
import { Symbol } from "../values/symbol.ts";
|
||||
|
||||
export const Object = (() => {
|
||||
class Object {
|
||||
@@ -29,6 +29,13 @@ export const Object = (() => {
|
||||
return object.getOwnMember(this, key) != null;
|
||||
}
|
||||
|
||||
public get __proto__() {
|
||||
return object.getPrototype(this);
|
||||
}
|
||||
public set __proto__(val) {
|
||||
object.setPrototype(this, val);
|
||||
}
|
||||
|
||||
public constructor (value?: unknown) {
|
||||
if (typeof value === 'object' && value !== null) return value as any;
|
||||
if (typeof value === 'string') return new String(value) as any;
|
||||
@@ -75,13 +82,13 @@ export const Object = (() => {
|
||||
res.s = set;
|
||||
}
|
||||
if ("enumerable" in desc) res.e = !!desc.enumerable;
|
||||
if ("configurable" in desc) res.e = !!desc.configurable;
|
||||
if ("configurable" in desc) res.c = !!desc.configurable;
|
||||
|
||||
if (!object.defineProperty(obj, key, res)) throw new TypeError("Cannot redefine property: " + String(key));
|
||||
}
|
||||
else {
|
||||
if ("enumerable" in desc) res.e = !!desc.enumerable;
|
||||
if ("configurable" in desc) res.e = !!desc.configurable;
|
||||
if ("configurable" in desc) res.c = !!desc.configurable;
|
||||
if ("writable" in desc) res.w = !!desc.writable;
|
||||
if ("value" in desc) res.v = desc.value;
|
||||
|
||||
@@ -190,6 +197,7 @@ export const Object = (() => {
|
||||
}
|
||||
}
|
||||
|
||||
object.defineProperty(Object.prototype, "__proto__", { e: false });
|
||||
object.setPrototype(Object.prototype, undefined);
|
||||
|
||||
func.setCallable(Object, true);
|
||||
@@ -1,9 +1,9 @@
|
||||
import { func, regex, symbol } from "./primordials.ts";
|
||||
import { func, regex, symbol } from "../primordials.ts";
|
||||
import { String } from "./string.ts";
|
||||
import { type ReplaceRange } from "./utils.ts";
|
||||
import { applyReplaces } from "./utils.ts";
|
||||
import { applySplits } from "./utils.ts";
|
||||
import { symbols } from "./utils.ts";
|
||||
import { type ReplaceRange } from "../utils.ts";
|
||||
import { applyReplaces } from "../utils.ts";
|
||||
import { applySplits } from "../utils.ts";
|
||||
import { symbols } from "../utils.ts";
|
||||
|
||||
const regexKey: unique symbol = symbol.makeSymbol("RegExp.impl") as any;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { TypeError } from "./errors.ts";
|
||||
import { func, number, regex, string } from "./primordials.ts";
|
||||
import { func, number, regex, string } from "../primordials.ts";
|
||||
import { RegExp } from "./regex.ts";
|
||||
import { applyReplaces, applySplits, limitI, type ReplaceRange, symbols, unwrapThis, valueKey, wrapI } from "./utils.ts";
|
||||
import { applyReplaces, applySplits, limitI, type ReplaceRange, symbols, unwrapThis, valueKey, wrapI } from "../utils.ts";
|
||||
|
||||
const trimStartRegex = new regex("^\\s+", false, false, false, false, false);
|
||||
const trimEndRegex = new regex("\\s+$", false, false, false, false, false);
|
||||
@@ -41,8 +41,9 @@ export const String = (() => {
|
||||
offset = +offset;
|
||||
return string.indexOf(self, search, offset, false);
|
||||
}
|
||||
public lastIndexOf(search: string, offset = 0) {
|
||||
public lastIndexOf(search: string, offset?: number) {
|
||||
const self = unwrapThis(this, "string", String, "String.prototype.lastIndexOf");
|
||||
if (offset == null) offset = self.length;
|
||||
offset = +offset;
|
||||
return string.indexOf(self, search, offset, true);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { func, object, symbol } from "./primordials.ts";
|
||||
import { symbols, unwrapThis, valueKey } from "./utils.ts";
|
||||
import { func, object, symbol } from "../primordials.ts";
|
||||
import { symbols, unwrapThis, valueKey } from "../utils.ts";
|
||||
|
||||
export const Symbol = (() => {
|
||||
class Symbol {
|
||||
@@ -1,14 +1,14 @@
|
||||
import { SourceMap } from "./map.ts";
|
||||
import { transform } from "@babel/standalone";
|
||||
// import presetEnv from "@babel/preset-env";
|
||||
import { transform, availablePresets } from "@babel/standalone";
|
||||
|
||||
export default function babel(next: Compiler): Compiler {
|
||||
print("Loaded babel!");
|
||||
|
||||
|
||||
return (filename, code, prevMap) => {
|
||||
const res = transform(code, {
|
||||
filename,
|
||||
sourceMaps: true,
|
||||
presets: [availablePresets.env],
|
||||
});
|
||||
|
||||
const map = SourceMap.parse({
|
||||
@@ -17,9 +17,8 @@ export default function babel(next: Compiler): Compiler {
|
||||
sources: [filename],
|
||||
});
|
||||
|
||||
const compiled = next("babel-internal://" + filename, res.code!, SourceMap.chain(map, prevMap));
|
||||
registerSource(filename, code);
|
||||
return compiled;
|
||||
return next("babel-internal://" + filename, res.code!, SourceMap.chain(map, prevMap));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,8 @@ export default function coffee(next: Compiler): Compiler {
|
||||
sources: [filename],
|
||||
});
|
||||
|
||||
const compiled = next("coffee-internal://" + filename, result, SourceMap.chain(map, prevMap));
|
||||
registerSource(filename, code);
|
||||
return compiled;
|
||||
return next("coffee-internal://" + filename, result, SourceMap.chain(map, prevMap));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,15 +6,24 @@ for (let i = 97; i <= 122; i++) map[i] = j++;
|
||||
map[43] = j++;
|
||||
map[47] = j++;
|
||||
|
||||
export type Location = readonly [file: string, line: number, start: number];
|
||||
|
||||
export function decodeVLQ(val: string): number[][][] {
|
||||
const lines: number[][][] = [];
|
||||
|
||||
for (const line of val.split(";", -1)) {
|
||||
const elements: number[][] = [];
|
||||
const fileParts = val.split(";", -1);
|
||||
|
||||
for (let i = 0; i < fileParts.length; i++) {
|
||||
const line = fileParts[i];
|
||||
if (line.length === 0) {
|
||||
lines.push([]);
|
||||
continue;
|
||||
}
|
||||
|
||||
const elements: number[][] = [];
|
||||
const lineParts = line.split(",", -1);
|
||||
|
||||
for (let i = 0; i < lineParts.length; i++) {
|
||||
const el = lineParts[i];
|
||||
|
||||
for (const el of line.split(",", -1)) {
|
||||
if (el.length === 0) elements.push([]);
|
||||
else {
|
||||
const list: number[] = [];
|
||||
@@ -72,10 +81,6 @@ export namespace Location {
|
||||
}
|
||||
}
|
||||
|
||||
export interface SourceMap {
|
||||
(loc: Location): Location | undefined;
|
||||
}
|
||||
|
||||
export class VLQSourceMap {
|
||||
public constructor(
|
||||
public readonly array: Map<string, [start: number, dst: Location][][]>,
|
||||
@@ -98,7 +103,7 @@ export class VLQSourceMap {
|
||||
const mid = (a + b) >> 1;
|
||||
const el = line[mid];
|
||||
|
||||
const cmp = el[0] - src[1];
|
||||
const cmp = el[0] - src[2];
|
||||
|
||||
if (cmp < 0) {
|
||||
if (done) {
|
||||
@@ -132,10 +137,13 @@ export class VLQSourceMap {
|
||||
const lastCols = new Set<number>();
|
||||
|
||||
for (let compiledRow = 0; compiledRow < mapping.length; compiledRow++) {
|
||||
const line = file[compiledRow] ??= [];
|
||||
const line: [start: number, dst: Location][] = file[compiledRow] = [];
|
||||
let compiledCol = 0;
|
||||
|
||||
for (const rawSeg of mapping[compiledRow]) {
|
||||
const rowData = mapping[compiledRow];
|
||||
for (let i = 0; i < rowData.length; i++) {
|
||||
const rawSeg = rowData[i];
|
||||
|
||||
compiledCol += rawSeg.length > 0 ? rawSeg[0] : 0;
|
||||
originalFile += rawSeg.length > 1 ? rawSeg[1] : 0;
|
||||
originalRow += rawSeg.length > 2 ? rawSeg[2] : 0;
|
||||
|
||||
10
src/lib/transpiler/transpiler.d.ts
vendored
Normal file
10
src/lib/transpiler/transpiler.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
type Location = [file: string, line: number, start: number];
|
||||
type SourceMap = (loc: Location) => Location | undefined;
|
||||
|
||||
type CompilerFactory = (next: Compiler) => Compiler;
|
||||
type Compiler = (filename: string, src: string, mapper: SourceMap) => (this: any, ...args: any[]) => any;
|
||||
|
||||
declare function getResource(name: string): string | undefined;
|
||||
declare function print(...args: any[]): void;
|
||||
declare function register(factory: CompilerFactory): void;
|
||||
declare function registerSource(filename: string, src: string): void;
|
||||
@@ -1,10 +0,0 @@
|
||||
import { type SourceMap } from "./map.ts";
|
||||
|
||||
declare global {
|
||||
type CompilerFactory = (next: Compiler) => Compiler;
|
||||
type Compiler = (filename: string, src: string, mapper: SourceMap) => Function;
|
||||
|
||||
function print(...args: any[]): void;
|
||||
function register(factory: CompilerFactory): void;
|
||||
function registerSource(filename: string, src: string): void;
|
||||
}
|
||||
@@ -1,17 +1,8 @@
|
||||
import { createDocumentRegistry, createLanguageService, ModuleKind, ScriptSnapshot, ScriptTarget, type Diagnostic, type CompilerOptions, type IScriptSnapshot, flattenDiagnosticMessageText, CompilerHost, LanguageService } from "typescript";
|
||||
import { SourceMap } from "./map.ts";
|
||||
|
||||
declare function getResource(name: string): string | undefined;
|
||||
declare function print(...args: any[]): void;
|
||||
declare function register(factory: CompilerFactory): void;
|
||||
declare function registerSource(filename: string, src: string): void;
|
||||
|
||||
type CompilerFactory = (next: Compiler) => Compiler;
|
||||
type Compiler = (filename: string, src: string, mapper: SourceMap) => Function;
|
||||
|
||||
const resources: Record<string, string | undefined> = {};
|
||||
|
||||
|
||||
function resource(name: string) {
|
||||
if (name in resources) return resources[name];
|
||||
else return resources[name] = getResource(name);
|
||||
@@ -115,8 +106,8 @@ export default function typescript(next: Compiler): Compiler {
|
||||
const result = outputs["/src.js"];
|
||||
const declaration = outputs["/src.d.ts"];
|
||||
|
||||
const compiled = next("ts-internal://" + filename, result, SourceMap.chain(map, prevMap));
|
||||
registerSource(filename, code);
|
||||
const compiled = next("ts-internal://" + filename, result, SourceMap.chain(map, prevMap));
|
||||
|
||||
return function (this: any) {
|
||||
const res = compiled.apply(this, arguments);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common;
|
||||
package me.topchetoeu.j2s.common;
|
||||
|
||||
public class FunctionBody {
|
||||
public final FunctionBody[] children;
|
||||
@@ -1,10 +1,10 @@
|
||||
package me.topchetoeu.jscript.common;
|
||||
package me.topchetoeu.j2s.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
|
||||
public class Instruction {
|
||||
public static enum Type {
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.topchetoeu.jscript.common;
|
||||
package me.topchetoeu.j2s.common;
|
||||
|
||||
import me.topchetoeu.jscript.common.json.JSON;
|
||||
import me.topchetoeu.j2s.common.json.JSON;
|
||||
|
||||
public class Metadata {
|
||||
private static final String VERSION;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common;
|
||||
package me.topchetoeu.j2s.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common;
|
||||
package me.topchetoeu.j2s.common;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.topchetoeu.jscript.common;
|
||||
package me.topchetoeu.j2s.common;
|
||||
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
|
||||
public class SyntaxException extends RuntimeException {
|
||||
public final Location loc;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.environment;
|
||||
package me.topchetoeu.j2s.common.environment;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -0,0 +1,3 @@
|
||||
package me.topchetoeu.j2s.common.environment;
|
||||
|
||||
public final class Key<T> { }
|
||||
@@ -1,15 +1,16 @@
|
||||
package me.topchetoeu.jscript.common.json;
|
||||
package me.topchetoeu.j2s.common.json;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import me.topchetoeu.jscript.common.SyntaxException;
|
||||
import me.topchetoeu.jscript.common.parsing.Filename;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.common.Metadata;
|
||||
import me.topchetoeu.j2s.common.SyntaxException;
|
||||
import me.topchetoeu.j2s.common.parsing.Filename;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
|
||||
public class JSON {
|
||||
public static ParseRes<JSONElement> parseString(Source src, int i) {
|
||||
@@ -100,7 +101,7 @@ public class JSON {
|
||||
return ParseRes.res(JSONElement.list(values), n);
|
||||
}
|
||||
public static JSONElement parse(Filename filename, String raw) {
|
||||
if (filename == null) filename = new Filename("jscript", "json");
|
||||
if (filename == null) filename = new Filename(Metadata.name(), "json");
|
||||
|
||||
var res = parseValue(new Source(null, filename, raw), 0);
|
||||
if (res.isFailed()) throw new SyntaxException(Location.of(filename, 0, 0), "Invalid JSON given");
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.json;
|
||||
package me.topchetoeu.j2s.common.json;
|
||||
|
||||
public class JSONElement {
|
||||
public static enum Type {
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.json;
|
||||
package me.topchetoeu.j2s.common.json;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.json;
|
||||
package me.topchetoeu.j2s.common.json;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.mapping;
|
||||
package me.topchetoeu.j2s.common.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -13,9 +13,9 @@ import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Filename;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Filename;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
|
||||
public class FunctionMap {
|
||||
public static class FunctionMapBuilder {
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.parsing;
|
||||
package me.topchetoeu.j2s.common.parsing;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package me.topchetoeu.jscript.common.parsing;
|
||||
package me.topchetoeu.j2s.common.parsing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import me.topchetoeu.j2s.common.Metadata;
|
||||
|
||||
public abstract class Location implements Comparable<Location> {
|
||||
public static final Location INTERNAL = Location.of(new Filename("jscript", "native"), -1, -1);
|
||||
public static final Location INTERNAL = Location.of(new Filename(Metadata.name(), "native"), -1, -1);
|
||||
|
||||
public abstract int line();
|
||||
public abstract int start();
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.parsing;
|
||||
package me.topchetoeu.j2s.common.parsing;
|
||||
|
||||
public class ParseRes<T> {
|
||||
public static enum State {
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.parsing;
|
||||
package me.topchetoeu.j2s.common.parsing;
|
||||
|
||||
public interface Parser<T> {
|
||||
public ParseRes<T> parse(Source src, int i);
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.topchetoeu.jscript.common.parsing;
|
||||
package me.topchetoeu.j2s.common.parsing;
|
||||
|
||||
import me.topchetoeu.jscript.common.SyntaxException;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.NumberNode;
|
||||
import me.topchetoeu.j2s.common.SyntaxException;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.NumberNode;
|
||||
|
||||
public class Parsing {
|
||||
public static boolean isDigit(Character c) {
|
||||
@@ -1,8 +1,8 @@
|
||||
package me.topchetoeu.jscript.common.parsing;
|
||||
package me.topchetoeu.j2s.common.parsing;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import me.topchetoeu.jscript.common.environment.Environment;
|
||||
import me.topchetoeu.j2s.common.environment.Environment;
|
||||
|
||||
public class Source {
|
||||
public final Environment env;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.common.parsing;
|
||||
package me.topchetoeu.j2s.common.parsing;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import me.topchetoeu.j2s.common.FunctionBody;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.environment.Environment;
|
||||
import me.topchetoeu.j2s.common.environment.Key;
|
||||
import me.topchetoeu.j2s.common.mapping.FunctionMap;
|
||||
import me.topchetoeu.j2s.common.mapping.FunctionMap.FunctionMapBuilder;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.control.TryNode;
|
||||
import me.topchetoeu.j2s.compilation.scope.FunctionScope;
|
||||
import me.topchetoeu.j2s.compilation.scope.Variable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import me.topchetoeu.jscript.common.FunctionBody;
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.environment.Environment;
|
||||
import me.topchetoeu.jscript.common.environment.Key;
|
||||
import me.topchetoeu.jscript.common.mapping.FunctionMap;
|
||||
import me.topchetoeu.jscript.common.mapping.FunctionMap.FunctionMapBuilder;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.control.TryNode;
|
||||
import me.topchetoeu.jscript.compilation.scope.FunctionScope;
|
||||
import me.topchetoeu.jscript.compilation.scope.Variable;
|
||||
|
||||
public final class CompileResult {
|
||||
public static final Key<Void> DEBUG_LOG = new Key<>();
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
|
||||
|
||||
public class CompoundNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.environment.Environment;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.scope.FunctionScope;
|
||||
import me.topchetoeu.jscript.compilation.values.VariableNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.environment.Environment;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.scope.FunctionScope;
|
||||
import me.topchetoeu.j2s.compilation.values.VariableNode;
|
||||
|
||||
public abstract class FunctionNode extends Node {
|
||||
public final CompoundNode body;
|
||||
@@ -1,12 +1,12 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.scope.Variable;
|
||||
import me.topchetoeu.jscript.compilation.values.VariableNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.scope.Variable;
|
||||
import me.topchetoeu.j2s.compilation.values.VariableNode;
|
||||
|
||||
public class FunctionStatementNode extends FunctionNode {
|
||||
public final String name;
|
||||
@@ -1,11 +1,11 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.values.VariableNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.values.VariableNode;
|
||||
|
||||
public class FunctionValueNode extends FunctionNode {
|
||||
public final String name;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -6,45 +6,45 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import me.topchetoeu.jscript.common.SyntaxException;
|
||||
import me.topchetoeu.jscript.common.environment.Environment;
|
||||
import me.topchetoeu.jscript.common.environment.Key;
|
||||
import me.topchetoeu.jscript.common.parsing.Filename;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.control.BreakNode;
|
||||
import me.topchetoeu.jscript.compilation.control.ContinueNode;
|
||||
import me.topchetoeu.jscript.compilation.control.DebugNode;
|
||||
import me.topchetoeu.jscript.compilation.control.DeleteNode;
|
||||
import me.topchetoeu.jscript.compilation.control.DoWhileNode;
|
||||
import me.topchetoeu.jscript.compilation.control.ForInNode;
|
||||
import me.topchetoeu.jscript.compilation.control.ForNode;
|
||||
import me.topchetoeu.jscript.compilation.control.IfNode;
|
||||
import me.topchetoeu.jscript.compilation.control.ReturnNode;
|
||||
import me.topchetoeu.jscript.compilation.control.SwitchNode;
|
||||
import me.topchetoeu.jscript.compilation.control.ThrowNode;
|
||||
import me.topchetoeu.jscript.compilation.control.TryNode;
|
||||
import me.topchetoeu.jscript.compilation.control.WhileNode;
|
||||
import me.topchetoeu.jscript.compilation.scope.FunctionScope;
|
||||
import me.topchetoeu.jscript.compilation.values.ArgumentsNode;
|
||||
import me.topchetoeu.jscript.compilation.values.ArrayNode;
|
||||
import me.topchetoeu.jscript.compilation.values.GlobalThisNode;
|
||||
import me.topchetoeu.jscript.compilation.values.ObjectNode;
|
||||
import me.topchetoeu.jscript.compilation.values.RegexNode;
|
||||
import me.topchetoeu.jscript.compilation.values.ThisNode;
|
||||
import me.topchetoeu.jscript.compilation.values.VariableNode;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.BoolNode;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.NullNode;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.NumberNode;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.StringNode;
|
||||
import me.topchetoeu.jscript.compilation.values.operations.CallNode;
|
||||
import me.topchetoeu.jscript.compilation.values.operations.ChangeNode;
|
||||
import me.topchetoeu.jscript.compilation.values.operations.DiscardNode;
|
||||
import me.topchetoeu.jscript.compilation.values.operations.IndexNode;
|
||||
import me.topchetoeu.jscript.compilation.values.operations.OperationNode;
|
||||
import me.topchetoeu.jscript.compilation.values.operations.PostfixNode;
|
||||
import me.topchetoeu.jscript.compilation.values.operations.TypeofNode;
|
||||
import me.topchetoeu.j2s.common.SyntaxException;
|
||||
import me.topchetoeu.j2s.common.environment.Environment;
|
||||
import me.topchetoeu.j2s.common.environment.Key;
|
||||
import me.topchetoeu.j2s.common.parsing.Filename;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.control.BreakNode;
|
||||
import me.topchetoeu.j2s.compilation.control.ContinueNode;
|
||||
import me.topchetoeu.j2s.compilation.control.DebugNode;
|
||||
import me.topchetoeu.j2s.compilation.control.DeleteNode;
|
||||
import me.topchetoeu.j2s.compilation.control.DoWhileNode;
|
||||
import me.topchetoeu.j2s.compilation.control.ForInNode;
|
||||
import me.topchetoeu.j2s.compilation.control.ForNode;
|
||||
import me.topchetoeu.j2s.compilation.control.IfNode;
|
||||
import me.topchetoeu.j2s.compilation.control.ReturnNode;
|
||||
import me.topchetoeu.j2s.compilation.control.SwitchNode;
|
||||
import me.topchetoeu.j2s.compilation.control.ThrowNode;
|
||||
import me.topchetoeu.j2s.compilation.control.TryNode;
|
||||
import me.topchetoeu.j2s.compilation.control.WhileNode;
|
||||
import me.topchetoeu.j2s.compilation.scope.FunctionScope;
|
||||
import me.topchetoeu.j2s.compilation.values.ArgumentsNode;
|
||||
import me.topchetoeu.j2s.compilation.values.ArrayNode;
|
||||
import me.topchetoeu.j2s.compilation.values.GlobalThisNode;
|
||||
import me.topchetoeu.j2s.compilation.values.ObjectNode;
|
||||
import me.topchetoeu.j2s.compilation.values.RegexNode;
|
||||
import me.topchetoeu.j2s.compilation.values.ThisNode;
|
||||
import me.topchetoeu.j2s.compilation.values.VariableNode;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.BoolNode;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.NullNode;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.NumberNode;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.StringNode;
|
||||
import me.topchetoeu.j2s.compilation.values.operations.CallNode;
|
||||
import me.topchetoeu.j2s.compilation.values.operations.ChangeNode;
|
||||
import me.topchetoeu.j2s.compilation.values.operations.DiscardNode;
|
||||
import me.topchetoeu.j2s.compilation.values.operations.IndexNode;
|
||||
import me.topchetoeu.j2s.compilation.values.operations.OperationNode;
|
||||
import me.topchetoeu.j2s.compilation.values.operations.PostfixNode;
|
||||
import me.topchetoeu.j2s.compilation.values.operations.TypeofNode;
|
||||
|
||||
public final class JavaScript {
|
||||
public static enum DeclarationType {
|
||||
@@ -1,15 +1,15 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.SyntaxException;
|
||||
import me.topchetoeu.jscript.common.environment.Environment;
|
||||
import me.topchetoeu.jscript.common.environment.Key;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.SyntaxException;
|
||||
import me.topchetoeu.j2s.common.environment.Environment;
|
||||
import me.topchetoeu.j2s.common.environment.Key;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
|
||||
public class LabelContext {
|
||||
public static final Key<LabelContext> BREAK_CTX = new Key<>();
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
|
||||
public abstract class Node {
|
||||
private Location loc;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
|
||||
public final class Parameter {
|
||||
public final Location loc;
|
||||
@@ -1,16 +1,16 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
package me.topchetoeu.j2s.compilation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.values.VariableNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.values.VariableNode;
|
||||
|
||||
public class VariableDeclareNode extends Node {
|
||||
@Desugar
|
||||
@@ -1,15 +1,15 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.SyntaxException;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.SyntaxException;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class BreakNode extends Node {
|
||||
public final String label;
|
||||
@@ -1,15 +1,15 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.SyntaxException;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.SyntaxException;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class ContinueNode extends Node {
|
||||
public final String label;
|
||||
@@ -1,13 +1,13 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class DebugNode extends Node {
|
||||
@Override public void compileFunctions(CompileResult target) {
|
||||
@@ -1,16 +1,16 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.jscript.compilation.values.VariableNode;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.BoolNode;
|
||||
import me.topchetoeu.jscript.compilation.values.operations.IndexNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
import me.topchetoeu.j2s.compilation.values.VariableNode;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.BoolNode;
|
||||
import me.topchetoeu.j2s.compilation.values.operations.IndexNode;
|
||||
|
||||
public class DeleteNode extends Node {
|
||||
public final Node key;
|
||||
@@ -1,16 +1,16 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class DoWhileNode extends Node {
|
||||
public final Node condition, body;
|
||||
@@ -1,17 +1,17 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.jscript.compilation.values.VariableNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
import me.topchetoeu.j2s.compilation.values.VariableNode;
|
||||
|
||||
public class ForInNode extends Node {
|
||||
public final boolean isDecl;
|
||||
@@ -21,7 +21,9 @@ public class ForInNode extends Node {
|
||||
|
||||
@Override public void resolve(CompileResult target) {
|
||||
body.resolve(target);
|
||||
binding.resolve(target);
|
||||
if (isDecl) {
|
||||
target.scope.define(binding.name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void compileFunctions(CompileResult target) {
|
||||
@@ -1,17 +1,17 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.jscript.compilation.VariableDeclareNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
import me.topchetoeu.j2s.compilation.VariableDeclareNode;
|
||||
|
||||
public class ForNode extends Node {
|
||||
public final Node declaration, assignment, condition, body;
|
||||
@@ -1,16 +1,16 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class IfNode extends Node {
|
||||
public final Node condition, body, elseBody;
|
||||
@@ -1,13 +1,13 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class ReturnNode extends Node {
|
||||
public final Node value;
|
||||
@@ -1,20 +1,20 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Operation;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Operation;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class SwitchNode extends Node {
|
||||
public static class SwitchCase {
|
||||
@@ -1,13 +1,13 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class ThrowNode extends Node {
|
||||
public final Node value;
|
||||
@@ -1,17 +1,17 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.CompoundNode;
|
||||
import me.topchetoeu.jscript.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.CompoundNode;
|
||||
import me.topchetoeu.j2s.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class TryNode extends Node {
|
||||
public final CompoundNode tryBody;
|
||||
@@ -1,16 +1,16 @@
|
||||
package me.topchetoeu.jscript.compilation.control;
|
||||
package me.topchetoeu.j2s.compilation.control;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.LabelContext;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.DeferredIntSupplier;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.LabelContext;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class WhileNode extends Node {
|
||||
public final Node condition, body;
|
||||
@@ -1,14 +1,14 @@
|
||||
package me.topchetoeu.jscript.compilation.members;
|
||||
package me.topchetoeu.j2s.compilation.members;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.jscript.compilation.values.ObjectNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
import me.topchetoeu.j2s.compilation.values.ObjectNode;
|
||||
|
||||
public class FieldMemberNode implements Member {
|
||||
public final Location loc;
|
||||
@@ -29,7 +29,7 @@ public class FieldMemberNode implements Member {
|
||||
if (value == null) target.add(Instruction.pushUndefined());
|
||||
else value.compile(target, true);
|
||||
|
||||
target.add(Instruction.defField());
|
||||
target.add(Instruction.storeMember());
|
||||
}
|
||||
|
||||
public FieldMemberNode(Location loc, Node key, Node value) {
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.topchetoeu.j2s.compilation.members;
|
||||
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
|
||||
public interface Member {
|
||||
Location loc();
|
||||
|
||||
void compileFunctions(CompileResult target);
|
||||
void compile(CompileResult target, boolean pollute);
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
package me.topchetoeu.jscript.compilation.members;
|
||||
package me.topchetoeu.j2s.compilation.members;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.CompoundNode;
|
||||
import me.topchetoeu.jscript.compilation.FunctionNode;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.jscript.compilation.values.ObjectNode;
|
||||
import me.topchetoeu.jscript.compilation.values.VariableNode;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.StringNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.CompoundNode;
|
||||
import me.topchetoeu.j2s.compilation.FunctionNode;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
import me.topchetoeu.j2s.compilation.values.ObjectNode;
|
||||
import me.topchetoeu.j2s.compilation.values.VariableNode;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.StringNode;
|
||||
|
||||
public final class PropertyMemberNode extends FunctionNode implements Member {
|
||||
public final Node key;
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.topchetoeu.jscript.compilation.patterns;
|
||||
package me.topchetoeu.j2s.compilation.patterns;
|
||||
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
|
||||
/**
|
||||
* Represents all nodes that can be assign targets
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.compilation.patterns;
|
||||
package me.topchetoeu.j2s.compilation.patterns;
|
||||
|
||||
/**
|
||||
* Represents all nodes that can be converted to assign targets
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.topchetoeu.j2s.compilation.patterns;
|
||||
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
|
||||
public interface ChangeTarget extends AssignTarget {
|
||||
void beforeChange(CompileResult target);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.compilation.scope;
|
||||
package me.topchetoeu.j2s.compilation.scope;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.topchetoeu.jscript.compilation.scope;
|
||||
package me.topchetoeu.j2s.compilation.scope;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.topchetoeu.jscript.compilation.scope;
|
||||
package me.topchetoeu.j2s.compilation.scope;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
|
||||
public final class VariableIndex {
|
||||
public static enum IndexType {
|
||||
@@ -1,11 +1,11 @@
|
||||
package me.topchetoeu.jscript.compilation.scope;
|
||||
package me.topchetoeu.j2s.compilation.scope;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import me.topchetoeu.jscript.compilation.scope.VariableIndex.IndexType;
|
||||
import me.topchetoeu.j2s.compilation.scope.VariableIndex.IndexType;
|
||||
|
||||
public final class VariableList implements Iterable<Variable> {
|
||||
private final class VariableNode implements Supplier<VariableIndex> {
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.j2s.compilation.values;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
|
||||
public class ArgumentsNode extends Node {
|
||||
@@ -1,15 +1,15 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.j2s.compilation.values;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
|
||||
public class ArrayNode extends Node {
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.j2s.compilation.values;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
|
||||
public class GlobalThisNode extends Node {
|
||||
@@ -1,21 +1,21 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.j2s.compilation.values;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.jscript.compilation.members.FieldMemberNode;
|
||||
import me.topchetoeu.jscript.compilation.members.Member;
|
||||
import me.topchetoeu.jscript.compilation.members.PropertyMemberNode;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.NumberNode;
|
||||
import me.topchetoeu.jscript.compilation.values.constants.StringNode;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
import me.topchetoeu.j2s.compilation.members.FieldMemberNode;
|
||||
import me.topchetoeu.j2s.compilation.members.Member;
|
||||
import me.topchetoeu.j2s.compilation.members.PropertyMemberNode;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.NumberNode;
|
||||
import me.topchetoeu.j2s.compilation.values.constants.StringNode;
|
||||
|
||||
public class ObjectNode extends Node {
|
||||
public final List<Member> members;
|
||||
@@ -1,12 +1,12 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.j2s.compilation.values;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class RegexNode extends Node {
|
||||
public final String pattern, flags;
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.j2s.compilation.values;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
|
||||
public class ThisNode extends Node {
|
||||
@@ -1,14 +1,14 @@
|
||||
package me.topchetoeu.jscript.compilation.values;
|
||||
package me.topchetoeu.j2s.compilation.values;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.common.parsing.ParseRes;
|
||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||
import me.topchetoeu.jscript.common.parsing.Source;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.jscript.compilation.patterns.ChangeTarget;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.common.parsing.ParseRes;
|
||||
import me.topchetoeu.j2s.common.parsing.Parsing;
|
||||
import me.topchetoeu.j2s.common.parsing.Source;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.JavaScript;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
import me.topchetoeu.j2s.compilation.patterns.ChangeTarget;
|
||||
|
||||
public class VariableNode extends Node implements ChangeTarget {
|
||||
public final String name;
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.topchetoeu.jscript.compilation.values.constants;
|
||||
package me.topchetoeu.j2s.compilation.values.constants;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class BoolNode extends Node {
|
||||
public final boolean value;
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.topchetoeu.jscript.compilation.values.constants;
|
||||
package me.topchetoeu.j2s.compilation.values.constants;
|
||||
|
||||
import me.topchetoeu.jscript.common.Instruction;
|
||||
import me.topchetoeu.jscript.common.parsing.Location;
|
||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||
import me.topchetoeu.jscript.compilation.Node;
|
||||
import me.topchetoeu.j2s.common.Instruction;
|
||||
import me.topchetoeu.j2s.common.parsing.Location;
|
||||
import me.topchetoeu.j2s.compilation.CompileResult;
|
||||
import me.topchetoeu.j2s.compilation.Node;
|
||||
|
||||
public class NullNode extends Node {
|
||||
@Override public void compileFunctions(CompileResult target) {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user