imba-shell
Version:
Interactive debugger and REPL for Imba.
162 lines (157 loc) • 6.95 kB
JavaScript
globalThis.IMBA_MANIFEST={};globalThis.IMBA_ASSETS_PATH='assets';
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function")
for (let key of __getOwnPropNames(from))
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
// src/Errors/index.imba
var Errors_exports = {};
__export(Errors_exports, {
ImbaMissingException: () => ImbaMissingException,
InvalidLanguageException: () => InvalidLanguageException
});
module.exports = __toCommonJS(Errors_exports);
// node_modules/imba/src/imba/runtime.mjs
var __init__$ = /* @__PURE__ */ Symbol.for("#__init__"), __initor__$ = /* @__PURE__ */ Symbol.for("#__initor__");
var __meta__$ = /* @__PURE__ */ Symbol.for("#meta"), __imba__$ = /* @__PURE__ */ Symbol.for("imba");
var HAS = {
SUPERCALLS: 1 << 3,
CONSTRUCTOR: 1 << 4
}, ClassFlags = {
IsExtension: 1 << 0,
IsTag: 1 << 1,
HasDescriptors: 1 << 2,
HasSuperCalls: 1 << 3,
HasConstructor: 1 << 4,
HasFields: 1 << 5,
HasMixins: 1 << 6,
HasInitor: 1 << 7,
HasDecorators: 1 << 8,
IsObjectExtension: 1 << 9
}, mmap = /* @__PURE__ */ new Map(), state = globalThis[__imba__$] || (globalThis[__imba__$] = {
counter: 0,
classes: mmap
});
function meta$(klass, defaults = {}) {
var _a;
return mmap.has(klass) || mmap.set(klass, {
symbol: /* @__PURE__ */ Symbol(klass.name),
parent: (_a = Object.getPrototypeOf(klass.prototype)) == null ? void 0 : _a.constructor,
for: klass,
uses: null,
inits: null,
id: state.counter++,
...defaults
}), mmap.get(klass);
}
function isSameDesc(a, b) {
if (!a || !b)
return !1;
if (a.get)
return b.get === a.get;
if (a.set)
return b.set === a.set;
if (a.value)
return a.value === b.value;
}
function extend$(target, ext, descs, cache = {}) {
let klass = target.constructor;
!descs && ext && (descs = Object.getOwnPropertyDescriptors(ext), delete descs.constructor, descs[__init__$] && (console.warn(`Cannot define plain fields when extending class ${klass.name}`), delete descs[__init__$]));
let meta = meta$(klass);
if (meta && meta.augments) {
let map = /* @__PURE__ */ new Map();
for (let key of Object.keys(descs)) {
let orig = Object.getOwnPropertyDescriptor(target, key);
for (let augmented of meta.augments) {
let defines = map.get(augmented);
defines || map.set(augmented, defines = {});
let augmentedKey = Object.getOwnPropertyDescriptor(augmented.prototype, key);
augmentedKey && !isSameDesc(orig, augmentedKey) ? console.warn("wont extend", key, augmentedKey, orig) : defines[key] = descs[key];
}
}
for (let [augmented, defines] of map)
Object.keys(defines).length && extend$(augmented.prototype, null, defines);
}
return Object.defineProperties(target, descs), target;
}
function augment$(klass, mixin) {
let meta = meta$(klass), mix = meta$(mixin);
if (mix.parent && !(klass.prototype instanceof mix.parent))
throw new Error(`Mixin ${mixin.name} has superclass not present in target class`);
if (!mix.augments) {
mix.augments = /* @__PURE__ */ new Set();
let ref = mix.ref = /* @__PURE__ */ Symbol(mixin.name), native = Object[Symbol.hasInstance];
mixin.prototype[ref] = !0, Object.defineProperty(mixin, Symbol.hasInstance, {
value: function(rel) {
return this === mixin ? rel && !!rel[ref] : native.call(this, rel);
}
});
}
if (klass.prototype[mix.ref])
return klass;
if (mix.uses)
for (let v of mix.uses)
augment$(klass, v);
mix.augments.add(klass), meta.uses || (meta.uses = []), meta.uses.push(mixin);
let descs = Object.getOwnPropertyDescriptors(mixin.prototype);
return delete descs.constructor, descs[__init__$] && (meta.inits || (meta.inits = []), meta.inits.push(mixin.prototype[__init__$]), delete descs[__init__$]), Object.defineProperties(klass.prototype, descs), (mixin == null ? void 0 : mixin.mixed) instanceof Function && mixin.mixed(klass), klass;
}
var sup = {
cache: {},
self: null,
target: null,
proxy: new Proxy({}, {
apply: (_, key, ...params) => sup.target[key].apply(sup.self, params),
get: (_, key) => Reflect.get(sup.target, key, sup.self),
set: (_, key, value, receiver) => Reflect.set(sup.target, key, value, sup.self)
})
};
function register$(klass, symbol, name, flags, into = null) {
var _a;
let proto = Object.getPrototypeOf(klass.prototype), mixed = flags & ClassFlags.HasMixins, meta;
if (mixed && (mmap.set(klass, mmap.get(proto.constructor)), proto = Object.getPrototypeOf(proto)), into) {
let target = flags & ClassFlags.IsObjectExtension ? into : into.prototype, meta2 = meta$(klass);
if (meta2.uses) {
into === target && console.warn("Cannot extend object with mixins");
for (let mixin of meta2.uses)
augment$(into, mixin);
}
return flags & ClassFlags.HasSuperCalls && (sup.cache[symbol] = Object.create(
Object.getPrototypeOf(target),
Object.getOwnPropertyDescriptors(target)
)), extend$(target, klass.prototype), into;
}
let supr = proto == null ? void 0 : proto.constructor;
if (meta = meta$(klass, { symbol }), Object.defineProperty(klass, __meta__$, { value: meta, enumerable: !1, configurable: !0 }), name && klass.name !== name && Object.defineProperty(klass, "name", { value: name, configurable: !0 }), meta.flags = flags, flags & ClassFlags.HasConstructor && (klass.prototype[__initor__$] = symbol), meta.uses)
for (let mixin of meta.uses)
(_a = mixin.mixes) == null || _a.call(mixin, klass);
return (supr == null ? void 0 : supr.inherited) instanceof Function && supr.inherited(klass), klass;
}
// src/Errors/ImbaMissingException.imba
var c$0 = /* @__PURE__ */ Symbol(), _ImbaMissingException = class extends Error {
}, ImbaMissingException = _ImbaMissingException;
(() => {
register$(_ImbaMissingException, c$0, "ImbaMissingException", 0);
})();
// src/Errors/InvalidLanguageException.imba
var c$02 = /* @__PURE__ */ Symbol(), _InvalidLanguageException = class extends Error {
}, InvalidLanguageException = _InvalidLanguageException;
(() => {
register$(_InvalidLanguageException, c$02, "InvalidLanguageException", 0);
})();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ImbaMissingException,
InvalidLanguageException
});
//__FOOT__
//# sourceMappingURL=./index.js.map