compiler/TNamespaceBinding.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 25 Sep 2015 03:51:15 +0100
changeset 16 17a2d1d9f205
parent 9 569bf5707c7e
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: 9
diff changeset
     1
"
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
     2
    Copyright (C) 2015-now Jan Vrany
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
     3
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
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: 9
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: 9
diff changeset
     6
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
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: 9
diff changeset
     8
      original author for inclusion in future releases
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
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: 9
diff changeset
    10
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
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: 9
diff changeset
    12
    a future.
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    13
"
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
"{ Package: 'jv:tea/compiler' }"
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
"{ NameSpace: Smalltalk }"
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
TBinding subclass:#TNamespaceBinding
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    19
	instanceVariableNames:'definition elements'
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
	classVariableNames:''
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
	poolDictionaries:''
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
	category:'Languages-Tea-Compiler-Bindings'
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
!
0c806a7f1888 Initial support for inline assembly
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: 9
diff changeset
    25
!TNamespaceBinding class methodsFor:'documentation'!
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    26
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    27
copyright
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    28
"
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    29
    Copyright (C) 2015-now Jan Vrany
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    30
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
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: 9
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: 9
diff changeset
    33
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
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: 9
diff changeset
    35
      original author for inclusion in future releases
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
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: 9
diff changeset
    37
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
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: 9
diff changeset
    39
    a future.
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    40
"
17a2d1d9f205 Added standalone Tea compiler - teak
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    41
! !
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    42
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    43
!TNamespaceBinding class methodsFor:'instance creation'!
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    44
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    45
namespace: aTNamespaceDefinition
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    46
    ^ self new initializeWithNamespace: aTNamespaceDefinition
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    48
    "Created: / 02-09-2015 / 15:59:06 / 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
    49
!
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    51
new
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    52
    "return an initialized instance"
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    53
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    54
    ^ self basicNew initialize.
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
! !
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
9
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    57
!TNamespaceBinding methodsFor:'accessing'!
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    58
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    59
type
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    60
    ^ self shouldNotImplement
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    61
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    62
    "Created: / 14-09-2015 / 14:13:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    63
! !
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    64
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    65
!TNamespaceBinding methodsFor:'initialization'!
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
initializeWithNamespace: aTNamespaceDefinition
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    68
    "Invoked when a new instance is created."
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
    definition := aTNamespaceDefinition.
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
    "Created: / 02-09-2015 / 15:59:35 / 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
    73
! !
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    74
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    75
!TNamespaceBinding methodsFor:'lookup'!
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    76
9
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    77
lookupClassBoolean
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    78
    ^ self lookupClassNamed: 'tBoolean'
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    79
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    80
    "Created: / 14-09-2015 / 14:13:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    81
!
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    82
7
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    83
lookupClassNamed: name
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    84
    | class |
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    85
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    86
    class := definition classNamed: name.
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    87
    class notNil ifTrue:[ 
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    88
        ^ class binding
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    89
    ].
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    90
    self error:('Could not resolve class named %1' bindWith: name)
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    91
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    92
    "Created: / 02-09-2015 / 11:09:33 / 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
    93
    "Modified (format): / 02-09-2015 / 16:00:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    94
!
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    95
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    96
lookupClassPointer
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    97
    ^ self lookupClassNamed: 'tPointer'
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    98
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
    99
    "Created: / 14-09-2015 / 14:14:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   100
!
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   101
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   102
lookupClassSIntegerW
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   103
    ^ self lookupClassNamed: 'tSIntegerW'
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   104
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   105
    "Created: / 14-09-2015 / 14:13:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   106
!
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   107
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   108
lookupClassUIntegerW
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   109
    ^ self lookupClassNamed: 'tUIntegerW'
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   110
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7
diff changeset
   111
    "Created: / 14-09-2015 / 14:13:54 / 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
   112
! !
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   113
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   114
!TNamespaceBinding 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
   115
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   116
version_HG
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   117
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   118
    ^ '$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
   119
! !
7556e3d41d80 Make 3 + 4 working, though the code is rather messy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   120