compiler/TConstantBinding.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 25 Sep 2015 03:51:15 +0100
changeset 16 17a2d1d9f205
parent 13 97090c2baa33
permissions -rw-r--r--
Added standalone Tea compiler - teak It allows for compilation of .tea files from the command line.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
     1
"
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
     2
    Copyright (C) 2015-now Jan Vrany
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
     3
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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: 13
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: 13
diff changeset
     6
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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: 13
diff changeset
     8
      original author for inclusion in future releases
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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: 13
diff changeset
    10
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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: 13
diff changeset
    12
    a future.
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
TValueBinding subclass:#TConstantBinding
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
	instanceVariableNames:'value'
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: 13
diff changeset
    25
!TConstantBinding class methodsFor:'documentation'!
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
    26
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
    27
copyright
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
    28
"
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
    29
    Copyright (C) 2015-now Jan Vrany
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
    30
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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: 13
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: 13
diff changeset
    33
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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: 13
diff changeset
    35
      original author for inclusion in future releases
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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: 13
diff changeset
    37
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
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: 13
diff changeset
    39
    a future.
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
    40
"
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
    41
! !
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
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
!TConstantBinding 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
13
97090c2baa33 Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 11
diff changeset
    45
value: anObject
97090c2baa33 Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 11
diff changeset
    46
    ^ self new initializeWithValue: anObject
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
13
97090c2baa33 Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 11
diff changeset
    48
    "Created: / 20-09-2015 / 07:11:25 / 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
    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
!TConstantBinding methodsFor:'accessing'!
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
value
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
    ^ value
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
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    57
!TConstantBinding methodsFor:'converting'!
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    58
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    59
asLLVMValueInModule: aLLVMModule
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    60
    value isInteger ifTrue:[ 
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    61
        ^ LLVMConstant sint: value type: (type asLLVMTypeInModule: aLLVMModule ).
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    62
    ].
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    63
    ^ self notYetImplemented
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    64
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    65
    "Created: / 03-09-2015 / 07:07:02 / 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: 6
diff changeset
    66
! !
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    67
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
!TConstantBinding methodsFor:'initialization'!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
13
97090c2baa33 Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 11
diff changeset
    70
initializeWithValue: anObject
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
    value := anObject.
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
13
97090c2baa33 Fixes/refactoring of scopes and bindings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 11
diff changeset
    73
    "Created: / 20-09-2015 / 07:11:37 / 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
    74
! !
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    76
!TConstantBinding methodsFor:'testing'!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    77
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    78
isConstantBinding
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    79
    ^ true
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    80
! !
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    81
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    82
!TConstantBinding class methodsFor:'documentation'!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    83
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    84
version_HG
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    85
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    86
    ^ '$Changeset: <not expanded> $'
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    87
! !
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    88