UNPKG

minigrace

Version:

A compiler for the Grace programming language

853 lines (852 loc) 218 kB
let gracecode_dialect_sourceFile = "/Users/black/Development/mg/gracelang/minigrace/modules/dialect.grace"; let gracecode_dialect_sha256 = "512b4b21e6149a45db3ffdd8d59f226e86759e15322d28bba9cea70b7fe1b23d"; let gracecode_dialect_minigraceRevision = "b57591d29fc5ee5270d114920bf671367b8c3ecb"; let gracecode_dialect_minigraceGeneration = "5171"; if (typeof gctCache !== "undefined") gctCache["dialect"] = "dialect:\nfreshScopes:\n $101 trait\n $102 trait\n $104\n $105\n $106\n $108 trait\n $109 trait\n $110 trait\n $111\n $112\n $113 trait\n $114 trait\n $115 trait\n $116\n $117 trait\n $118\n $120 trait\n $121 trait\nmethodTypes:$103:\n RequestOf(methodName:String) \u2192 Pattern\n aPatternMatchingNode(kind:String) \u2192 Pattern\n check(module:Unknown) \u2192 Done\n fail(message:Unknown)at(rng:ast.Range) \u2192 Unknown\n fail(msg:Unknown)when(pat:Unknown) \u2192 Done\n rule(block:Unknown) \u2192 Done\nmethodTypes:$105:\n asString \u2192 String\n at(key:Unknown)put(value:Unknown) \u2192 Done\n atKey(key:Unknown)do(block:Unknown) \u2192 Done\n containsKey(key:Unknown) \u2192 Boolean\n isEmpty \u2192 Boolean\n keys \u2192 List\n size \u2192 Number\n values \u2192 List\nmethodTypes:$106:\n at(name:String)put(value:Unknown) \u2192 Done\n find(name:String)butIfMissing(bl:Unknown) \u2192 Unknown\nmethodTypes:$107:\n asString \u2192 String\n size \u2192 Number\nmethodTypes:$108:\n matches(obj:Object) \u2192 Boolean\nmethodTypes:$109:\n matches(obj:Object) \u2192 Boolean\nmodules:\n ast\n errormessages\n standardBundle\npath:\n /Users/black/Development/mg/gracelang/minigrace/modules/dialect.grace\nscope:$101:\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 isMe(1) Boolean (go) $scope_boolean\n isType Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n prefix\u00ac Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\nscope:$102:\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:$103:\n AndPattern(2) Unknown (mth) $110\n AndType(2) Unknown (mth) $111\n ArrayLiteral Unknown (def) $scope_done public\n AstNode type\n BarType(2) Unknown (mth) $112\n BasePattern Unknown (mth) $101\n BaseType Unknown (mth) $113\n Bind Unknown (def) $scope_done public\n Binding type\n BlockLiteral Unknown (def) $scope_done public\n Boolean type\n BoundsError Unknown (mth) $scope_done\n CheckerFailure Unknown (def) $scope_done public\n Class Unknown (def) $scope_done public\n Collection type\n CollectionFactory type\n ConcurrentModification Unknown (mth) $scope_done\n Def Unknown (def) $scope_done public\n Dialect Unknown (def) $scope_done public\n DialectError Unknown (def) $scope_done public\n Dictionary type\n Done type\n Enumerable type\n EnvironmentException Unknown (mth) $scope_done\n EqualityObject type\n Exception Unknown (mth) $scope_done\n ExceptionKind type\n ExceptionPacket type\n ForRequest Unknown (def) $scope_done public\n Function0 type\n Function1 type\n Function2 type\n Function3 type\n Generic Unknown (def) $scope_done public\n Identifier Unknown (def) $scope_done public\n If Unknown (def) $scope_done public\n Import Unknown (def) $scope_done public\n Inherit Unknown (def) $scope_done public\n Interface type\n Iterator type\n IteratorExhausted Unknown (mth) $scope_done\n List type\n MatchCase Unknown (def) $scope_done public\n Member Unknown (def) $scope_done public\n Method Unknown (def) $scope_done public\n MethodSignature Unknown (def) $scope_done public\n NoSuchMethod Unknown (mth) $scope_done\n NoSuchObject Unknown (mth) $scope_done\n None type\n NotPattern(1) Unknown (mth) $114\n Number type\n NumberLiteral Unknown (def) $scope_done public\n Object type\n ObjectLiteral Unknown (def) $scope_done public\n OctetsLiteral Unknown (def) $scope_done public\n Operator Unknown (def) $scope_done public\n OrPattern(2) Unknown (mth) $115\n Outer Unknown (def) $scope_done public\n Parameter Unknown (def) $scope_done public\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 ProgrammingError Unknown (mth) $scope_done\n Request Unknown (def) $scope_done public\n RequestError Unknown (mth) $scope_done\n RequestOf(1) Pattern (mth) $109\n ResourceException Unknown (mth) $scope_done\n Return Unknown (def) $scope_done public\n RuntimeError Unknown (mth) $scope_done\n SelfType type\n Sequence type\n Sequenceable type\n Set type\n Signature type\n Sink type\n String type\n StringLiteral Unknown (def) $scope_done public\n SubobjectResponsibility Unknown (mth) $scope_done\n TryCatch Unknown (def) $scope_done public\n Type type\n TypeAnnotation Unknown (def) $scope_done public\n TypeDeclaration Unknown (def) $scope_done public\n TypeError Unknown (mth) $scope_done\n TypeExclusion(2) Unknown (mth) $116\n TypeIntersection(2) Unknown (mth) $scope_done\n TypeLiteral Unknown (def) $scope_done public\n TypeVariant(2) Unknown (mth) $scope_done\n UnimplementedMethod Unknown (mth) $scope_done\n UninitializedVariable Unknown (mth) $scope_done\n Var Unknown (def) $scope_done public\n WhileRequest Unknown (def) $scope_done public\n aMutableMap Unknown (mth) $105\n aPatternMatchingNode(1) Pattern (mth) $108\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) $scope_done\n check(1) Done (mth) $scope_done\n checkTypes(1) Unknown (mth) $scope_done\n collection Unknown (mth) $scope_done\n confidential Unknown (mth) $scope_done\n createSuggestion Unknown (mth) $scope_done\n dictionary Unknown (mth) $scope_done\n dictionary(1) Unknown (mth) $scope_done\n do(1)while(1) Unknown (mth) $scope_done\n done Unknown (mth) $scope_done\n entryFrom(1)to(1) Unknown (mth) $104 confidential\n enumerable Unknown (mth) $scope_done\n equality Unknown (mth) $117\n fail(1) Unknown (mth) $scope_done\n fail(1)at(1) Unknown (mth) $scope_done\n fail(1)from(1)to(1) Unknown (mth) $scope_done\n fail(1)from(1)to(1)suggest(1) Unknown (mth) $scope_done\n fail(1)when(1) Done (mth) $scope_done\n for(1)and(1)do(1) Unknown (mth) $scope_done\n for(1)do(1) Unknown (mth) $scope_done\n forBody(1) Unknown (mth) $scope_done\n forCollection(1) Unknown (mth) $scope_done\n hashCombine(2) Unknown (mth) $scope_done\n identityEquality Unknown (mth) $102\n indexable Unknown (mth) $scope_done\n infinity Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n list Unknown (mth) $scope_done\n list(1) Unknown (mth) $scope_done\n max(2) Unknown (mth) $scope_done\n min(2) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n override Unknown (mth) $scope_done\n pi Unknown (mth) $scope_done\n point2Dx(1)y(1) Unknown (mth) $118\n primitiveArray Unknown (mth) $119\n public Unknown (mth) $scope_done\n range Unknown (mth) $scope_done\n readable Unknown (mth) $scope_done\n repeat(1)times(1) Unknown (mth) $scope_done\n required Unknown (mth) $scope_done\n rule(1) Done (mth) $scope_done\n runRules(1) Unknown (mth) $scope_done\n scope Unknown (def) $107 public\n sequence Unknown (mth) $scope_done\n sequence(1) Unknown (mth) $scope_done\n set Unknown (mth) $scope_done\n set(1) Unknown (mth) $scope_done\n singleton Unknown (mth) $120\n singleton(1) Unknown (mth) $121\n stackOfKind(1) Unknown (mth) $106 confidential\n typeOf(1) Unknown (mth) $scope_done\n valueOf(1) Unknown (mth) $scope_done\n when(1)error(1) Unknown (mth) $scope_done\n while(1)do(1) Unknown (mth) $scope_done\n whileBody(1) Unknown (mth) $scope_done\n whileCond(1) Unknown (mth) $scope_done\n writable Unknown (mth) $scope_done\n \u03c0 Unknown (mth) $scope_done\nscope:$104:\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n basicAsString String (go) $scope_string\n isMe(1) Boolean (go) $scope_boolean\n key Unknown (def) $scopeEmpty public\n myIdentityHash Number (go) $scope_number\n value Unknown (var) $scopeEmpty public\n value:=(1) Unknown (var) $scopeEmpty public\nscope:$105:\n asDebugString String (go) $scope_string\n asString String (mth) $scope_done override\n at(1) Unknown (mth) $scope_done\n at(1)put(1) Done (mth) $scope_done\n atKey(1)do(1) Done (mth) $scope_done\n atKey(1)do(1)else(1) Unknown (mth) $scope_done\n basicAsString String (go) $scope_string\n containsKey(1) Boolean (mth) $scope_done\n entries Unknown (def) $scope_done\n isEmpty Boolean (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n keys List (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n size Number (mth) $scope_done\n values List (mth) $scope_done\nscope:$106:\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n at(1)put(1) Done (mth) $scope_done\n basicAsString String (go) $scope_string\n find(1)butIfMissing(1) Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n myIdentityHash Number (go) $scope_number\n stack Unknown (def) $scope_done public\nscope:$107:\n asDebugString String (go) $scope_string\n asString String (mth) $scope_done override\n basicAsString String (go) $scope_string\n enter(1) Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n methods Unknown (def) $scope_done public\n myIdentityHash Number (go) $scope_number\n size Number (mth) $scope_done\n types Unknown (def) $scope_done public\n variables Unknown (def) $scope_done public\nscope:$108:\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 isMe(1) Boolean (go) $scope_boolean\n isType Unknown (mth) $scope_done\n matches(1) Boolean (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n prefix\u00ac Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\nscope:$109:\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 isMe(1) Boolean (go) $scope_boolean\n isType Unknown (mth) $scope_done\n matches(1) Boolean (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n prefix\u00ac Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\nscope:$110:\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 isMe(1) Boolean (go) $scope_boolean\n isType Unknown (mth) $scope_done\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n prefix\u00ac Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\nscope:$111:\n &(1) Unknown (mth) $scope_done\n -(1) Unknown (mth) $scope_done\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 interfaces Unknown (def) $scope_done\n isInterface Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n isNone Unknown (mth) $scope_done\n isType Unknown (mth) $scope_done\n matchHook(1) Unknown (mth) $scope_done\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n name Unknown (var) $scopeEmpty\n name:=(1) Unknown (var) $scopeEmpty\n prefix== Unknown (mth) $scope_done\n prefix\u00ac Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n setName(1) Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n typeParameterNames Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$112:\n &(1) Unknown (mth) $scope_done\n -(1) Unknown (mth) $scope_done\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 interfaces Unknown (mth) $scope_done\n isInterface Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n isNone Unknown (mth) $scope_done\n isType Unknown (mth) $scope_done\n matchHook(1) Unknown (mth) $scope_done\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n name Unknown (var) $scopeEmpty\n name:=(1) Unknown (var) $scopeEmpty\n prefix== Unknown (mth) $scope_done\n prefix\u00ac Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n setName(1) Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n typeParameterNames Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$113:\n &(1) Unknown (mth) $scope_done\n -(1) Unknown (mth) $scope_done\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 interfaces Unknown (req) $scopeUniv\n isInterface Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n isNone Unknown (mth) $scope_done\n isType Unknown (mth) $scope_done\n matchHook(1) Unknown (req) $scopeUniv\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n name Unknown (req) $scopeUniv\n name:=(1) Unknown (req) $scopeUniv\n prefix== Unknown (mth) $scope_done\n prefix\u00ac Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n setName(1) Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n typeParameterNames Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$114:\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 isMe(1) Boolean (go) $scope_boolean\n isType Unknown (mth) $scope_done\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n prefix\u00ac Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\nscope:$115:\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 isMe(1) Boolean (go) $scope_boolean\n isType Unknown (mth) $scope_done\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n prefix\u00ac Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\nscope:$116:\n &(1) Unknown (mth) $scope_done\n -(1) Unknown (mth) $scope_done\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 interfaces Unknown (mth) $scope_done\n isInterface Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n isNone Unknown (mth) $scope_done\n isType Unknown (mth) $scope_done\n matchHook(1) Unknown (req) $scopeUniv\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n name Unknown (var) $scopeEmpty\n name:=(1) Unknown (var) $scopeEmpty\n prefix== Unknown (mth) $scope_done\n prefix\u00ac Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n setName(1) Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n typeParameterNames Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$117:\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:$118:\n *(1) Unknown (mth) $scope_done\n +(1) Unknown (mth) $scope_done\n -(1) Unknown (mth) $scope_done\n /(1) Unknown (mth) $scope_done\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 distanceTo(1) Unknown (mth) $scope_done\n dot(1) Number (mth) $scope_done\n hash Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n length Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n norm Unknown (mth) $scope_done\n prefix- Unknown (mth) $scope_done\n prefix== Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n reverseDivideNumber(1) Unknown (mth) $scope_done\n reverseMinusNumber(1) Unknown (mth) $scope_done\n reversePlusNumber(1) Unknown (mth) $scope_done\n reverseTimesNumber(1) Unknown (mth) $scope_done\n x Unknown (def) $scopeEmpty\n y Unknown (def) $scopeEmpty\n \u2260(1) Unknown (mth) $scope_done\n \u22c5(1) Number (mth) $scope_done\nscope:$119:\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n basicAsString String (go) $scope_string\n isMe(1) Boolean (go) $scope_boolean\n myIdentityHash Number (go) $scope_number\n new(1) Unknown (mth) $scope_done\nscope:$120:\n &(1) Unknown (mth) $scope_done\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 isType Unknown (mth) $scope_done\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n prefix== Unknown (mth) $scope_done\n prefix\u00ac Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nscope:$121:\n &(1) Unknown (mth) $scope_done\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 isMe(1) Boolean (go) $scope_boolean\n isType Unknown (mth) $scope_done\n matches(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n prefix== Unknown (mth) $scope_done\n prefix\u00ac Unknown (mth) $scope_done\n prefix\u2260 Unknown (mth) $scope_done\n setTypeName(1) Unknown (mth) $scope_done\n |(1) Unknown (mth) $scope_done\n \u2260(1) Unknown (mth) $scope_done\nself:\n $103\ntypedec:$103.AstNode:\n type AstNode = interface {\n kind \u2192 String}\ntypes:\n $103.AstNode\n"; if (typeof originalSourceLines !== "undefined") { originalSourceLines["dialect"] = [ "dialect \"none\"", "import \"standardBundle\" as sb", "import \"errormessages\" as errormessages", "import \"ast\" as ast", "", "use sb.open", "", "// Checker error", "", "def CheckerFailure is public = self.Exception.refine \"CheckerFailure\"", "def DialectError is public = self.Exception.refine \"DialectError\"", "", "// Helper Map", "", "class entryFrom(key') to(value') is confidential {", " def key is public = key'", " var value is public := value'", "}", "", "class aMutableMap {", "", " def entries = list []", "", " method isEmpty -> Boolean { size == 0 }", "", " method size -> Number { entries.size }", "", " method at(key) {", " atKey(key) do { value -> return value }", "", " NoSuchObject.raise \"no key {key} in aMutableMap\"", " }", "", " method at(key) put(value) -> Done {", " if (value.asString == \"done\") then {", " outer.ProgrammingError.raise \"mutableMap: attempting to put ‹done› at key {key}\"", " }", " entries.do { entry ->", " if(entry.key == key) then {", " entry.value := value", " return done", " }", " }", "", " entries.push(entryFrom(key) to(value))", " }", "", " method keys -> List {", " def keys' = list []", "", " entries.do { entry ->", " keys'.push(entry.key)", " }", "", " return keys'", " }", "", " method values -> List {", " def values' = list []", "", " entries.do { entry ->", " values'.push(entry.value)", " }", "", " return values'", " }", "", " method containsKey(key) -> Boolean {", " atKey(key) do { _ -> return true }", "", " return false", " }", "", " method atKey(key) do(block) -> Done {", " atKey(key) do(block) else {}", " return", " }", "", " method atKey(key) do(block) else(block') {", " entries.do { entry ->", " if(entry.key == key) then {", " return block.apply(entry.value)", " }", " }", "", " return block'.apply", " }", "", " method asString -> String is override {", " var out := \"\\{\"", " entries.do { entry ->", " out := \"{out} {entry.key} => {entry.value}\"", " } separatedBy {", " out := \"{out},\"", " }", " return \"{out} \\}\"", " }", "", "}", "", "", "", "// Rules", "", "// The defined type rules.", "def rules = list []", "", "// The cached type assignments.", "def cache = aMutableMap", "", "// Creates a new type rule.", "method rule(block) -> Done {", " rules.push(block)", "}", "", "", "var currentLine := 0 // Will be updated with each node examined", "", "method fail (message) {", " // short fail-with-message; gives source line only", "", " DialectError.raise (message) with (ast.line(currentLine) column 0)", "}", "", "method fail (message) at (rng:ast.Range) {", " // fail, using the source-file range rng for the error message", " // Note that, since ast.AstNode conforms to ast.Range, the second", " // argument can be an AstNode.", "", " DialectError.raise (message) with (rng)", "}", "method fail (message) from (startCol) to (endCol) {", " // fail, with a source range", "", " def rng = ast.start (ast.line(currentLine) column(startCol))", " end (ast.line(currentLine) column(endCol))", " DialectError.raise (message) with (rng)", "}", "", "method fail(message) from (startCol) to (endCol) suggest (s) {", " // fail, with an object that contains a source range and a suggestion", "", " def o = object {", " inherit ast.start (ast.line(currentLine) column(startCol))", " end (ast.line(currentLine) column(endCol))", " def sugg is public = [s]", " }", " DialectError.raise (message) with (o)", "}", "", "method fail (msg) when (pat) -> Done {", " // adds a rule the the list of active rules. The rule will fail when", " // applied to a node x such that pat.match(x), and pat.apply(x) is true", "", " rule { x ->", " if (pat.matches(x) && {pat.apply(x)}) then {", " fail(msg)", " }", " }", "}", "", "method createSuggestion {", " errormessages.suggestion.new", "}", "", "method when(pat)error(msg) {", " // alternate syntax for fail (msg) when (pat)", "", " fail(msg)when(pat)", "}", "", "// Scope", "", "class stackOfKind(kind : String) is confidential {", " def stack is public = list [aMutableMap]", "", " method at(name : String) put(value) -> Done {", " stack.last.at(name) put(value)", " }", "", " method find(name : String) butIfMissing(bl) {", " var i := stack.size", " while { i > 0 } do {", " stack.at(i).atKey(name) do { value ->", " return value", " }", "", " i := i - 1", " }", "", " return bl.apply", " }", "", "}", "", "def scope is public = object {", " def variables is public = stackOfKind(\"variable\")", " def methods is public = stackOfKind(\"method\")", " def types is public = stackOfKind(\"type\")", "", " method size -> Number {", " variables.stack.size", " }", "", " method enter(bl) {", " variables.stack.push(aMutableMap)", " methods.stack.push(aMutableMap)", " types.stack.push(aMutableMap)", "", " def result = bl.apply", "", " variables.stack.pop", " methods.stack.pop", " types.stack.pop", "", " return result", " }", "", " method asString -> String is override {", " \"scope<{size}>\"", " }", "}", "", "method checkTypes(node) {", " node.accept(astVisitor)", "}", "", "method typeOf(node) {", " checkTypes(node)", " cache.atKey(node) do { value -> return value }", " DialectError.raise \"cannot type non-expression {node}\" with (node)", "}", "", "method runRules(node) {", " // apply all rules to node; returns the result of the last applicable rule.", " // if there are no applicable rules, returns false", " cache.atKey(node) do { value -> return value }", " currentLine := node.line", "", " var result := false", " rules.do { each ->", " if (each.matches(node)) then {", " result := each.apply(node)", " if (result.asString == \"done\") then {", " outer.ProgrammingError.raise", " \"rule.apply(node) has result 'done' when rule is {each} and node = {node}\"", " }", " cache.at(node) put(result)", " }", " }", " return result", "}", "", "", "// Type checker", "", "// Checks the defined rules on the given AST.", "method check(module) -> Done {", " // Runs the check on the module object.", " module.accept(astVisitor)", "}", "", "type AstNode = interface { kind -> String }", "", "class aPatternMatchingNode(kind:String) -> Pattern {", " use BasePattern", "", " method matches(obj:Object) -> Boolean {", " match(obj)", " case { node:AstNode -> kind == node.kind }", " else { false }", " }", "}", "", "def If is public = aPatternMatchingNode \"if\"", "def BlockLiteral is public = aPatternMatchingNode \"block\"", "def MatchCase is public = aPatternMatchingNode \"matchcase\"", "def TryCatch is public = aPatternMatchingNode \"trycatch\"", "def Outer is public = aPatternMatchingNode \"outer\"", "def MethodSignature is public = aPatternMatchingNode \"methodtype\"", "def TypeLiteral is public = aPatternMatchingNode \"typeliteral\"", "def TypeDeclaration is public = aPatternMatchingNode \"typedec\"", "def TypeAnnotation is public = aPatternMatchingNode \"dtype\"", "def Method is public = aPatternMatchingNode \"method\"", "def Parameter is public = aPatternMatchingNode \"parameter\"", "def Request is public = aPatternMatchingNode \"call\"", "def Class is public = aPatternMatchingNode \"class\"", "def ObjectLiteral is public = aPatternMatchingNode \"object\"", "def ArrayLiteral is public = aPatternMatchingNode \"array\"", "def Member is public = aPatternMatchingNode \"member\"", "def Generic is public = aPatternMatchingNode \"generic\"", "def Identifier is public = aPatternMatchingNode \"identifier\"", "def OctetsLiteral is public = aPatternMatchingNode \"octets\"", "def StringLiteral is public = aPatternMatchingNode \"string\"", "def NumberLiteral is public = aPatternMatchingNode \"num\"", "def Operator is public = aPatternMatchingNode \"op\"", "def Bind is public = aPatternMatchingNode \"bind\"", "def Def is public = aPatternMatchingNode \"defdec\"", "def Var is public = aPatternMatchingNode \"vardec\"", "def Import is public = aPatternMatchingNode \"import\"", "def Dialect is public = aPatternMatchingNode \"dialect\"", "def Return is public = aPatternMatchingNode \"return\"", "def Inherit is public = aPatternMatchingNode \"inherit\"", "", "// Special requests patterns.", "", "class RequestOf(methodName:String) -> Pattern {", "", " use BasePattern", "", " method matches(obj:Object) -> Boolean {", " match(obj)", " case { node:AstNode ->", " node.isCall && {node.canonicalName == methodName}", " } else {", " false", " }", " }", "}", "", "def WhileRequest is public = RequestOf \"while(_)do(_)\"", "def ForRequest is public = RequestOf \"for(_)do(_)\"", "", "method whileCond(node) {", " // answers the condition expression from node, which must be a", " // a callNode calling \"while(_)do(_)\"", " def sig = node.parts", " sig.first.args.first", "}", "", "method whileBody(node) {", " // answers the body expression from node, which must be a", " // a callNode calling \"while(_)do(_)\"", " def sig = node.parts", " sig.second.args.first", "}", "", "method forCollection(node) {", " // answers the collection expression from node, which must be a", " // a callNode calling \"for(_)do(_)\"", " def sig = node.parts", " sig.first.args.first", "}", "", "method forBody(node) {", " // answers the body expression from node, which must be a", " // a callNode calling \"for(_)do(_)\"", " def sig = node.parts", " sig.second.args.first", "}", "", "def astVisitor = object {", " inherit ast.baseVisitor", "", " method checkMatch(node) -> Boolean {", " runRules(node)", " return true", " }", "", " method visitIf(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitBlock(node) -> Boolean {", " runRules(node)", "", " node.params.do { param ->", " runRules(aParameter.fromNode(param))", " }", "", " node.body.do { stmt ->", " stmt.accept(self)", " }", "", " return false", " }", "", " method visitMatchCase(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitTryCatch(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitMethodType(node) -> Boolean {", " runRules(node)", "", " node.signatureParts.do { part ->", " part.params.do { param ->", " runRules(aParameter.fromNode(param))", " }", " }", "", " return false", " }", "", " method visitType(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitMethod(node) -> Boolean {", " runRules(node)", "", " node.signatureParts.do { part ->", " part.params.do { param ->", " runRules(aParameter.fromNode(param))", " }", " }", "", " node.body.do { stmt ->", " stmt.accept(self)", " }", "", " return false", " }", "", " method visitCall(node) -> Boolean {", " checkMatch(node)", "", " match(node.receiver)", " case { memb : Member ->", " memb.receiver.accept(self)", " } else { }", "", " node.parts.do { part ->", " part.args.do { arg ->", " arg.accept(self)", " }", " }", "", " return false", " }", "", " method visitObject(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitArray(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitMember(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitGeneric(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitIdentifier(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitOctets(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitString(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitNum(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitOp(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitBind(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitDefDec(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitVarDec(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitImport(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitReturn(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitInherits(node) -> Boolean {", " checkMatch(node)", " }", "", " method visitDialect(node) -> Boolean {", " checkMatch(node)", " }", "", "}", "", "def aTypeAnnotation is confidential = object {", " class fromNode(node) -> TypeAnnotation {", " use identityEquality", " def kind is public = \"dtype\"", " def value is public = node", " def line is public = node.line", " def linePos is public = node.linePos", " }", "}", "", "def aParameter is confidential = object {", " class fromNode(node) -> Parameter {", " use identityEquality", " def kind is public = \"parameter\"", " def value is public = node.value", " def dtype is public = node.dtype", " def line is public = node.line", " def linePos is public = node.linePos", " }", "}", "" ]; } function gracecode_dialect() { importedModules["dialect"] = this; const var_$module = this; this.definitionModule = "dialect"; 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 "standardBundle" as sb if (typeof gracecode_standardBundle == "undefined") throw new GraceExceptionPacket(EnvironmentExceptionObject, new GraceString("could not find module standardBundle")); var var_sb = do_import("standardBundle", gracecode_standardBundle); var func0 = function(argcv) { // accessor method sb, line 2 const numArgs = arguments.length - 1; if (numArgs > 0) raiseTypeArgError("sb", 0, numArgs - 0); return var_sb; }; // end of method sb this.methods["sb"] = func0; func0.methodName = "sb"; func0.paramCounts = [0]; func0.paramNames = []; func0.definitionLine = 2; func0.definitionModule = "dialect"; func0.debug = "import"; func0.confidential = true; setLineNumber(3); // compilenode import // Import of "errormessages" as errormessages if (typeof gracecode_errormessages == "undefined") throw new GraceExceptionPacket(EnvironmentExceptionObject, new GraceString("could not find module errormessages")); var var_errormessages = do_import("errormessages", gracecode_errormessages); var func1 = function(argcv) { // accessor method errormessages, line 3 const numArgs = arguments.length - 1; if (numArgs > 0) raiseTypeArgError("errormessages", 0, numArgs - 0); return var_errormessages; }; // end of method errormessages this.methods["errormessages"] = func1; func1.methodName = "errormessages"; func1.paramCounts = [0]; func1.paramNames = []; func1.definitionLine = 3; func1.definitionModule = "dialect"; func1.debug = "import"; func1.confidential = true; setLineNumber(4); // compilenode import // Import of "ast" as ast if (typeof gracecode_ast == "undefined") throw new GraceExceptionPacket(EnvironmentExceptionObject, new GraceString("could not find module ast")); var var_ast = do_import("ast", gracecode_ast); var func2 = function(argcv) { // accessor method ast, line 4 const numArgs = arguments.length - 1; if (numArgs > 0) raiseTypeArgError("ast", 0, numArgs - 0); return var_ast; }; // end of method ast this.methods["ast"] = func2; func2.methodName = "ast"; func2.paramCounts = [0]; func2.paramNames = []; func2.definitionLine = 4; func2.definitionModule = "dialect"; func2.debug = "import"; func2.confidential = true; this.closureKeys = this.closureKeys || []; this.closureKeys.push("outer_dialect_1"); this.outer_dialect_1 = var_$dialect; setLineNumber(6); // reuse call var initFun3 = request(var_sb, "open$build(3)", [null], this, [], []); // compileReuseCall var func4 = function(argcv, var_key__39__, var_value__39__) { // method entryFrom(_)to(_), line 15 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 2) && (numArgs !== 2)) { raiseTypeArgError("entryFrom(_)to(_)", 0, numArgs - 2); } var ouc = emptyGraceObject("entryFrom(_)to(_)", "dialect", 15); var ouc_init = this.methods["entryFrom(1)to(1)$build(3)"].call(this, null, var_key__39__, var_value__39__, ouc, [], []); ouc_init.call(ouc); return ouc; }; // end of method entryFrom(_)to(_) func4.confidential = true; this.methods["entryFrom(1)to(1)"] = func4; func4.methodName = "entryFrom(1)to(1)"; func4.paramCounts = [1, 1]; func4.paramNames = ["key'", "value'"]; func4.definitionLine = 15; func4.definitionModule = "dialect"; var func5 = function(argcv, var_key__39__, var_value__39__, inheritingObject, aliases, exclusions) { // method entryFrom(_)to(_)$build(_,_,_), line 15 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 4; if ((numArgs > 2) && (numArgs !== 2)) { raiseTypeArgError("entryFrom(_)to(_)", 0, numArgs - 2); } var obj6_build = function(ignore, var_key__39__, var_value__39__, outerObj, aliases, exclusions) { this.closureKeys = this.closureKeys || []; this.closureKeys.push("outer_dialect_15"); this.outer_dialect_15 = outerObj; const inheritedExclusions = { }; for (var eix = 0, eLen = exclusions.length; eix < eLen; eix ++) { const exMeth = exclusions[eix]; inheritedExclusions[exMeth] = this.methods[exMeth]; }; this.data.key = undefined; var reader7_key = function() { // reader method key if (this.data.key === undefined) raiseUninitializedVariable("key"); return this.data.key; }; reader7_key.isDef = true; this.methods["key"] = reader7_key; this.data.value = undefined; var reader8_value = function() { // reader method value if (this.data.value === undefined) raiseUninitializedVariable("value"); return this.data.value; }; reader8_value.isVar = true; this.methods["value"] = reader8_value; var writer9_value = function(argcv, n) { // writer method value:=(_) this.data.value = n; return GraceDone; }; this.methods["value:=(1)"] = writer9_value; this.mutable = true; const overridenByAliases = { }; for (let aix = 0, aLen = aliases.length; aix < aLen; aix ++) { const a = aliases[aix]; const newNm = a.newName; const oldNm = a.oldName; overridenByAliases[newNm] = this.methods[newNm]; const m = confidentialVersion(overridenByAliases[oldNm] || this.methods[oldNm], newNm); m.definitionLine = 15; m.definitionModule = "dialect"; this.methods[newNm] = m; } for (let exName in inheritedExclusions) { if (inheritedExclusions.hasOwnProperty(exName)) { if (inheritedExclusions[exName]) { this.methods[exName] = inheritedExclusions[exName]; } else { delete this.methods[exName]; } } } var obj6_init = function() { // init of object on line 15 this.data.key = var_key__39__; this.data.value = var_value__39__; }; return obj6_init; // from compileBuildAndInitFunctions(_)inMethod(_) }; var obj6_init = obj6_build.call(inheritingObject, null, var_key__39__, var_value__39__, this, aliases, exclusions); return obj6_init; // from compileBuildMethodFor(_)withObjCon(_)inside(_) }; // end of method entryFrom(_)to(_)$build(_,_,_) func5.confidential = true; this.methods["entryFrom(1)to(1)$build(3)"] = func5; func5.methodName = "entryFrom(1)to(1)$build(3)"; func5.paramCounts = [1, 1]; func5.paramNames = ["key'", "value'"]; func5.definitionLine = 15; func5.definitionModule = "dialect"; var func10 = function(argcv) { // method aMutableMap, line 20 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("aMutableMap", 0, numArgs - 0); } var ouc = emptyGraceObject("aMutableMap", "dialect", 20); var ouc_init = this.methods["aMutableMap$build(3)"].call(this, null, ouc, [], []); ouc_init.call(ouc); return ouc; }; // end of method aMutableMap this.methods["aMutableMap"] = func10; func10.methodName = "aMutableMap"; func10.paramCounts = [0]; func10.paramNames = []; func10.definitionLine = 20; func10.definitionModule = "dialect"; var func11 = function(argcv, inheritingObject, aliases, exclusions) { // method aMutableMap$build(_,_,_), line 20 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 4; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("aMutableMap", 0, numArgs - 0); } var obj12_build = function(ignore, outerObj, aliases, exclusions) { this.closureKeys = this.closureKeys || []; this.closureKeys.push("outer_dialect_20"); this.outer_dialect_20 = outerObj; const inheritedExclusions = { }; for (var eix = 0, eLen = exclusions.length; eix < eLen; eix ++) { const exMeth = exclusions[eix]; inheritedExclusions[exMeth] = this.methods[exMeth]; }; this.data.entries = undefined; var reader13_entries = function() { // reader method entries if (this.data.entries === undefined) raiseUninitializedVariable("entries"); return this.data.entries; }; reader13_entries.isDef = true; reader13_entries.confidential = true; this.methods["entries"] = reader13_entries; var func14 = function(argcv) { // method isEmpty, line 24 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("isEmpty", 0, numArgs - 0); } setLineNumber(24); // compilenode num // call case 4: other requests var call16 = selfRequest(this, "size", [0]); var term15 = request(call16, "==(1)", [1], new GraceNum(0)); var call17 = selfRequest(var_$module, "Boolean", [0]); assertTypeOrMsg(term15, call17, "result of method isEmpty", "Boolean"); return term15; }; // end of method isEmpty var call18 = selfRequest(var_$module, "Boolean", [0]); func14.returnType = call18; this.methods["isEmpty"] = func14; func14.methodName = "isEmpty"; func14.paramCounts = [0]; func14.paramNames = []; func14.definitionLine = 24; func14.definitionModule = "dialect"; var func19 = function(argcv) { // method size, line 26 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 0) && (numArgs !== 0)) { raiseTypeArgError("size", 0, numArgs - 0); } setLineNumber(26); // compilenode member // call case 4: other requests var call21 = selfRequest(this, "entries", [0]); var call20 = request(call21, "size", [0]); var call22 = selfRequest(var_$module, "Number", [0]); assertTypeOrMsg(call20, call22, "result of method size", "Number"); return call20; }; // end of method size var call23 = selfRequest(var_$module, "Number", [0]); func19.returnType = call23; this.methods["size"] = func19; func19.methodName = "size"; func19.paramCounts = [0]; func19.paramNames = []; func19.definitionLine = 26; func19.definitionModule = "dialect"; var func24 = function(argcv, var_key) { // method at(_), line 28 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("at(_)", 0, numArgs - 1); } setLineNumber(29); // compilenode block var block26 = new GraceBlock(this, 29, 1); block26.guard = jsTrue; block26.real = function block26(var_value) { setLineNumber(29); // compilenode return throw new ReturnException(var_value, returnTarget); }; let applyMeth26 = function apply_1 (argcv, ...args) { if (this.guard.apply(this.receiver, args)) return this.real.apply(this.receiver, args); badBlockArgs.apply(this, args); }; applyMeth26.methodName = "apply(1)"; applyMeth26.paramCounts = [1]; applyMeth26.paramNames = ["value"]; applyMeth26.definitionLine = 29; applyMeth26.definitionModule = "dialect"; block26.methods["apply(1)"] = applyMeth26; let matchesMeth26 = function matches_1 (argcv, ...args) { return this.guard.apply(this.receiver, args) ? GraceTrue : GraceFalse; }; matchesMeth26.methodName = "matches(1)"; matchesMeth26.paramCounts = [1]; matchesMeth26.paramNames = ["value"]; matchesMeth26.definitionLine = 29; matchesMeth26.definitionModule = "dialect"; block26.methods["matches(1)"] = matchesMeth26; var call25 = selfRequest(this, "atKey(1)do(1)", [1, 1], var_key, block26); setLineNumber(31); // compilenode string var string29 = new GraceString(" in aMutableMap"); // call case 4: other requests // call case 4: other requests var string31 = new GraceString("no key "); var concat30 = request(string31, "++(1)", [1], var_key); var concat28 = request(concat30, "++(1)", [1], string29); // call case 4: other requests var call32 = selfRequest(var_$module, "NoSuchObject", [0]); var call27 = request(call32, "raise(1)", [1], concat28); return call27; }; // end of method at(_) this.methods["at(1)"] = func24; func24.methodName = "at(1)"; func24.paramCounts = [1]; func24.paramNames = ["key"]; func24.definitionLine = 28; func24.definitionModule = "dialect"; var func33 = function(argcv, var_key, var_value) { // method at(_)put(_), line 34 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 2) && (numArgs !== 2)) { raiseTypeArgError("at(_)put(_)", 0, numArgs - 2); } var if34 = GraceDone; setLineNumber(35); // compilenode string var string36 = new GraceString("done"); // call case 4: other requests // call case 4: other requests var call37 = request(var_value, "asString", [0]); var term35 = request(call37, "==(1)", [1], string36); if (Grace_isTrue(term35)) { setLineNumber(36); // compilenode string // call case 4: other requests // call case 4: other requests var string41 = new GraceString("mutableMap: attempting to put \u2039done\u203a at key "); var concat40 = request(string41, "++(1)", [1], var_key); var concat39 = request(concat40, "++(1)", [1], GraceEmptyString);