Compare commits
9 Commits
4ea14ca1f5
...
31e2e95bc8
Author | SHA1 | Date | |
---|---|---|---|
31e2e95bc8 | |||
98dde69751 | |||
ec1edb981e | |||
36f9839485 | |||
22f36267c0 | |||
f8b9776f28 | |||
12cff84666 | |||
7058a689a2 | |||
fde8b42e36 |
@ -112,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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -82,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;
|
||||
|
||||
|
@ -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,7 +1,4 @@
|
||||
// import coffeescript from "./coffeescript.ts";
|
||||
// import babel from "./babel.ts";
|
||||
import coffeescript from "./coffeescript.ts";
|
||||
import babel from "./babel.ts";
|
||||
|
||||
// register(v => coffeescript(babel(v)));
|
||||
import typescript from "./typescript.ts";
|
||||
|
||||
register(typescript);
|
||||
register(v => coffeescript(babel(v)));
|
||||
|
@ -11,17 +11,14 @@ export default function babel(next: Compiler): Compiler {
|
||||
presets: [availablePresets.env],
|
||||
});
|
||||
|
||||
print(res.map!.mappings);
|
||||
|
||||
const map = SourceMap.parse({
|
||||
file: "babel-internal://" + filename,
|
||||
mappings: res.map!.mappings,
|
||||
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));
|
||||
};
|
||||
}
|
||||
|
||||
|
2
src/lib/transpiler/transpiler.d.ts
vendored
2
src/lib/transpiler/transpiler.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
type Location = readonly [file: string, line: number, start: number];
|
||||
type Location = [file: string, line: number, start: number];
|
||||
type SourceMap = (loc: Location) => Location | undefined;
|
||||
|
||||
type CompilerFactory = (next: Compiler) => Compiler;
|
||||
|
@ -106,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);
|
||||
|
@ -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) {
|
||||
|
@ -409,7 +409,43 @@ public class SimpleDebugger implements Debugger {
|
||||
res.set("description", className);
|
||||
}
|
||||
|
||||
if (val instanceof ArrayValue arr) res.set("description", "Array(" + arr.size() + ")");
|
||||
if (val instanceof ArrayValue arr) {
|
||||
var desc = new StringBuilder("Array(" + arr.size() + ")");
|
||||
|
||||
if (arr.size() > 0) {
|
||||
desc.append("[");
|
||||
|
||||
for (var i = 0; i < arr.size(); i++) {
|
||||
if (i != 0) desc.append(", ");
|
||||
if (desc.length() > 120) {
|
||||
desc.append("...");
|
||||
break;
|
||||
}
|
||||
|
||||
if (arr.has(i)) {
|
||||
try {
|
||||
var curr = arr.get(i);
|
||||
if (curr instanceof StringValue str) {
|
||||
desc.append(JSON.stringify(JSONElement.string(str.value)));
|
||||
}
|
||||
else {
|
||||
desc.append(arr.get(i).toString(env));
|
||||
}
|
||||
}
|
||||
catch (EngineException e) {
|
||||
desc.append("<error>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
desc.append("<empty>");
|
||||
}
|
||||
}
|
||||
|
||||
desc.append("]");
|
||||
}
|
||||
|
||||
res.set("description", desc.toString());
|
||||
}
|
||||
else if (val instanceof FunctionValue) res.set("description", val.toString());
|
||||
else {
|
||||
var defaultToString = false;
|
||||
|
Loading…
Reference in New Issue
Block a user