compiler/TVariableBinding.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 20 Sep 2015 12:01:42 +0100
changeset 13 97090c2baa33
parent 7 7556e3d41d80
child 16 17a2d1d9f205
permissions -rw-r--r--
Fixes/refactoring of scopes and bindings. Fixed initialization of scopes and bindings. Make typechecker to seed types.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ 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
     2
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Smalltalk }"
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
TValueBinding subclass:#TVariableBinding
13
97090c2baa33 Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
     6
	instanceVariableNames:'name index'
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	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
    10
!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
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: 6
diff changeset
    12
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
!TVariableBinding 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
    14
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    15
name:aString 
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    16
    ^ self new initializeWithName:aString
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    18
    "Created: / 31-08-2015 / 12:08:09 / 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
    19
! !
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
!TVariableBinding class methodsFor:'queries'!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
isAbstract
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
    "Return if this class is an abstract class.
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
     True is returned here for myself only; false for subclasses.
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
     Abstract subclasses must redefine again."
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
    ^ self == TVariableBinding.
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
! !
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
!TVariableBinding methodsFor:'accessing'!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
name
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
    ^ name
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
! !
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    37
!TVariableBinding methodsFor:'conversion'!
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    38
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    39
asLLVMValueInModule: aLLVMModule
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    40
    self halt.
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    41
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    42
    "Created: / 02-09-2015 / 08:34:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    43
    "Modified: / 03-09-2015 / 07:05:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    44
! !
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    45
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
!TVariableBinding methodsFor:'initialization'!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    48
initializeWithName:aString 
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
    name := aString.
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    51
    "Created: / 31-08-2015 / 12:07:45 / 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
    52
! !
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
!TVariableBinding methodsFor:'printing & storing'!
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
printOn:aStream
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    aStream nextPutAll: name.
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
    aStream space.
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
    type notNil ifTrue:[ 
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
        type printOn: aStream
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
    ] ifFalse:[ 
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
        aStream nextPutAll: '< ??? >'
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
    "Modified: / 25-08-2015 / 22:54:09 / 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
    66
! !
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    68
!TVariableBinding class methodsFor:'documentation'!
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    69
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    70
version_HG
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    71
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    72
    ^ '$Changeset: <not expanded> $'
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    73
! !
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    74