compiler/TCompiler.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 31 Aug 2015 13:53:40 +0100
changeset 4 3d80069ea3e2
parent 1 18b4a3b98e96
child 6 0c806a7f1888
permissions -rw-r--r--
More work on basic infrastructure - types, bindings & compilation. At this point it actually can compile a simple method returning an integer value. However, full of hacks here and there and full of #notYetImplemented.

"{ Package: 'jv:tea/compiler' }"

"{ NameSpace: Smalltalk }"

Object subclass:#TCompiler
	instanceVariableNames:'context'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Tea-Compiler'
!


!TCompiler class methodsFor:'compilation'!

compile: unit in: env
    self new compile: unit in: env.
    "Created: / 29-08-2015 / 14:18:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TCompiler methodsFor:'accessing'!

context
    ^ context
!

context:aTCompilerContext
    context := aTCompilerContext.
! !

!TCompiler methodsFor:'compilation'!

compile
    | unit |

    unit := context unit.
    self assert:(unit isRingObject and:[ unit isClass and:[ unit isMeta not ] ]).

    self runPass:TSemanticAnalysisPass.
    self runPass:TTypeAnalysisPass.
    self runPass:TLLVMIREmitPass.

    "Created: / 29-08-2015 / 14:22:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (format): / 31-08-2015 / 10:51:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

compile: unit
    context unit: unit.
    self compile.

    "Created: / 29-08-2015 / 21:53:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

compile: unit in: environment
    context := TCompilerContext new.
    context environment: environment.
    context unit: unit.
    self context: context.
    self compile: unit.

    "Created: / 31-08-2015 / 12:27:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TCompiler methodsFor:'private'!

runPass: aClass
    aClass new
        context: context;
        run

    "Created: / 31-08-2015 / 10:51:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TCompiler class methodsFor:'documentation'!

version
    ^ 'Path: jv/tea/compiler/TCompiler.st, Version: 1.0, User: jv, Time: 2015-08-31T13:47:55.136+01'
!

version_HG
    ^ 'Path: jv/tea/compiler/TCompiler.st, Version: 1.0, User: jv, Time: 2015-08-31T13:47:55.136+01'
! !