compiler/TProgramNodeVisitor.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 20 Sep 2015 12:01:42 +0100
changeset 13 97090c2baa33
parent 9 569bf5707c7e
child 14 fa42d3f1a578
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
RBProgramNodeVisitor subclass:#TProgramNodeVisitor
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:''
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-AST'
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
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
!TProgramNodeVisitor methodsFor:'visiting'!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
visitArgument: anRBVariableNode
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    16
    | typeSpec |
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    17
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
    super visitArgument: anRBVariableNode.
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    19
    typeSpec := anRBVariableNode typeSpec.
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    20
    typeSpec notNil ifTrue:[ self visitNode: typeSpec ]
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
    "Created: / 25-08-2015 / 19:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    23
    "Modified: / 02-09-2015 / 06:53:18 / 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
    24
! !
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
!TProgramNodeVisitor methodsFor:'visitor-double dispatching'!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    28
acceptInlineAssemblyNode: aMethodNode 
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    29
    self acceptBlockNode: aMethodNode.
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    30
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    31
    "Created: / 02-09-2015 / 06:52:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    32
!
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3
diff changeset
    33
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
acceptMethodNode: aMethodNode 
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
    super acceptMethodNode: aMethodNode.
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
    self visitNode: aMethodNode returnTypeSpec
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
    "Created: / 25-08-2015 / 19:53:04 / 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
    39
!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
acceptSimpleTypeNode: aTSimpleTypeNode
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
    "Created: / 21-08-2015 / 22:20:26 / 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
    44
    "Modified: / 25-08-2015 / 19:54: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
    45
!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
9
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    47
acceptSpecialFormNode: aTSpecialFormNode
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    48
    self acceptMessageNode: aTSpecialFormNode
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    49
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    50
    "Created: / 14-09-2015 / 12:10:35 / 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: 6
diff changeset
    51
!
569bf5707c7e Added support for special forms to parser and typechecker (somewhat)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
    52
3
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
acceptTypeSpecNode: aTTypeSpecNode
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
    self visitNode: aTTypeSpecNode type.
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
    "Created: / 21-08-2015 / 22:18:08 / 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
    57
    "Modified: / 25-08-2015 / 19:54:47 / 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
    58
!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
acceptUnionTypeNode: aTUnionTypeNode
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
    aTUnionTypeNode types do:[:type | self visitNode: type ]
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
    "Created: / 21-08-2015 / 22:21:29 / 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
    64
    "Modified (format): / 25-08-2015 / 19:54:40 / 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
    65
! !
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
!TProgramNodeVisitor class methodsFor:'documentation'!
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
version
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
    ^ 'Path: jv/tea/compiler/TProgramNodeVisitor.st, Version: 1.0, User: jv, Time: 2015-08-25T19:55:02.763+01'
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
!
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
version_HG
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
    ^ 'Path: jv/tea/compiler/TProgramNodeVisitor.st, Version: 1.0, User: jv, Time: 2015-08-25T19:55:02.763+01'
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
! !
97ee341d3e9f Initial shot of scopes & bindings and type checking. Must be rethought.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76