UNPKG

@sudoo/marked

Version:

JavaScript & TypeScript code runner in JavaScript, safe with marked territory, asynchronous

84 lines (83 loc) 2.19 kB
"use strict"; /** * @author WMXPY * @namespace Variable_SandClass * @description Sand Class */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SandClass = void 0; const error_code_1 = require("../../declare/error-code"); const error_1 = require("../../util/error/error"); const sand_map_1 = require("../sand-map"); class SandClass { static create(className) { return new SandClass(className); } constructor(className) { this._className = className; this._map = sand_map_1.SandMap.fromScratch(); this._staticMap = sand_map_1.SandMap.fromScratch(); this._superClass = null; this._classConstructor = null; } get className() { return this._className; } get body() { return this._map; } get staticBody() { return this._staticMap; } get classConstructor() { return this._classConstructor; } setClassConstructor(classConstructor) { this._classConstructor = classConstructor; return this; } lookFor(key) { if (this._map.has(key)) { return this._map.get(key); } if (this._superClass) { return this._superClass.lookFor(key); } return null; } lookForHas(key) { if (this._map.has(key)) { return true; } if (this._superClass) { return this._superClass.lookForHas(key); } return false; } setSuperClass(superClass) { this._superClass = superClass; return this; } hasSuperClass() { return this._superClass !== null; } ensureSuperClass() { if (this._superClass) { return this._superClass; } throw (0, error_1.error)(error_code_1.ERROR_CODE.INTERNAL_ERROR, "No super class"); } sameClass(other) { if (this === other) { return true; } if (!this._superClass) { return false; } return this._superClass.sameClass(other); } toNative() { return Object.assign({}, this._staticMap.map); } } exports.SandClass = SandClass;