annotate modules/symbols.tp @ 253:697c2c562af2

Fix infinite loop in hash dict
author Michael Pavone <pavone@retrodev.com>
date Sat, 31 May 2014 21:27:03 -0700
parents 004946743678
children 98147071baf6
rev   line source
pavone@252 1 {
pavone@252 2 _null <- #{
pavone@252 3 find:else <- :_ :else {
pavone@252 4 else:
pavone@252 5 }
pavone@252 6 }
pavone@252 7 _local <- 0
pavone@252 8 _closedover <- 1
pavone@252 9 _upvar <- 2
pavone@252 10 _method <- 3
pavone@252 11 _self <- 4
pavone@252 12 _parent <- 5
pavone@252 13
pavone@252 14 _nextMethodId <- 0
pavone@252 15 _method <- :_name {
pavone@252 16 _id <- _nextMethodId
pavone@252 17 _nextMethodId <- _id + 1
pavone@252 18 #{
pavone@252 19 name <- { _name }
pavone@252 20 id <- { _id }
pavone@252 21 string <- { "method " . _name . "(" . _id . ")" }
pavone@252 22 }
pavone@252 23 }
pavone@252 24 #{
pavone@252 25 nullTable <- { _null }
pavone@252 26
pavone@252 27 tablewithParent <- :_parent {
pavone@252 28 _symbols <- dict hash
pavone@252 29 #{
pavone@252 30 find:else <- :name :else {
pavone@252 31 _symbols get: name else: {
pavone@252 32 _parent find: name else: else
pavone@252 33 }
pavone@252 34 }
pavone@252 35 defineMethod <- :name {
pavone@252 36 _symbols get: name else: {
pavone@252 37 _symbols set: name (_method: name)
pavone@252 38 }
pavone@252 39 self
pavone@252 40 }
pavone@252 41 print <- {
pavone@252 42 foreach: _symbols :name info {
pavone@252 43 print: name . ": " . info . "\n"
pavone@252 44 }
pavone@252 45 }
pavone@252 46 }
pavone@252 47 }
pavone@252 48
pavone@252 49 table <- {
pavone@252 50 tablewithParent: _null
pavone@252 51 }
pavone@252 52
pavone@252 53 buildMethodTable <- :tree {
pavone@252 54 _object <- ast obj
pavone@252 55 _assignment <- ast assignment
pavone@252 56 tree fold: table with: :acc el {
pavone@252 57 if: (el nodeType) = _object {
pavone@252 58 (el messages) fold: acc with: :acc msg {
pavone@252 59 if: (msg nodeType) = _assignment {
pavone@252 60 acc defineMethod: ((msg to) name)
pavone@252 61 }
pavone@252 62 acc
pavone@252 63 }
pavone@252 64 } else: {
pavone@252 65 acc
pavone@252 66 }
pavone@252 67 }
pavone@252 68 }
pavone@252 69 }
pavone@252 70 }