author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 16 Sep 2015 05:29:43 +0100 | |
changeset 11 | 6d39860d0fdb |
parent 8 | eec72263ed75 |
child 16 | 17a2d1d9f205 |
permissions | -rw-r--r-- |
4
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1 |
"{ Package: 'jv:tea/compiler' }" |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
2 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
3 |
"{ NameSpace: Smalltalk }" |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
4 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
5 |
TFunctionBinding subclass:#TMethodBinding |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
6 |
instanceVariableNames:'mclass selector' |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
7 |
classVariableNames:'' |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
8 |
poolDictionaries:'' |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
9 |
category:'Languages-Tea-Compiler-Bindings' |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
10 |
! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
11 |
|
7
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
12 |
|
4
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
13 |
!TMethodBinding class methodsFor:'instance creation'! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
14 |
|
8
eec72263ed75
Introduced TEnvironment, a container object that keeps all (class) definition requiref for a compilation
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7
diff
changeset
|
15 |
class: aTClassBinding selector: aSymbol |
eec72263ed75
Introduced TEnvironment, a container object that keeps all (class) definition requiref for a compilation
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7
diff
changeset
|
16 |
^ self new initializeWithClass: aTClassBinding selector: aSymbol |
4
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
17 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
18 |
"Created: / 31-08-2015 / 12:04:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
19 |
! ! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
20 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
21 |
!TMethodBinding methodsFor:'accessing'! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
22 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
23 |
mclass |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
24 |
^ mclass |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
25 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
26 |
"Created: / 31-08-2015 / 12:14:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
27 |
! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
28 |
|
7
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
29 |
receiverType |
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
30 |
^ mclass type |
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
31 |
|
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
32 |
"Created: / 02-09-2015 / 21:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
33 |
! |
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
34 |
|
4
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
35 |
selector |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
36 |
^ selector |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
37 |
! ! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
38 |
|
11
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
39 |
!TMethodBinding methodsFor:'converting'! |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
40 |
|
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
41 |
asLLVMValueInModule: aLLVMModule |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
42 |
| name function | |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
43 |
|
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
44 |
name := TLLVMCodeGenerator llvmFunctionNameForClass: mclass clazz selector: selector. |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
45 |
function := aLLVMModule getFunctionNamed: name. |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
46 |
function isNil ifTrue:[ |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
47 |
| type | |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
48 |
|
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
49 |
mclass isMetaclass ifTrue:[ |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
50 |
type := LLVMType |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
51 |
function: (parameterTypes collect:[:t|t asLLVMTypeInModule: aLLVMModule ]) |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
52 |
returning: (returnType asLLVMTypeInModule: aLLVMModule). |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
53 |
] ifFalse:[ |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
54 |
type := LLVMType |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
55 |
function: {mclass type asLLVMTypeInModule: aLLVMModule } , |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
56 |
(parameterTypes collect:[:t|t asLLVMTypeInModule: aLLVMModule]) |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
57 |
returning: (returnType asLLVMTypeInModule: aLLVMModule). |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
58 |
]. |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
59 |
function := aLLVMModule addFunctionNamed: name type: type. |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
60 |
mclass isMetaclass ifFalse:[ |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
61 |
(function parameterAt: 1) name: 'self'. |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
62 |
] |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
63 |
]. |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
64 |
^ function |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
65 |
|
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
66 |
"Created: / 15-09-2015 / 07:04:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
67 |
! ! |
6d39860d0fdb
First shot on #ifTrie:ifFalse: special form
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
68 |
|
4
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
69 |
!TMethodBinding methodsFor:'initialization'! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
70 |
|
8
eec72263ed75
Introduced TEnvironment, a container object that keeps all (class) definition requiref for a compilation
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7
diff
changeset
|
71 |
initializeWithClass: aTClassBinding selector: aSymbol |
eec72263ed75
Introduced TEnvironment, a container object that keeps all (class) definition requiref for a compilation
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7
diff
changeset
|
72 |
mclass := aTClassBinding. |
4
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
73 |
selector := aSymbol |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
74 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
75 |
"Created: / 31-08-2015 / 11:20:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
76 |
! ! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
77 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
78 |
!TMethodBinding methodsFor:'testing'! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
79 |
|
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
80 |
isMethodBinding |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
81 |
^ true |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
82 |
! ! |
3d80069ea3e2
More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
83 |
|
7
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
84 |
!TMethodBinding class methodsFor:'documentation'! |
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
85 |
|
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
86 |
version_HG |
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
87 |
|
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
88 |
^ '$Changeset: <not expanded> $' |
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
89 |
! ! |
7556e3d41d80
Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
90 |