UNPKG

net.akehurst.language-agl-processor

Version:
354 lines (352 loc) 11.1 kB
import { LinkedHashMap1zhqxkxv3xnkl as LinkedHashMap, Unit_instance104q5opgivhr8 as Unit_instance, IllegalStateExceptionkoljg5n0nrlr as IllegalStateException, toString1pkumu07cwy4m as toString, asList2ho2pewtsfvv as asList, THROW_CCE2g6jy02ryeudk as THROW_CCE, KtList3hktaavzmj137 as KtList, isInterface3d6p8outrmvmk as isInterface, emptyList1g2z5xcrvp2zy as emptyList, initMetadataForObject1cxne3s9w65el as initMetadataForObject, VOID7hggqo3abtya as VOID, initMetadataForCompanion1wyw17z38v6ac as initMetadataForCompanion, get_js1ale1wr4fbvs0 as get_js, toList383f556t1dixk as toList, NotImplementedErrorfzlkpv14xxr8 as NotImplementedError, lazy2hsh8ze7j6ikd as lazy, ensureNotNull1e947j3ixpazm as ensureNotNull, endsWith3cq61xxngobwh as endsWith, Enum3alwj03lh1n41 as Enum, createInstance11u8l4wsvcneu as createInstance, initMetadataForClassbxx6q50dy2s7 as initMetadataForClass, getKClassFromExpression3vpejubogshaw as getKClassFromExpression, KClass1cc9rfeybg8hs as KClass, KProperty1ca4yb4wlo496 as KProperty1, getPropertyCallableRef1ajb9in178r5r as getPropertyCallableRef, defineProp3hxgpk2knu2px as defineProp, } from './kotlin-kotlin-stdlib.mjs'; //region block: imports //endregion //region block: pre-declaration class KotlinxReflect { constructor() { KotlinxReflect_instance = this; var tmp = this; // Inline function 'kotlin.collections.mutableMapOf' call tmp.ip_1 = LinkedHashMap.l4(); var tmp_0 = this; // Inline function 'kotlin.collections.mutableMapOf' call tmp_0.jp_1 = LinkedHashMap.l4(); var tmp_1 = this; // Inline function 'kotlin.collections.mutableMapOf' call tmp_1.kp_1 = LinkedHashMap.l4(); var tmp_2 = this; // Inline function 'kotlin.collections.mutableMapOf' call tmp_2.lp_1 = LinkedHashMap.l4(); this.mp_1 = this.ip_1; } np(qualifiedName, cls, enumValuesFunction, objectInstance) { // Inline function 'kotlin.collections.set' call this.ip_1.r2(qualifiedName, cls); // Inline function 'kotlin.collections.set' call this.jp_1.r2(cls, qualifiedName); if (!(null == enumValuesFunction)) { // Inline function 'kotlin.collections.set' call this.kp_1.r2(qualifiedName, enumValuesFunction); } if (!(null == objectInstance)) { // Inline function 'kotlin.collections.set' call this.lp_1.r2(qualifiedName, objectInstance); } } op(qualifiedName) { var tmp0_elvis_lhs = this.mp_1.z2(qualifiedName); var tmp; if (tmp0_elvis_lhs == null) { var message = 'Cannot find class ' + qualifiedName + ", is the class registered with KotlinxReflect and did you remember to call 'KotlinxReflectForModule.registerUsedClasses()'?"; throw IllegalStateException.v4(toString(message)); } else { tmp = tmp0_elvis_lhs; } return tmp; } pp(kclass) { var tmp0_elvis_lhs = this.jp_1.z2(kclass); var tmp; if (tmp0_elvis_lhs == null) { var message = "Cannot get qualifiedName of '" + toString(kclass) + "' is it registered with KotlinxReflect and did you remember to call 'KotlinxReflectForModule.registerUsedClasses()'?"; throw IllegalStateException.v4(toString(message)); } else { tmp = tmp0_elvis_lhs; } return tmp; } qp(qualifiedName) { var tmp0_safe_receiver = this.kp_1.z2(qualifiedName); var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver(); var tmp = tmp1_safe_receiver == null ? null : asList(tmp1_safe_receiver); var tmp2_elvis_lhs = (tmp == null ? true : isInterface(tmp, KtList)) ? tmp : THROW_CCE(); return tmp2_elvis_lhs == null ? emptyList() : tmp2_elvis_lhs; } rp(qualifiedName) { var tmp = this.lp_1.z2(qualifiedName); return (tmp == null ? true : !(tmp == null)) ? tmp : THROW_CCE(); } } class Companion { constructor() { this.metadata = '$metadata$'; } sp() { return this.metadata; } } class ClassReflection { constructor(kclass) { this.kclass = kclass; var tmp = this; tmp.tp_1 = lazy(ClassReflection$allPropertyNames$delegate$lambda(this)); var tmp_0 = this; tmp_0.up_1 = lazy(ClassReflection$allMemberFunctions$delegate$lambda); } vp() { return this.kclass; } wp() { return endsWith(ensureNotNull(this.kclass.zc()), 'Abstract'); } xp() { var tmp0 = this.tp_1; // Inline function 'kotlin.getValue' call allPropertyNames$factory(); return tmp0.b3(); } yp() { var tmp0 = this.up_1; // Inline function 'kotlin.getValue' call allMemberFunctions$factory(); return tmp0.b3(); } zp() { return KotlinxReflect_getInstance().pp(this.kclass); } aq() { var tmp = this.kclass; var n = tmp instanceof Enum; // Inline function 'kotlin.js.asDynamic' call var jsCls = get_js(this.kclass); // Inline function 'kotlin.js.asDynamic' call var ep = Enum.prototype; var tp = Object.getPrototypeOf(jsCls.prototype); return ep == tp; } bq() { var md = '$metadata$'; var cls = get_js(this.kclass); var tmp = 'object' == cls[md].kind; return (!(tmp == null) ? typeof tmp === 'boolean' : false) ? tmp : THROW_CCE(); } construct(constructorArgs) { var cls = get_js(this.kclass); var tmp; if (this.isObject) { var qname = KotlinxReflect_getInstance().pp(this.kclass); var obj = KotlinxReflect_getInstance().rp(qname); var tmp_0; if (obj == null) { var message = "Object instance not found for '" + qname + "', has it been registered?"; throw IllegalStateException.v4(toString(message)); } else { tmp_0 = obj; } tmp = tmp_0; } else { // Inline function 'kotlin.collections.isEmpty' call if (constructorArgs.length === 0) { tmp = createInstance(this.kclass); } else { var obj_0 = Reflect.construct(cls, constructorArgs); tmp = !(obj_0 == null) ? obj_0 : THROW_CCE(); } } return tmp; } isSupertypeOf(subtype) { // Inline function 'kotlin.TODO' call throw NotImplementedError.uj(); } allPropertyNamesFor(self_0) { var js = Object.getOwnPropertyNames(self_0); return toList(js); } isPropertyMutable(propertyName) { var cls = get_js(this.kclass); var tmp = function () { var proto = cls.prototype; var propDescriptor = null; while (proto) { propDescriptor = Object.getOwnPropertyDescriptor(proto, propertyName); if (propDescriptor) { break; } else { proto = Object.getPrototypeOf(proto); } } ; //var result = false var result = true; // try default to true ! if (propDescriptor) { result = typeof propDescriptor.set === 'function'; } return result; }.call(this); return (!(tmp == null) ? typeof tmp === 'boolean' : false) ? tmp : THROW_CCE(); } getProperty(self_0, propertyName) { return self_0[propertyName]; } setProperty(self_0, propertyName, value) { self_0[propertyName] = value; } enumValues() { var tmp; if (this.isEnum) { var tmp_0 = KotlinxReflect_getInstance().qp(this.qualifiedName); tmp = isInterface(tmp_0, KtList) ? tmp_0 : THROW_CCE(); } else { tmp = emptyList(); } return tmp; } enumValueOf(name) { var tmp0 = this.enumValues(); var tmp$ret$1; $l$block: { // Inline function 'kotlin.collections.firstOrNull' call var _iterator__ex2g4s = tmp0.s(); while (_iterator__ex2g4s.t()) { var element = _iterator__ex2g4s.u(); if (element.c3_1 === name) { tmp$ret$1 = element; break $l$block; } } tmp$ret$1 = null; } var tmp = tmp$ret$1; return (tmp == null ? true : tmp instanceof Enum) ? tmp : THROW_CCE(); } call(self_0, methodName, args) { return self_0[methodName](args); } get isAbstract() { return this.wp(); } get allPropertyNames() { return this.xp(); } get allMemberFunctions() { return this.yp(); } get qualifiedName() { return this.zp(); } get isEnum() { return this.aq(); } get isObject() { return this.bq(); } } class ObjectReflection { constructor(self_0) { this.cq_1 = self_0; var tmp = this; var tmp_0 = getKClassFromExpression(this.cq_1); tmp.dq_1 = isInterface(tmp_0, KClass) ? tmp_0 : THROW_CCE(); var tmp_1 = this; tmp_1.eq_1 = lazy(ObjectReflection$allPropertyNames$delegate$lambda(this)); } fq(propertyName) { var self_0 = this.cq_1; return self_0[propertyName]; } gq(propertyName, value) { var self_0 = this.cq_1; self_0[propertyName] = value; } hq(methodName, args) { var self_0 = this.cq_1; return self_0[methodName](args); } } //endregion var KotlinxReflect_instance; function KotlinxReflect_getInstance() { if (KotlinxReflect_instance === VOID) new KotlinxReflect(); return KotlinxReflect_instance; } var Companion_instance; function Companion_getInstance() { return Companion_instance; } function ClassReflection$allPropertyNames$delegate$lambda(this$0) { return () => { var cls = get_js(this$0.kclass); var js = function () { var p = []; var prt = cls.prototype; //Object.getPrototypeOf(cls); var nms = Object.getOwnPropertyNames(prt); for (var i = 0; i < nms.length; i++) if (p.indexOf(nms[i]) == -1) p.push(nms[i]); return p; }(); return toList(js); }; } function ClassReflection$allMemberFunctions$delegate$lambda() { // Inline function 'kotlin.TODO' call throw NotImplementedError.uj(); } function reflect(_this__u8e3s4) { return new ClassReflection(_this__u8e3s4); } function ObjectReflection$allPropertyNames$delegate$lambda(this$0) { return () => { var self_0 = this$0.cq_1; var js = Object.getOwnPropertyNames(self_0); return toList(js); }; } function reflect_0(_this__u8e3s4) { return new ObjectReflection(_this__u8e3s4); } function allPropertyNames$factory() { return getPropertyCallableRef('allPropertyNames', 1, KProperty1, (receiver) => receiver.allPropertyNames, null); } function allMemberFunctions$factory() { return getPropertyCallableRef('allMemberFunctions', 1, KProperty1, (receiver) => receiver.allMemberFunctions, null); } //region block: post-declaration initMetadataForObject(KotlinxReflect, 'KotlinxReflect'); initMetadataForCompanion(Companion); initMetadataForClass(ClassReflection, 'ClassReflection'); initMetadataForClass(ObjectReflection, 'ObjectReflection', VOID, VOID, VOID, [2]); //endregion //region block: init Companion_instance = new Companion(); //endregion //region block: exports defineProp(ClassReflection, 'Companion', Companion_getInstance); export { ClassReflection as ClassReflection, }; export { KotlinxReflect_getInstance as KotlinxReflect_getInstance2hq0ypnv4vmi6, reflect as reflect24kqvyv71l70g, reflect_0 as reflect2lo0xbf04497l, }; //endregion //# sourceMappingURL=net.akehurst.kotlinx-kotlinx-reflect.mjs.map