compiler/TCompiler.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 02 Sep 2015 09:18:00 +0100
changeset 6 0c806a7f1888
parent 4 3d80069ea3e2
child 7 7556e3d41d80
permissions -rw-r--r--
Initial support for inline assembly
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'jv:tea/compiler' }"
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Smalltalk }"
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Object subclass:#TCompiler
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
     6
	instanceVariableNames:'context'
1
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'Languages-Tea-Compiler'
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
18b4a3b98e96 Creates subpackage jv:tea/compiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    12
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    13
!TCompiler class methodsFor:'compilation'!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    14
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    15
compile: unit in: env
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    16
    self new compile: unit in: env.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    17
    "Created: / 29-08-2015 / 14:18:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    18
! !
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    19
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    20
!TCompiler methodsFor:'accessing'!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    21
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    22
context
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    23
    ^ context
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    24
!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    25
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    26
context:aTCompilerContext
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    27
    context := aTCompilerContext.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    28
! !
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    29
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    30
!TCompiler methodsFor:'compilation'!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    31
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    32
compile
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    33
    | unit |
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    34
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    35
    unit := context unit.
6
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    36
    self 
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    37
        assert:(unit isRingObject and:[ unit isClass and:[ unit isMeta not ] ]).
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    38
    self runPass:TSemanticAnalyser.
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    39
    self runPass:TTypechecker.
0c806a7f1888 Initial support for inline assembly
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    40
    self runPass:TCodeGenerator.
4
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    41
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    42
    "Created: / 29-08-2015 / 14:22:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    43
    "Modified (format): / 31-08-2015 / 10:51:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    44
!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    45
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    46
compile: unit
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    47
    context unit: unit.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    48
    self compile.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    49
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    50
    "Created: / 29-08-2015 / 21:53: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: 1
diff changeset
    51
!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    52
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    53
compile: unit in: environment
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    54
    context := TCompilerContext new.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    55
    context environment: environment.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    56
    context unit: unit.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    57
    self context: context.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    58
    self compile: unit.
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    59
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    60
    "Created: / 31-08-2015 / 12:27:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    61
! !
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    62
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    63
!TCompiler methodsFor:'private'!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    64
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    65
runPass: aClass
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    66
    aClass new
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    67
        context: context;
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    68
        run
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    69
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    70
    "Created: / 31-08-2015 / 10:51:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    71
! !
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    72
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    73
!TCompiler class methodsFor:'documentation'!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    74
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    75
version
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    76
    ^ 'Path: jv/tea/compiler/TCompiler.st, Version: 1.0, User: jv, Time: 2015-08-31T13:47:55.136+01'
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    77
!
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    78
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    79
version_HG
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    80
    ^ 'Path: jv/tea/compiler/TCompiler.st, Version: 1.0, User: jv, Time: 2015-08-31T13:47:55.136+01'
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    81
! !
3d80069ea3e2 More work on basic infrastructure - types, bindings & compilation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    82