Mercurial > repos > tabletprog
view modules/symbols.tp @ 289:befaefdfcd8a
Make sure that true and false modules are initialized before anything else and that the list module is initialized before any modules besides true and false
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 22 Jul 2014 23:32:49 -0700 |
parents | 98147071baf6 |
children | aea99b93cf2f |
line wrap: on
line source
{ _null <- #{ find:else <- :_ :else { else: } } _local <- 0 _closedover <- 1 _upvar <- 2 _method <- 3 _self <- 4 _parent <- 5 _nextMethodId <- 0 _method <- :_name { _id <- _nextMethodId _nextMethodId <- _id + 1 #{ name <- { _name } id <- { _id } string <- { "method " . _name . "(" . _id . ")" } } } #{ nullTable <- { _null } tablewithParent <- :_parent { _symbols <- dict hash #{ find:else <- :name :else { _symbols get: name else: { _parent find: name else: else } } defineMethod <- :name { _symbols get: name else: { _symbols set: name (_method: name) } self } print <- { foreach: _symbols :name info { print: name . ": " . info . "\n" } } } } table <- { tablewithParent: _null } buildMethodTable <- :tree { _object <- ast obj _assignment <- ast assignment _call <- ast call tree fold: table with: :acc el { if: (el nodeType) = _object { (el messages) fold: acc with: :acc msg { if: (msg nodeType) = _assignment { acc defineMethod: ((msg to) name) } else: { if: (msg nodeType) = _call && (msg llMessage?) { acc defineMethod: (((msg args) value) name) } } acc } } else: { acc } } } } }