UNPKG

minigrace

Version:

A compiler for the Grace programming language

947 lines (943 loc) 92.5 kB
let gracecode_mirror_sourceFile = "/Users/black/Development/mg/gracelang/minigrace/mirror.grace"; let gracecode_mirror_sha256 = "50f3da794fdf32fc3f5de55752f15752f46ae09666701a8c24a3578df41bc6bf"; let gracecode_mirror_minigraceRevision = "b57591d29fc5ee5270d114920bf671367b8c3ecb"; let gracecode_mirror_minigraceGeneration = "5171"; if (typeof gctCache !== "undefined") gctCache["mirror"] = "dialect:\nfreshScopes:\n $103 trait\n $105\n $106\n $107 trait\n $108 trait\n $109\nmethodTypes:$104:\n isTheSame(left:Unknown, right:Unknown) \u2192 Boolean\n numberOfParameters(numericName:Unknown) \u2192 Number\nmethodTypes:$105:\n methods \u2192 Sequence\u27e6MethodMirror\u27e7\n request(nm:String)withArgs(args:Sequence\u27e6Object\u27e7) \u2192 Unknown\nmodules:\n basicTypesBundle\n equalityBundle\n intrinsic\npath:\n /Users/black/Development/mg/gracelang/minigrace/mirror.grace\nscope:$103:\n ::(1) Unknown (mth) $scope_done\n ==(1) Unknown (req) $scopeUniv\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n basicAsString String (go) $scope_string\n hash Unknown (req) $scopeUniv\n isMe(1) Boolean (go) $scope_boolean\n myIdentityHash Number (go) $scope_number\n prefix== Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$104:\n Binding type\n Boolean type\n Collection type\n CollectionFactory type\n Done type\n Enumerable type\n EqualityObject type\n ExceptionKind type\n ExceptionPacket type\n Function0 type\n Function1 type\n Function2 type\n Function3 type\n Interface type\n Iterator type\n MethodMirror type\n Mirror type\n None type\n Number type\n Object type\n Pattern type\n Point type\n Predicate0 type\n Predicate1 type\n Predicate2 type\n Predicate3 type\n Procedure0 type\n Procedure1 type\n Procedure2 type\n Procedure3 type\n SelfType type\n Sequence type\n Sequenceable type\n Signature type\n Sink type\n String type\n Type type\n abstract Unknown (mth) $scope_done\n annotation Unknown (mth) $scope_done\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n basicAsString String (go) $scope_string\n binding Unknown (mth) $107\n confidential Unknown (mth) $scope_done\n equality Unknown (mth) $103\n identityEquality Unknown (mth) $108\n initialModuleName Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n isTheSame(2) Boolean (mth) $scope_done\n loadModule(1) Unknown (mth) $scope_done\n methodMirror(2) Unknown (mth) $106\n myIdentityHash Number (go) $scope_number\n numberOfParameters(1) Number (mth) $scope_done\n override Unknown (mth) $scope_done\n public Unknown (mth) $scope_done\n readable Unknown (mth) $scope_done\n reflect(1) Unknown (mth) $105\n required Unknown (mth) $scope_done\n writable Unknown (mth) $scope_done\nscope:$105:\n ::(1) Unknown (mth) $scope_done\n ==(1) Unknown (mth) $scope_done\n allMethodNames Unknown (mth) $scope_done\n asDebugString String (go) $scope_string\n asString Unknown (mth) $scope_done\n basicAsString String (go) $scope_string\n confidentialMethodNames Unknown (mth) $scope_done\n definitionLine Unknown (mth) $scope_done\n definitionModule Unknown (mth) $scope_done\n hash Unknown (mth) $scope_done\n ilk Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n methodNames Unknown (mth) $scope_done\n methods Sequence (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n onMethod(1) Unknown (mth) $scope_done\n prefix== Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n request(1)withArgs(1) Unknown (mth) $scope_done\n subject Unknown (def) $scopeEmpty public\n whenNoMethodDo(1) Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$106:\n ::(1) Unknown (mth) $scope_done\n ==(1) Unknown (mth) $scope_done\n asDebugString String (go) $scope_string\n asString Unknown (mth) $scope_done\n basicAsString String (go) $scope_string\n hash Unknown (mth) $scope_done\n isConfidential Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n isPublic Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n name Unknown (mth) $scope_done\n numberOfParams Unknown (mth) $scope_done\n numberOfTypeParams Unknown (mth) $scope_done\n paramCounts Unknown (mth) $scope_done\n paramNames Unknown (mth) $scope_done\n paramTypes Unknown (mth) $scope_done\n partCount Unknown (mth) $scope_done\n prefix== Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n requestWithArgs(1) Unknown (mth) $scope_done\n returnType Unknown (mth) $scope_done\n subject Unknown (def) $scopeEmpty public\n typeParamNames Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$107:\n asDebugString String (go) $scope_string\n asString Unknown (mth) $scope_done\n basicAsString String (go) $scope_string\n isMe(1) Boolean (go) $scope_boolean\n key(1)value(1) Unknown (mth) $109\n myIdentityHash Number (go) $scope_number\nscope:$108:\n ::(1) Unknown (mth) $scope_done\n ==(1) Unknown (mth) $scope_done\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n basicAsString String (go) $scope_string\n hash Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n myIdentityHash Number (go) $scope_number\n prefix== Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$109:\n ::(1) Unknown (mth) $scope_done\n ==(1) Unknown (mth) $scope_done\n asDebugString Unknown (mth) $scope_done\n asString Unknown (mth) $scope_done\n basicAsString String (go) $scope_string\n hash Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n key Unknown (def) $scopeEmpty\n myIdentityHash Number (go) $scope_number\n prefix== Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n value Unknown (def) $scopeEmpty\n \u2260(1) Unknown (mth) $scope_done\nself:\n $104\ntypedec:$104.MethodMirror:\n type MethodMirror = EqualityObject & interface {\n name \u2192 String\n numberOfParams \u2192 Number\n numberOfTypeParams \u2192 Number\n partCount \u2192 Number\n paramCounts \u2192 Sequence\u27e6Number\u27e7\n paramNames \u2192 Sequence\u27e6String\u27e7\n paramTypes \u2192 Sequence\u27e6Type\u27e7\n returnType \u2192 Type\n typeParamNames \u2192 Sequence\u27e6String\u27e7\n requestWithArgs(args:Sequence\u27e6Object\u27e7) \u2192 Unknown\n subject \u2192 Object\n isConfidential \u2192 Boolean\n isPublic \u2192 Boolean}\ntypedec:$104.Mirror:\n type Mirror = EqualityObject & interface {\n methods \u2192 Sequence\u27e6MethodMirror\u27e7\n methodNames \u2192 Sequence\u27e6String\u27e7\n confidentialMethodNames \u2192 Sequence\u27e6String\u27e7\n allMethodNames \u2192 Sequence\u27e6String\u27e7\n onMethod(nm:String) \u2192 MethodMirror\n request(nm:String)withArgs(args:Sequence\u27e6Object\u27e7) \u2192 Unknown\n ilk \u2192 String\n definitionModule \u2192 String\n definitionLine \u2192 String\n subject \u2192 Object\n whenNoMethodDo(action:Function3) \u2192 Done}\ntypes:\n $104.MethodMirror\n $104.Mirror\n"; if (typeof originalSourceLines !== "undefined") { originalSourceLines["mirror"] = [ "dialect \"none\"", "import \"intrinsic\" as intrinsic", "import \"basicTypesBundle\" as basicTypesBundle", "import \"equalityBundle\" as equalityBundle", "", "use intrinsic.annotations", "use basicTypesBundle.open", "use equalityBundle.open", "", "type Mirror = EqualityObject & interface {", " methods → Sequence⟦MethodMirror⟧ // mirrors on all of subject's methods", " methodNames → Sequence⟦String⟧ // the names of the subject's non-confidential methods", " confidentialMethodNames → Sequence⟦String⟧ // the names of the subject's confidential methods", " allMethodNames → Sequence⟦String⟧ // the names of all of the subject's methods", " onMethod(nm:String) → MethodMirror // a mirror on the method with name nm", " request(nm:String)withArgs(args:Sequence⟦Object⟧) → Unknown", " ilk → String // a uid for the subject's object constructor", " definitionModule → String // the name of the module containing the subject's constructor", " definitionLine → String // the line number of the start of the subject's constructor", " subject → Object // the object on which I reflect", " whenNoMethodDo(action:Function3) → Done", " // if subject is sent a request named nm, with argument list args, and", " // there is no method nm, action will be applied to (nm, args, subject)", "}", "", "type MethodMirror = EqualityObject & interface {", " name → String // canonical name of the method", " numberOfParams → Number // the number of parameters of the method", " numberOfTypeParams → Number // the number of type parameters", " partCount → Number // the number of parts to name", " paramCounts → Sequence⟦Number⟧ // the number of parameters to each part", " paramNames → Sequence⟦String⟧ // the names of the parameters", " paramTypes → Sequence⟦Type⟧ // the types of the parameters", " returnType → Type", " typeParamNames → Sequence⟦String⟧// the names of the type parameters", " requestWithArgs(args:Sequence⟦Object⟧) → Unknown", " // executes the method with args; ordonary arguments first, followed by type args", " subject → Object // the object on whose method I reflect", " isConfidential → Boolean // true if this method is confidential", " isPublic → Boolean // true if this method is public", "}", "", "def MMhash = \"MM\".hash", "def OMhash = \"OM\".hash", "def thisModule = self", "", "class reflect(subj) {", " // answers a Mirror on subj", " use equality", " def subject is public = subj", " method asString { \"a mirror on {subject}\" }", " method methods → Sequence⟦MethodMirror⟧ {", " native \"js\" code ‹", " var meths = [];", " var current = this.data.subject;", " for (var k in current.methods) {", " if (! k.includes(\"$\") && current.methods.hasOwnProperty(k)) {", " meths.push(request(var_thisModule, \"methodMirror(2)\",", " 2, current, new GraceString(k)));", " }", " }", " return new GraceSequence(meths);", " ›", " }", " method methodNames {", " // Answers a sorted sequence of strings, being the names of the subject's", " // public methods. Don't use a set, to limit dependencies", " native \"js\" code ‹", " var methNames = [];", " var current = this.data.subject;", " for (var k in current.methods) {", " if (! k.includes(\"$\") && current.methods.hasOwnProperty(k) &&", " ! current.methods[k].confidential) {", " methNames.push(canonicalMethodName(k));", " }", " }", " return new GraceSequence(methNames.sort().map(", " nm => new GraceString(nm)));", " ›", " }", " method confidentialMethodNames {", " // answers a sorted sequecne of strings (not a set) being the names of", " // the subject's confidential methods", " native \"js\" code ‹", " var methNames = [];", " var current = this.data.subject;", " for (var k in current.methods) {", " if (! k.includes(\"$\") && current.methods.hasOwnProperty(k) &&", " current.methods[k].confidential) {", " methNames.push(canonicalMethodName(k));", " }", " }", " return new GraceSequence(methNames.sort().map(", " nm => new GraceString(nm)));", " ›", " }", " method allMethodNames {", " // answers a sorted sequecne of strings, being the names of all of", " // the subject's methods", " native \"js\" code ‹", " var methNames = [];", " var current = this.data.subject;", " for (var k in current.methods) {", " if (! k.includes(\"$\") && current.methods.hasOwnProperty(k)) {", " methNames.push(canonicalMethodName(k));", " }", " }", " return new GraceSequence(methNames.sort().map(", " nm => new GraceString(nm)));", " ›", " }", " method onMethod(nm) {", " // answers a MethodMirror on the subject's method named nm", " methodMirror(subject, nm)", " }", "", " method request(nm:String) withArgs(args:Sequence⟦Object⟧) → Unknown {", " def methodMirror = methodMirror(subject, nm)", " methodMirror.requestWithArgs(args)", " }", "", " method whenNoMethodDo(handlerBlock) {", " // sets up handlerBlock (a function with 3 parameters) to be applied when", " // a requested method is not found. The parameters of handlerBlock are", " // name:String — the canonical name of the requested method", " // args:Sequence⟦Object⟧ — the arguments of the original request", " // receiver:Object — the object on which the request was originally made", " // (which will be the subject of this mirror)", " native \"js\" code ‹this.data.subject.noSuchMethodHandler = var_handlerBlock;›", " }", " method ilk {", " native \"js\" code ‹return new GraceString(this.data.subject.classUid);›", " }", " method definitionModule {", " native \"js\" code ‹return new GraceString(this.data.subject.definitionModule);›", " }", " method definitionLine {", " native \"js\" code ‹return new GraceNum(this.data.subject.definitionLine || 0);›", " }", " method hash {", " def subjectHash = native \"js\" code ‹", " result = selfRequest(this.data.subject, \"myIdentityHash\");", " › // in native code so that we can make it a _self_ request", " intrinsic.hashCombine(OMhash, subjectHash);", " }", " method == (other) {", " native \"js\" code ‹", " if (this.classUid !== var_other.classUid) {", " return GraceFalse; // return false if other is not a Mirror", " }", " if (this.data.subject !== var_other.data.subject) {", " return GraceFalse; // return false if we don't have the same subject", " }", " return GraceTrue;", " ›", " }", "}", "", "class methodMirror(theSubject, aMethodName) {", " // Answers a MethodMirror on theSubject's method with name aMethodName", " // For flexibility, we allow aMethodName to be canonical or numeric", "", " use equality", "", " def subject is public = theSubject", "", " native \"js\" code ‹", " const rawName = var_aMethodName._value;", " if (rawName.indexOf(\"(\") === -1) {", " this.numericName = rawName;", " this.canonicalName = rawName;", " } else if (rawName.match(/\\(\\d+\\)/)) {", " this.numericName = rawName;", " this.canonicalName = canonicalMethodName(rawName);", " } else {", " this.numericName = numericMethodName(rawName);", " this.canonicalName = rawName;", " };", " if (! this.data.subject.methods[this.numericName]) {", " var exceptionMsg = new GraceString(\"no method \" +", " this.canonicalMethodName + \" in mirror for \");", " const objDescription = request(this.data.subject, \"asString\", [0]);", " exceptionMsg = request(exceptionMsg, \"++(1)\", [1], objDescription);", " throw new GraceExceptionPacket(NoSuchMethodErrorObject, exceptionMsg);", " };", " this.theFunction = this.data.subject.methods[this.numericName];", " ›", "", " method name {", " native \"js\" code ‹return new GraceString(this.canonicalName)›", " }", " method asString { \"mirror on method '{name}' of {subject}\" }", " method partCount {", " native \"js\" code ‹", " const count = this.numericName.split(\"(\").length;", " if (count === 1) return new GraceNum(1);", " return new GraceNum(count - 1);", " ›", " }", " method paramCounts {", " native \"js\" code ‹", " const len = this.theFunction.paramCounts ? this.theFunction.paramCounts.length : 0;", " const countArray = new Array(len);", " for (var i = 0; i < len; i++) {", " countArray[i] = new GraceNum(this.theFunction.paramCounts[i]);", " }", " return new GraceSequence(countArray);", " ›", " }", "", " method isConfidential {", " native \"js\" code ‹", " return (this.theFunction.confidential ? GraceTrue : GraceFalse);", " ›", " }", "", " method isPublic {", " native \"js\" code ‹", " return (this.theFunction.confidential ? GraceFalse : GraceTrue);", " ›", " }", "", " method numberOfParams {", " native \"js\" code ‹", " return new GraceNum(this.theFunction.paramNames.length);", " ›", " }", "", " method numberOfTypeParams {", " native \"js\" code ‹", " return new GraceNum(this.theFunction.typeParamNames.length);", " ›", " }", "", " method paramNames {", " native \"js\" code ‹", " const graceNames = this.theFunction.paramNames.map(s => new GraceString(s));", " return new GraceSequence(graceNames);", " ›", " }", "", " method paramTypes {", " native \"js\" code ‹", " var types;", " const paramTypes = this.theFunction.paramTypes;", " if (typeof paramTypes == \"function\") {", " const nrTypeParams = this.theFunction.typeParamNames.length;", " const paramTypesBlock = new GraceBlock(", " {definitionModule: \"mirror\"}, 247, nrTypeParams);", " paramTypesBlock.guard = function(...args) {", " for (let i=0; i<args.length; i++) {", " if (! isGraceType(args[i])) return false;", " }", " return true;", " };", " paramTypesBlock.real = (...args) =>", " new GraceSequence(paramTypes.apply(this.theFunction, args));", " const applyMeth = (argcv, ...args) => {", " if (paramTypesBlock.guard.apply(paramTypesBlock, args))", " return paramTypesBlock.real.apply(this.theFunction, args);", " for (let i=0; i<args.length; i++) {", " if (! isGraceType(args[i])) {", " raiseException(RequestErrorObject,", " \"argument \" + (i+1) + \" to block (from methodMirror.paramTypes) is not a type.\");", " }", " }", " };", " applyMeth.methodName = \"apply(\" + nrTypeParams + \")\";", " applyMeth.paramCounts = [nrTypeParams];", " applyMeth.paramNames = this.theFunction.typeParamNames;", " applyMeth.definitionLine = this.theFunction.definitionLine;", " applyMeth.definitionModule = this.theFunction.definitionModule;", " paramTypesBlock.methods[applyMeth.methodName] = applyMeth;", " return paramTypesBlock;", " }", " if (paramTypes) {", " types = this.theFunction.paramTypes;", " } else {", " types = Array(this.theFunction.paramNames.length).fill(type_Unknown);", " }", " return new GraceSequence(types);", " ›", " }", "", " method returnType {", " native \"js\" code ‹", " const returnType = this.theFunction.returnType;", " if (typeof returnType == \"function\") {", " const nrTypeParams = this.theFunction.typeParamNames.length;", " const returnTypeBlock = new GraceBlock(", " {definitionModule: \"mirror\"}, 285, nrTypeParams);", " returnTypeBlock.guard = function(...args) {", " for (let i=0; i<args.length; i++) {", " if (! isGraceType(args[i])) return false;", " }", " return true;", " };", " returnTypeBlock.real = (...args) =>", " returnType.apply(this.theFunction, args);", " const applyMeth = (argcv, ...args) => {", " if (returnTypeBlock.guard.apply(returnTypeBlock, args))", " return returnTypeBlock.real.apply(this.theFunction, args);", " for (let i=0; i<args.length; i++) {", " if (! isGraceType(args[i])) {", " raiseException(RequestErrorObject,", " \"argument \" + (i+1) + \" to block (from methodMirror.returnType) is not a type.\");", " }", " }", " };", " applyMeth.methodName = \"apply(\" + nrTypeParams + \")\";", " applyMeth.paramCounts = [nrTypeParams];", " applyMeth.paramNames = this.theFunction.typeParamNames;", " applyMeth.definitionLine = this.theFunction.definitionLine;", " applyMeth.definitionModule = this.theFunction.definitionModule;", " returnTypeBlock.methods[applyMeth.methodName] = applyMeth;", " return returnTypeBlock;", " }", " if (returnType) {", " return returnType;", " } else {", " return type_Unknown;", " }", " ›", " }", "", " method typeParamNames {", " native \"js\" code ‹", " const jsNames = this.theFunction.typeParamNames", " if (jsNames) {", " return new GraceSequence(jsNames.map(s => new GraceString(s)));", " }", " return new GraceSequence([]);", " ›", " }", "", " method requestWithArgs(argList) {", " native \"js\" code ‹", " var paramcv = this.theFunction.paramCounts || [0];", " var np = (this.theFunction.paramNames) ?", " this.theFunction.paramNames.length : 0;", " var ntp = (this.theFunction.typeParamNames) ?", " this.theFunction.typeParamNames.length : 0;", " var providedLen = request(var_argList, \"size\", [0])._value;", " if ((providedLen !== np) && (providedLen != (np + ntp))) {", " const tParamPart = (ntp > 0) ? (\" and \" + ntp + \" type arguments\") : \"\";", " throw new GraceExceptionPacket(RequestErrorObject,", " new GraceString(\"method '\" + this.canonicalName + \"' requires \" +", " np + \" arguments\" + tParamPart +", " \", but was given \" + providedLen + \".\"));", " }", " const requestArgs = [this.data.subject, this.numericName, paramcv];", " const argsIter = request(var_argList, \"iterator\", [0]);", " while (Grace_isTrue(request(argsIter, \"hasNext\", [0]))) {", " const arg = request(argsIter, \"next\", [0]);", " requestArgs.push(arg);", " }", " return selfRequest.apply(null, requestArgs);", " ›", " }", "", " method hash {", " def subjectHash = native \"js\" code ‹", " result = selfRequest(this.data.subject, \"myIdentityHash\");", " ›", " intrinsic.hashCombine(MMhash,", " intrinsic.hashCombine(name.hash, subjectHash));", " }", "", " method == (other) {", " native \"js\" code ‹", " if (this.classUid !== var_other.classUid) {", " return GraceFalse; // return false if other is not a methodMirror", " }", " if (this.data.subject !== var_other.data.subject) {", " return GraceFalse; // return false if we don't have the same subject", " }", " if (this.numericName !== var_other.numericName) {", " return GraceFalse; // return false if not the same method", " }", " return GraceTrue;", " ›", " }", "}", "", "method loadModule(moduleName) {", " // loads moduleName dynamically", "", " native \"js\" code ‹return loadDynamicModule(safeJsString(var_moduleName));›", "}", "", "method initialModuleName {", " // the name of the \"main\" module being run from the command line or ide", "", " native \"js\" code ‹return new GraceString(minigrace.initialModuleName);›", "}", "", "method numberOfParameters(numericName) → Number {", " def parts = numericName.split \"(\"", " var result := 0", " (2..parts.size).do { i →", " def part_split = parts.at(i).split \")\"", " def n = part_split.first.asNumber", " if (n.isNaN) then {", " intrinsic.constants.ProgrammingError.raise", " \"ill-formed numeric method name {numericName}\"", " } else {", " result := result + n", " }", " }", " result", "}", "", "method isTheSame(left, right) → Boolean {", " def leftMirror = reflect(left)", " leftMirror.request \"isMe(_)\" withArgs [right]", "}" ]; } function gracecode_mirror() { importedModules["mirror"] = this; const var_$module = this; this.definitionModule = "mirror"; this.definitionLine = 1; setLineNumber(1); // compilenode dialect // Dialect "none" const var_$dialect = new GraceModule("none"); this.outer = var_$dialect; setLineNumber(2); // compilenode import // Import of "intrinsic" as intrinsic if (typeof gracecode_intrinsic == "undefined") throw new GraceExceptionPacket(EnvironmentExceptionObject, new GraceString("could not find module intrinsic")); var var_intrinsic = do_import("intrinsic", gracecode_intrinsic); var func0 = function(argcv) { // accessor method intrinsic, line 2 const numArgs = arguments.length - 1; if (numArgs > 0) raiseTypeArgError("intrinsic", 0, numArgs - 0); return var_intrinsic; }; // end of method intrinsic this.methods["intrinsic"] = func0; func0.methodName = "intrinsic"; func0.paramCounts = [0]; func0.paramNames = []; func0.definitionLine = 2; func0.definitionModule = "mirror"; func0.debug = "import"; func0.confidential = true; setLineNumber(3); // compilenode import // Import of "basicTypesBundle" as basicTypesBundle if (typeof gracecode_basicTypesBundle == "undefined") throw new GraceExceptionPacket(EnvironmentExceptionObject, new GraceString("could not find module basicTypesBundle")); var var_basicTypesBundle = do_import("basicTypesBundle", gracecode_basicTypesBundle); var func1 = function(argcv) { // accessor method basicTypesBundle, line 3 const numArgs = arguments.length - 1; if (numArgs > 0) raiseTypeArgError("basicTypesBundle", 0, numArgs - 0); return var_basicTypesBundle; }; // end of method basicTypesBundle this.methods["basicTypesBundle"] = func1; func1.methodName = "basicTypesBundle"; func1.paramCounts = [0]; func1.paramNames = []; func1.definitionLine = 3; func1.definitionModule = "mirror"; func1.debug = "import"; func1.confidential = true; setLineNumber(4); // compilenode import // Import of "equalityBundle" as equalityBundle if (typeof gracecode_equalityBundle == "undefined") throw new GraceExceptionPacket(EnvironmentExceptionObject, new GraceString("could not find module equalityBundle")); var var_equalityBundle = do_import("equalityBundle", gracecode_equalityBundle); var func2 = function(argcv) { // accessor method equalityBundle, line 4 const numArgs = arguments.length - 1; if (numArgs > 0) raiseTypeArgError("equalityBundle", 0, numArgs - 0); return var_equalityBundle; }; // end of method equalityBundle this.methods["equalityBundle"] = func2; func2.methodName = "equalityBundle"; func2.paramCounts = [0]; func2.paramNames = []; func2.definitionLine = 4; func2.definitionModule = "mirror"; func2.debug = "import"; func2.confidential = true; this.closureKeys = this.closureKeys || []; this.closureKeys.push("outer_mirror_1"); this.outer_mirror_1 = var_$dialect; setLineNumber(6); // reuse call var initFun3 = request(var_intrinsic, "annotations$build(3)", [null], this, [], []); // compileReuseCall setLineNumber(7); // reuse call var initFun4 = request(var_basicTypesBundle, "open$build(3)", [null], this, [], []); // compileReuseCall setLineNumber(8); // reuse call var initFun5 = request(var_equalityBundle, "open$build(3)", [null], this, [], []); // compileReuseCall setLineNumber(10); // compilenode typedec // Type decl Mirror var func7 = function(argcv) { // method Mirror, line 1 var returnTarget = invocationCount; invocationCount++; setLineNumber(1); // compilenode string var string9 = new GraceString("Mirror"); // call case 4: other requests setLineNumber(10); // compilenode interfaceliteral // interface literal var iface11 = new GraceInterface("\u2039anon\u203a"); sig12 = () => { setLineNumber(11); // compilenode member var call13 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("methods", [], [], [], call13); } sig14 = () => { setLineNumber(12); // compilenode member var call15 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("methodNames", [], [], [], call15); } sig16 = () => { setLineNumber(13); // compilenode member var call17 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("confidentialMethodNames", [], [], [], call17); } sig18 = () => { setLineNumber(14); // compilenode member var call19 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("allMethodNames", [], [], [], call19); } sig20 = () => { setLineNumber(15); // compilenode member var call21 = selfRequest(var_$module, "String", [0]); var call22 = selfRequest(var_$module, "MethodMirror", [0]); return new GraceSignature("onMethod(1)", ["nm"], [], [call21], call22); } sig23 = () => { setLineNumber(16); // compilenode member var call24 = selfRequest(var_$module, "String", [0]); var call25 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("request(1)withArgs(1)", ["nm", "args"], [], [call24, call25], type_Unknown); } sig26 = () => { setLineNumber(17); // compilenode member var call27 = selfRequest(var_$module, "String", [0]); return new GraceSignature("ilk", [], [], [], call27); } sig28 = () => { setLineNumber(18); // compilenode member var call29 = selfRequest(var_$module, "String", [0]); return new GraceSignature("definitionModule", [], [], [], call29); } sig30 = () => { setLineNumber(19); // compilenode member var call31 = selfRequest(var_$module, "String", [0]); return new GraceSignature("definitionLine", [], [], [], call31); } sig32 = () => { setLineNumber(20); // compilenode member var call33 = selfRequest(var_$module, "Object", [0]); return new GraceSignature("subject", [], [], [], call33); } sig34 = () => { setLineNumber(21); // compilenode member var call35 = selfRequest(var_$module, "Function3", [0]); var call36 = selfRequest(var_$module, "Done", [0]); return new GraceSignature("whenNoMethodDo(1)", ["action"], [], [call35], call36); } iface11.typeMethods = { "methods": sig12 , "methodNames": sig14 , "confidentialMethodNames": sig16 , "allMethodNames": sig18 , "onMethod(1)": sig20 , "request(1)withArgs(1)": sig23 , "ilk": sig26 , "definitionModule": sig28 , "definitionLine": sig30 , "subject": sig32 , "whenNoMethodDo(1)": sig34 }; // call case 4: other requests setLineNumber(10); // compilenode member var call37 = selfRequest(var_$module, "EqualityObject", [0]); var term10 = request(call37, "&(1)", [1], iface11); var call8 = selfRequest(term10, "setTypeName(1)", [1], string9); return call8; }; // end of method Mirror function memofunc7(argcv) { if (! this.data["memo$Mirror"]) // parameterless memo function this.data["memo$Mirror"] = func7.call(this, argcv); return this.data["memo$Mirror"]; }; this.methods["Mirror"] = memofunc7; memofunc7.methodName = "Mirror"; memofunc7.paramCounts = [0]; memofunc7.paramNames = []; memofunc7.definitionLine = 1; memofunc7.definitionModule = "mirror"; func7.methodName = "Mirror"; func7.paramCounts = [0]; func7.paramNames = []; func7.definitionLine = 1; func7.definitionModule = "mirror"; setLineNumber(26); // compilenode typedec // Type decl MethodMirror var func39 = function(argcv) { // method MethodMirror, line 1 var returnTarget = invocationCount; invocationCount++; setLineNumber(1); // compilenode string var string41 = new GraceString("MethodMirror"); // call case 4: other requests setLineNumber(26); // compilenode interfaceliteral // interface literal var iface43 = new GraceInterface("\u2039anon\u203a"); sig44 = () => { setLineNumber(27); // compilenode member var call45 = selfRequest(var_$module, "String", [0]); return new GraceSignature("name", [], [], [], call45); } sig46 = () => { setLineNumber(28); // compilenode member var call47 = selfRequest(var_$module, "Number", [0]); return new GraceSignature("numberOfParams", [], [], [], call47); } sig48 = () => { setLineNumber(29); // compilenode member var call49 = selfRequest(var_$module, "Number", [0]); return new GraceSignature("numberOfTypeParams", [], [], [], call49); } sig50 = () => { setLineNumber(30); // compilenode member var call51 = selfRequest(var_$module, "Number", [0]); return new GraceSignature("partCount", [], [], [], call51); } sig52 = () => { setLineNumber(31); // compilenode member var call53 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("paramCounts", [], [], [], call53); } sig54 = () => { setLineNumber(32); // compilenode member var call55 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("paramNames", [], [], [], call55); } sig56 = () => { setLineNumber(33); // compilenode member var call57 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("paramTypes", [], [], [], call57); } sig58 = () => { setLineNumber(34); // compilenode member var call59 = selfRequest(var_$module, "Type", [0]); return new GraceSignature("returnType", [], [], [], call59); } sig60 = () => { setLineNumber(35); // compilenode member var call61 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("typeParamNames", [], [], [], call61); } sig62 = () => { setLineNumber(36); // compilenode member var call63 = selfRequest(var_$module, "Sequence", [0]); return new GraceSignature("requestWithArgs(1)", ["args"], [], [call63], type_Unknown); } sig64 = () => { setLineNumber(38); // compilenode member var call65 = selfRequest(var_$module, "Object", [0]); return new GraceSignature("subject", [], [], [], call65); } sig66 = () => { setLineNumber(39); // compilenode member var call67 = selfRequest(var_$module, "Boolean", [0]); return new GraceSignature("isConfidential", [], [], [], call67); } sig68 = () => { setLineNumber(40); // compilenode member var call69 = selfRequest(var_$module, "Boolean", [0]); return new GraceSignature("isPublic", [], [], [], call69); } iface43.typeMethods = { "name": sig44 , "numberOfParams": sig46 , "numberOfTypeParams": sig48 , "partCount": sig50 , "paramCounts": sig52 , "paramNames": sig54 , "paramTypes": sig56 , "returnType": sig58 , "typeParamNames": sig60 , "requestWithArgs(1)": sig62 , "subject": sig64 , "isConfidential": sig66 , "isPublic": sig68 }; // call case 4: other requests setLineNumber(26); // compilenode member var call70 = selfRequest(var_$module, "EqualityObject", [0]); var term42 = request(call70, "&(1)", [1], iface43); var call40 = selfRequest(term42, "setTypeName(1)", [1], string41); return call40; }; // end of method MethodMirror function memofunc39(argcv) { if (! this.data["memo$MethodMirror"]) // parameterless memo function this.data["memo$MethodMirror"] = func39.call(this, argcv); return this.data["memo$MethodMirror"]; }; this.methods["MethodMirror"] = memofunc39; memofunc39.methodName = "MethodMirror"; memofunc39.paramCounts = [0]; memofunc39.paramNames = []; memofunc39.definitionLine = 1; memofunc39.definitionModule = "mirror"; func39.methodName = "MethodMirror"; func39.paramCounts = [0]; func39.paramNames = []; func39.definitionLine = 1; func39.definitionModule = "mirror"; var func71 = function(argcv, var_subj) { // method reflect(_), line 47 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("reflect(_)", 0, numArgs - 1); } var ouc = emptyGraceObject("reflect(_)", "mirror", 47); var ouc_init = this.methods["reflect(1)$build(3)"].call(this, null, var_subj, ouc, [], []); ouc_init.call(ouc); return ouc; }; // end of method reflect(_) this.methods["reflect(1)"] = func71; func71.methodName = "reflect(1)"; func71.paramCounts = [1]; func71.paramNames = ["subj"]; func71.definitionLine = 47; func71.definitionModule = "mirror"; var func72 = function(argcv, var_subj, inheritingObject, aliases, exclusions) { // method reflect(_)$build(_,_,_), line 47 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 4; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("reflect(_)", 0, numArgs - 1); } var obj73_build = function(ignore, var_subj, outerObj, aliases, exclusions) { this.closureKeys = this.closureKeys || []; this.closureKeys.push("outer_mirror_47"); this.outer_mirror_47 = outerObj; const inheritedExclusions = { }; for (var eix = 0, eLen = exclusions.length; eix < eLen; eix ++) { const exMeth = exclusions[eix]; inheritedExclusions[exMeth] = this.methods[exMeth]; }; setLineNumber(49); // reuse call var initFun74 = selfRequest(var_$module, "equality$build(3)", [null], this, [], []); // compileReuseCall this.data.subject = undefined; var reader75_subject = function() { // reader method subject if (this.data.subject === undefined) raiseUninitializedVariable("subject"); return this.data.subject; }; reader75_subject.isDef = true; this.methods["subject"] = reader75_subject; var func76 = function(argcv) { // method asString, line 51 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("asString", 0, numArgs - 0); } setLineNumber(51); // compilenode string // call case 4: other requests var call79 = selfRequest(this, "subject", [0]); // call case 4: other requests var string80 = new GraceString("a mirror on "); var concat78 = request(string80, "++(1)", [1], call79); var concat77 = request(concat78, "++(1)", [1], GraceEmptyString); return concat77; }; // end of method asString this.methods["asString"] = func76; func76.methodName = "asString"; func76.paramCounts = [0]; func76.paramNames = []; func76.definitionLine = 51; func76.definitionModule = "mirror"; var func81 = function(argcv) { // method methods, line 52 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("methods", 0, numArgs - 0); } setLineNumber(53); // compilenode call var result = GraceDone; // start native code from line 53 var meths = []; var current = this.data.subject; for (var k in current.methods) { if (! k.includes("$") && current.methods.hasOwnProperty(k)) { meths.push(request(var_thisModule, "methodMirror(2)", 2, current, new GraceString(k))); } } return new GraceSequence(meths); // end native code insertion setLineNumber(52); // compilenode member var call83 = selfRequest(var_$module, "Sequence", [0]); setLineNumber(53); // typecheck assertTypeOrMsg(result, call83, "result of method methods", "Sequence"); return result; }; // end of method methods setLineNumber(52); // compilenode member var call84 = selfRequest(var_$module, "Sequence", [0]); func81.returnType = call84; this.methods["methods"] = func81; func81.methodName = "methods"; func81.paramCounts = [0]; func81.paramNames = []; func81.definitionLine = 52; func81.definitionModule = "mirror"; var func85 = function(argcv) { // method methodNames, line 65 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("methodNames", 0, numArgs - 0); } setLineNumber(68); // compilenode call var result = GraceDone; // start native code from line 68 var methNames = []; var current = this.data.subject; for (var k in current.methods) { if (! k.includes("$") && current.methods.hasOwnProperty(k) && ! current.methods[k].confidential) { methNames.push(canonicalMethodName(k)); } } return new GraceSequence(methNames.sort().map( nm => new GraceString(nm))); // end native code insertion return result; }; // end of method methodNames this.methods["methodNames"] = func85; func85.methodName = "methodNames"; func85.paramCounts = [0]; func85.paramNames = []; func85.definitionLine = 65; func85.definitionModule = "mirror"; var func87 = function(argcv) { // method confidentialMethodNames, line 81 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("confidentialMethodNames", 0, numArgs - 0); } setLineNumber(84); // compilenode call var result = GraceDone; // start native code from line 84 var methNames = []; var current = this.data.subject; for (var k in current.methods) { if (! k.includes("$") && current.methods.hasOwnProperty(k) && current.methods[k].confidential) { methNames.push(canonicalMethodName(k)); } } return new GraceSequence(methNames.sort().map( nm => new GraceString(nm))); // end native code insertion return result; }; // end of method confidentialMethodNames this.methods["confidentialMethodNames"] = func87; func87.methodName = "confidentialMethodNames"; func87.paramCounts = [0]; func87.paramNames = []; func87.definitionLine = 81; func87.definitionModule = "mirror"; var func89 = function(argcv) { // method allMethodNames, line 97 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("allMethodNames", 0, numArgs - 0); } setLineNumber(100); // compilenode call var result = GraceDone; // start native code from line 100 var methNames = []; var current = this.data.subject; for (var k in current.methods) { if (! k.includes("$") && current.methods.hasOwnProperty(k)) { methNames.push(canonicalMethodName(k)); } } return new GraceSequence(methNames.sort().map( nm => new GraceString(nm))); // end native code insertion return result; }; // end of method allMethodNames this.methods["allMethodNames"] = func89; func89.methodName = "allMethodNames"; func89.paramCounts = [0]; func89.paramNames = []; func89.definitionLine = 97; func89.definitionModule = "mirror"; var func91 = function(argcv, var_nm) { // method onMethod(_), line 112 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("onMethod(_)", 0, numArgs - 1); } setLineNumber(114); // compilenode member var call93 = selfRequest(this, "subject", [0]); var call92 = selfRequest(var_$module, "methodMirror(2)", [2], call93, var_nm); return call92; }; // end of method onMethod(_) this.methods["onMethod(1)"] = func91; func91.methodName = "onMethod(1)"; func91.paramCounts = [1]; func91.paramNames = ["nm"]; func91.definitionLine = 112; func91.definitionModule = "mirror"; var func94 = function(argcv, var_nm, var_args) { // method request(_)withArgs(_), line 117 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 2) && (numArgs !== 2)) { raiseTypeArgError("request(_)withArgs(_)", 0, numArgs - 2); } setLineNumber(117); // compilenode member var call95 = selfRequest(var_$module, "String", [0]); assertTypeOrMsg(var_nm, call95, "argument 1 in request of `request(_)withArgs(_)`", "String"); var call96 = selfRequest(var_$module, "Sequence", [0]); assertTypeOrMsg(var_args, call96, "argument 2 in request of `request(_)withArgs(_)`", "Sequence"); setLineNumber(118); // compilenode member var call98 = selfRequest(this, "subject", [0]); var call97 = selfRequest(var_$module, "methodMirror(2)", [2], call98, var_nm); var var_methodMirror = call97; setLineNumber(119); // compilenode call // call case 4: other requests if (var_methodMirror === undefined) raiseUninitializedVariable("methodMirror"); var call99 = request(var_methodMirror, "requestWithArgs(1)", [1], var_args); return call99; }; // end of method request(_)withArgs(_) setLineNumber(117); // compilenode member var call100 = selfRequest(var_$module, "String", [0]); var call101 = selfRequest(var_$module, "Sequence"