Mercurial > repos > tabletprog
annotate modules/symbols.tp @ 277:2b58eafa360b
Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 20 Jul 2014 17:30:46 -0700 |
parents | 98147071baf6 |
children | aea99b93cf2f |
rev | line source |
---|---|
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 _null <- #{ |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 find:else <- :_ :else { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 else: |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 _local <- 0 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 _closedover <- 1 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 _upvar <- 2 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 _method <- 3 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 _self <- 4 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 _parent <- 5 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 _nextMethodId <- 0 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 _method <- :_name { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 _id <- _nextMethodId |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 _nextMethodId <- _id + 1 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 #{ |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 name <- { _name } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 id <- { _id } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 string <- { "method " . _name . "(" . _id . ")" } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 #{ |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 nullTable <- { _null } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 tablewithParent <- :_parent { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 _symbols <- dict hash |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 #{ |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 find:else <- :name :else { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 _symbols get: name else: { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 _parent find: name else: else |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 defineMethod <- :name { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 _symbols get: name else: { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 _symbols set: name (_method: name) |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 self |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 print <- { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 foreach: _symbols :name info { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 print: name . ": " . info . "\n" |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 table <- { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 tablewithParent: _null |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 buildMethodTable <- :tree { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 _object <- ast obj |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 _assignment <- ast assignment |
263
98147071baf6
Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
56 _call <- ast call |
98147071baf6
Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
57 |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 tree fold: table with: :acc el { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 if: (el nodeType) = _object { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 (el messages) fold: acc with: :acc msg { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 if: (msg nodeType) = _assignment { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 acc defineMethod: ((msg to) name) |
263
98147071baf6
Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
63 } else: { |
98147071baf6
Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
64 if: (msg nodeType) = _call && (msg llMessage?) { |
98147071baf6
Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
65 acc defineMethod: (((msg args) value) name) |
98147071baf6
Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
66 } |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 acc |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 } else: { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 acc |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 } |