Checkpoint, going this way again it seems

node v18.11.0
version: 1.0.0
endpointsharetweet
const ObjectOwnPropertyKeys = Reflect.ownKeys; const given = f => f(); const { assign: ObjectAssign, create: ObjectCreate, keys: ObjectKeys, entries: ObjectEntries, freeze: ObjectFreeze, fromEntries: ObjectFromEntries, hasOwn: ObjectHasOwn, getPrototypeOf: ObjectGetPrototypeOf, setPrototypeOf: ObjectSetPrototypeOf, } = Object; const { isArray: ArrayIsArray } = Array; const { join: ArrayPrototypeJoin, map: ArrayPrototypeMap } = Array.prototype; const ArrayF = ObjectFromEntries(["filter", "map", "join", "reduce"] .map(name => given(( f = Array.prototype[name]) => [name, (array, ...args) => Call(f, array, ...args)]))); const { toString: ObjectPrototypeToString } = Object.prototype; const ObjectFilter = (object, f) => ObjectFilterEntries(object, ([key, value]) => f(value, key)); const ObjectFilterKeys = (object, f) => ObjectFilter(object, (_, key) => f(key)); const ObjectFilterEntries = (object, f) => ObjectFromEntries(ObjectEntries(object).filter(f)); const ObjectMap = (object, f) => ObjectMapEntries(object, ([key, value]) => [key, f(value, key)]); const ObjectMapEntries = (object, f) => ObjectFromEntries(ObjectOwnPropertyKeys(object) .map(key => f([key, object[key]]))); const { has: WeakMapProrotypeHas, get: WeakMapPrototypeGet, set: WeakMapPrototypeSet } = WeakMap.prototype; const { entries: MapPrototypeEntries, get: MapPrototypeGet, has: MapPrototypeHas, keys: MapPrototypeKeys, values: MapPrototypeValues } = Map.prototype;
const IsNull = V => V === null; const IsString = V => typeof V === "string"; const IsCallable = V => typeof V === "function"; const IsNonCallableObject = V => !IsNull(V) && typeof V === "object"; const IsObject = value => !IsNull(value) && typeof value === "object" || typeof value === "function"; const Call = Function.prototype.call.bind(Function.prototype.call); const IsNotNull = value => value !== null;
const { IsReifiedObject, GetInternalSlot, GetInstanceData, ReifiedObjectClaim, } = given(( InternalSlotsForReifiedObjects = new WeakMap(), WeakMapHas = (WM, K, V) => WM.has(K, V), WeakMapKey = (WM, K, V) => (WM.set(K, V), K), WeakMapSet = (WM, K, V) => WM.set(K, V), WeakMapGet = (WM, K, f) => WM.get(K)) => ({ IsReifiedObject: O => WeakMapHas(InternalSlotsForReifiedObjects, O), GetInternalSlot: (ReifiedObject, InternalSlot) => WeakMapGet(InternalSlotsForReifiedObjects, ReifiedObject)[InternalSlot], GetInstanceData: ReifiedObject => GetInternalSlot(ReifiedObject, "[[InstanceData]]"), ReifiedObjectClaim: ( ImmutablePlatformPrototype, /* :: Immutable<PlatformPrototype> */ [Type, TypeId], /* :: Left [Type] | Right [false, TypeId] */ CaseName, /* :: string */ InstanceData, /* :: Immutable<PlatformObject> | null */ UnreachablePlatformNucleus /* :: Unreachable<PlatformObject> */, OptionalPropertiesToCopy /* :: PlatformObject | null | undefined */) => given(( nucleusPrototype = ObjectGetPrototypeOf(UnreachablePlatformNucleus), needsSetPrototypeOf = nucleusPrototype !== ImmutablePlatformPrototype, targetPrototyped = needsSetPrototypeOf ? ObjectSetPrototypeOf( UnreachablePlatformNucleus, ImmutablePlatformPrototype) : UnreachablePlatformNucleus, targetDetailed = !!OptionalPropertiesToCopy ? ObjectAssign( targetPrototyped, OptionalPropertiesToCopy) : targetPrototyped, targetImmutable = ObjectFreeze(targetDetailed)) => WeakMapKey( InternalSlotsForReifiedObjects, targetImmutable, ObjectFreeze(ObjectSetPrototypeOf( { "[[Type]]": [Type, TypeId], "[[Case]]": CaseName, "[[InstanceData]]": InstanceData }, null)))) }));
const ToUnreachablePlatformFunction = given(( AdditionalParameterNames = { "LEXICAL": [], "STRICT": ["Call"], "CONSTRUCTOR": ["Call"] }, TargetFunctionSourceText = { "LEXICAL": `: (...args) => FunctionBody(...args)`, "STRICT": `(...args) { return Call(FunctionBody, this, ...args) }`, "CONSTRUCTOR": `: function (...args) { return Call( FunctionBody, this, new.target, ...args) }` }, FIXME_quote = x => `"${x}"`) => (ThisMode, FunctionName, FunctionBody, PropertiesToCopy) => given(( quotedFunctionName = FIXME_quote(FunctionName), toUnreachablePlatformFunction = new Function( "FunctionBody", ...AdditionalParameterNames[ThisMode], `return { ${quotedFunctionName}` + TargetFunctionSourceText[ThisMode] + `}[${quotedFunctionName}]`), platformFunction = ThisMode === "LEXICAL" ? toUnreachablePlatformFunction(FunctionBody) : toUnreachablePlatformFunction(FunctionBody, Call), propertiedFunction = PropertiesToCopy ? ObjectAssign(platformFunction, PropertiesToCopy) : platformFunction) => propertiedFunction));
const ToBridgePrototype = given(( toString = ToUnreachablePlatformFunction( "STRICT", "toString", ObjectPrototypeToString), toStringTag = Symbol.toStringTag, toPrototypeProperties = (ToStringTag, PropertiesToCopy) => PropertiesToCopy ? { [toStringTag]: ToStringTag, toString, ...PropertiesToCopy } : { [toStringTag]: ToStringTag, toString }) => ( ConstructorName, PropertiesToCopy, BasePrototype) =>(console.log(ConstructorName)) || ObjectFreeze( ObjectAssign( ObjectSetPrototypeOf( ToUnreachablePlatformFunction( "CONSTRUCTOR", ConstructorName, () => { throw "OH NO!" }).prototype, null), toPrototypeProperties( ConstructorName, PropertiesToCopy)))); const IsSelfApplicable = value => IsCallable(value) && /^(?:\(\s*)?(?:self|callee)(?=[,\s\)])/.test(value + "");
const PrimitiveTypeNames = [ "bigint", "boolean", "number", "null", "string", "symbol", "undefined" ]; const BootstrapTypeSchemas = { "TypeDefinition": { "cases": { "": (U๐‘, L) => U๐‘(L + 1).CaseDefinition({ "name": U๐‘(L + 1).FieldDefinition.Parameter({ "domain": () => U๐‘(L + 1).Maybe(U๐‘(0).string), "fallback": () => U๐‘(L + 1).Maybe.Just(U๐‘(L + 1).Maybe(U๐‘(0).string).None), "variadic": false }), "cases": T๐‘(1).FieldDefinition({ "domain": () => U๐‘(L).Dictionary(U๐‘(0).string, U๐‘(L).CaseDefinition), "fallback": () => U๐‘(0).Maybe.Just(() => U๐‘(L).Dictionary(U๐‘(0).string, U๐‘(L).CaseDefinition)()), "variadic": false }) }) }, "prototype": { } }, };
const GetOrSetOwnProperty = (O, P, fallback) => ObjectHasOwn(O, P) ? O[P] : (O[P] = fallback(P));
const FAIL = message => { throw Error(message); }; const ReifiedObjectOrdinaryCreateFromCase = ( TargetTypeOrDeferredType, TargetTypeDefinition, TargetCaseName, TargetCaseDefinition, CalleeArguments) => (console.log("HERE",TargetTypeOrDeferredType, TargetTypeDefinition, TargetCaseName, TargetCaseDefinition, CalleeArguments), ReifiedObjectClaim( ToBridgePrototype("BLAH"), /*GetInstanceData(TargetTypeDefinition) .casePrototypes .get(TargetCaseName),*/ TargetTypeOrDeferredType, null,//TargetTypeDefinition, TargetCaseName, { I_AM_A_TYPE: "hello" }, //CalleeArguments[0], /* ToUnreachablePlatformNucleusFromCase( TargetCaseDefinition, CalleeArguments),*/ null, null)); const ReifiedObjectCreateFromCase = ( TargetType, TargetCaseName, CalleeNewTarget, CalleeArguments) => given(( TargetTypeDefinition = GetInstanceData(TargetType).definition, { name, cases } = GetInstanceData(TargetType).definition, TypeCaseName = TargetCaseName ? `${name}.${TargetCaseName}` : name, isInstantiable = cases.size > 0 || FAIL(`type ${name} is not an instantiable type.`), //cases.count > 0 || FAIL(`type ${name} is not an instantiable type.`), hasConstructor = cases.has(TargetCaseName) || FAIL(`type ${name} has no case named "${TargetCaseName}"`), invokedCorrectly = !CalleeNewTarget || FAIL(`Don't invoke ${TypeCaseName} with "new".`), TargetCaseConstructor = ReifiedObjectOrdinaryCreateFromCase) => TargetCaseConstructor( [TargetType], TargetTypeDefinition, TargetCaseName, null,//TargetCaseDefinition, CalleeArguments)); // REMEMBER, NONE OF THE TYPES EXIST AT PROVISION TIME!!!! WE CREATE WITHOUT THEM const [Type, PrimitiveTypes] = given(( ToTypeDisplayName = given(( DigitSubscripts = "โ‚€โ‚โ‚‚โ‚ƒโ‚„โ‚…โ‚†โ‚‡โ‚ˆโ‚‰", ToLevelSubscript = L => (L + "") .replace(/\d/g, d => DigitSubscripts[d])) => (TypeLevel, TypeName) => TypeLevel === 0 ? TypeName : `${TypeName}${ToLevelSubscript(TypeLevel)}`), ToTypeCaseDisplayName = (TypeLevel, TypeName, CaseName) => CaseName === "" ? ToTypeDisplayName(TypeLevel, TypeName) : `${ToTypeDisplayName(TypeLevel, TypeName)}.${CaseName}`, ReifiedObjectBootstrapCreateFromCase = ( TypeLevel, TypeName, CaseName, InternalData, Nucleus) => ReifiedObjectClaim( ToBridgePrototype("YIKES_" + TypeName + " " + CaseName + " " + TypeLevel), [false, [TypeLevel, TypeName]], CaseName, InternalData, Nucleus), TypeDefinition๐‘ = (TypeLevel, name, cases) => ReifiedObjectBootstrapCreateFromCase( TypeLevel, "TypeDefinition", "", null, { name, cases }), [GetTypeUniverse, PrimitiveTypes] = given(( TypeUniverses = ObjectCreate(null), TypeUniverseCreate = TypeLevel => given(( TypeDisplayName = ToTypeDisplayName(TypeLevel, "Type"), Type = ToUnreachablePlatformFunction( "CONSTRUCTOR", ToTypeDisplayName(TypeLevel, "Type"), (NewTarget, ...args) => (console.log(`IN ${TypeDisplayName} constructor`), ReifiedObjectCreateFromCase(Type, "", NewTarget, args)))) => ReifiedObjectClaim( // We nest this because we want to simulate the // CasePrototype/TypePrototype structure you normally get. ToBridgePrototype(TypeDisplayName), [false, [TypeLevel + 1, "Type"]], "", { definition: TypeDefinition๐‘(TypeLevel, "Type", new Map([["", {}]])) }, Type)), Type0 = TypeUniverseCreate(0), PrimitiveTypes = ObjectFromEntries(ArrayF.map( PrimitiveTypeNames, PrimitiveTypeName => [ PrimitiveTypeName, Type0(TypeDefinition๐‘(0, PrimitiveTypeName, new Map()))])), GetTypeUniverse = TypeLevel => GetOrSetOwnProperty( TypeUniverses, TypeLevel, TypeUniverseCreate)) => [GetTypeUniverse, PrimitiveTypes])) => [GetTypeUniverse, PrimitiveTypes]); x = Type(0)("hi")
PrimitiveTypes
Loadingโ€ฆ

no comments

    sign in to comment