author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 25 Sep 2015 03:51:15 +0100 | |
changeset 16 | 17a2d1d9f205 |
parent 15 | 10a95d798b36 |
permissions | -rw-r--r-- |
16
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
1 |
" |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
2 |
Copyright (C) 2015-now Jan Vrany |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
3 |
|
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
4 |
This code is not an open-source (yet). You may use this code |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
5 |
for your own experiments and projects, given that: |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
6 |
|
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
7 |
* all modification to the code will be sent to the |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
8 |
original author for inclusion in future releases |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
9 |
* this is not used in any commercial software |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
10 |
|
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
11 |
This license is provisional and may (will) change in |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
12 |
a future. |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
13 |
" |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
14 |
"{ Package: 'jv:tea/compiler' }" |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
15 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
16 |
"{ NameSpace: Smalltalk }" |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
17 |
|
15
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
18 |
TObjectWithProperties subclass:#TScope |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
19 |
instanceVariableNames:'node parent children variables' |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
20 |
classVariableNames:'' |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
21 |
poolDictionaries:'' |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
22 |
category:'Languages-Tea-Compiler-Bindings' |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
23 |
! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
24 |
|
16
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
25 |
!TScope class methodsFor:'documentation'! |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
26 |
|
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
27 |
copyright |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
28 |
" |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
29 |
Copyright (C) 2015-now Jan Vrany |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
30 |
|
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
31 |
This code is not an open-source (yet). You may use this code |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
32 |
for your own experiments and projects, given that: |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
33 |
|
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
34 |
* all modification to the code will be sent to the |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
35 |
original author for inclusion in future releases |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
36 |
* this is not used in any commercial software |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
37 |
|
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
38 |
This license is provisional and may (will) change in |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
39 |
a future. |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
40 |
" |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
41 |
! ! |
17a2d1d9f205
Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15
diff
changeset
|
42 |
|
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
43 |
!TScope class methodsFor:'instance creation'! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
44 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
45 |
node: node |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
46 |
^ self node: node parent: nil. |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
47 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
48 |
"Created: / 25-08-2015 / 22:28:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
49 |
! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
50 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
51 |
node: node parent: parent |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
52 |
^ self new initializeWithNode: node parent: parent |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
53 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
54 |
"Created: / 25-08-2015 / 22:24:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
55 |
! ! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
56 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
57 |
!TScope methodsFor:'accessing'! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
58 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
59 |
children |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
60 |
^ children ? #() |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
61 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
62 |
"Modified: / 25-08-2015 / 22:28:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
63 |
! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
64 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
65 |
node |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
66 |
^ node |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
67 |
! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
68 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
69 |
parent |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
70 |
^ parent |
13
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
71 |
! |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
72 |
|
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
73 |
variables |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
74 |
^ variables ? #() |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
75 |
|
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
76 |
"Modified: / 19-09-2015 / 05:56:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
77 |
! ! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
78 |
|
15
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
79 |
!TScope methodsFor:'accesssing - llvm'! |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
80 |
|
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
81 |
llvmAllocas |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
82 |
^ self propertyAt: #llvmAllocas |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
83 |
ifAbsent: [ parent notNil ifTrue:[ parent llvmAllocas ] ifFalse:[nil] ] |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
84 |
|
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
85 |
"Created: / 23-09-2015 / 21:42:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
86 |
! |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
87 |
|
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
88 |
llvmAllocas: anLLVMBasicBlock |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
89 |
self propertyAt: #llvmAllocas put: anLLVMBasicBlock |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
90 |
|
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
91 |
"Created: / 23-09-2015 / 21:40:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
92 |
! ! |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
93 |
|
13
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
94 |
!TScope methodsFor:'adding & removing'! |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
95 |
|
13
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
96 |
addSubScope: aTScope |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
97 |
children isNil ifTrue:[ |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
98 |
children := OrderedCollection new: 5. |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
99 |
]. |
13
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
100 |
children add: aTScope |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
101 |
|
13
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
102 |
"Created: / 19-09-2015 / 06:05:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
103 |
! |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
104 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
105 |
addVariable: aTVariableBinding |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
106 |
variables isNil ifTrue:[ |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
107 |
variables := OrderedCollection new. |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
108 |
]. |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
109 |
variables add: aTVariableBinding |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
110 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
111 |
"Created: / 25-08-2015 / 22:42:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
112 |
! ! |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
113 |
|
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
114 |
!TScope methodsFor:'initialization'! |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
115 |
|
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
116 |
initializeWithNode: n parent: p |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
117 |
node := n. |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
118 |
parent := p. |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
119 |
parent notNil ifTrue:[ |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
120 |
parent addSubScope: self. |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
121 |
]. |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
122 |
|
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
123 |
"Created: / 25-08-2015 / 22:25:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
124 |
"Modified: / 19-09-2015 / 06:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
125 |
! ! |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
126 |
|
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
127 |
!TScope methodsFor:'lookup'! |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
128 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
129 |
lookupVariable: name |
13
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
130 |
"Return binding for variable with given name or nil if not found" |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
131 |
| variable | |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
132 |
variables notNil ifTrue:[ |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
133 |
variable := variables detect:[:binding | binding name = name ] ifNone:[ nil ]. |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
134 |
]. |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
135 |
(variable isNil and:[parent notNil]) ifTrue:[ |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
136 |
variable := parent lookupVariable: name. |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
137 |
]. |
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
138 |
^ variable |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
139 |
|
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
140 |
"Created: / 25-08-2015 / 22:58:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13
97090c2baa33
Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
141 |
"Modified: / 20-09-2015 / 06:11:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
142 |
! ! |
97ee341d3e9f
Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
143 |
|
6
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
144 |
!TScope methodsFor:'testing'! |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
145 |
|
15
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
146 |
hasSelfArgument |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
147 |
^ (node isMethod and:[node binding mclass isMetaclass not]) |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
148 |
|
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
149 |
"Created: / 23-09-2015 / 18:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
150 |
! |
10a95d798b36
Added support for local variables and #whileTrue: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
151 |
|
6
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
152 |
isBlockScope |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
153 |
^ node isBlock |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
154 |
|
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
155 |
"Created: / 02-09-2015 / 08:57:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
156 |
! |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
157 |
|
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
158 |
isMethodScope |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
159 |
^ node isMethod |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
160 |
|
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
161 |
"Created: / 02-09-2015 / 08:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
162 |
! ! |
0c806a7f1888
Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
163 |