compiler/extensions.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 23 Sep 2015 22:21:44 +0100
changeset 15 10a95d798b36
parent 9 569bf5707c7e
permissions -rw-r--r--
Added support for local variables and #whileTrue: special form Allocate all local variables in a special basic block named `allocas`. Added support for #whileTrue: special form.

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

!RBAssignmentNode methodsFor:'accessing'!

binding
    ^ variable binding

    "Created: / 23-09-2015 / 16:45:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBAssignmentNode methodsFor:'accessing'!

binding: aTBinding
    self shouldNotImplement

    "Created: / 23-09-2015 / 16:45:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBBlockNode methodsFor:'accessing'!

parameterTypes
    ^arguments collect:[ :arg | arg type ]

    "Created: / 23-09-2015 / 16:30:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBBlockNode methodsFor:'accessing'!

returnType
    | spec |

    spec := self returnTypeSpec.
    ^ spec notNil ifTrue:[ spec asType ] ifFalse:[ TAutomaticType new ]

    "Created: / 23-09-2015 / 16:28:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBBlockNode methodsFor:'accessing'!

returnTypeSpec
    "Return the TTypeSpecNode describing the return type of the
     block"

    ^ self propertyAt: #returnTypeSpec ifAbsent: nil

    "Created: / 21-08-2015 / 22:47:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBBlockNode methodsFor:'accessing'!

returnTypeSpec: aTTypeSpecNode
    "Set the TTypeSpecNode describing the return type of the block"

    ^ self propertyAt: #returnTypeSpec put: aTTypeSpecNode

    "Created: / 21-08-2015 / 22:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBBlockNode methodsFor:'accessing'!

scope
    ^ self propertyAt: #scope

    "Created: / 25-08-2015 / 22:14:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBBlockNode methodsFor:'accessing'!

scope: aTScope
    ^ self propertyAt: #scope put: aTScope

    "Created: / 25-08-2015 / 22:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBMethodNode methodsFor:'accessing'!

parameterTypes
    ^arguments collect:[ :arg | arg type ]

    "Created: / 23-09-2015 / 16:30:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBMethodNode methodsFor:'accessing'!

returnType
    | spec |

    spec := self returnTypeSpec.
    ^ spec notNil ifTrue:[ spec asType ] ifFalse:[ TAutomaticType new ]

    "Created: / 23-09-2015 / 16:28:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBMethodNode methodsFor:'accessing'!

returnTypeSpec
    "Return the TTypeSpecNode describing the return type of the
     method"

    ^ self propertyAt: #returnTypeSpec ifAbsent: nil

    "Created: / 21-08-2015 / 22:47:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBMethodNode methodsFor:'accessing'!

returnTypeSpec: aTTypeSpecNode
    "Set the TTypeSpecNode describing the return type of the method"

    ^ self propertyAt: #returnTypeSpec put: aTTypeSpecNode

    "Created: / 21-08-2015 / 22:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBMethodNode methodsFor:'accessing'!

scope
    ^ self propertyAt: #scope

    "Created: / 25-08-2015 / 22:14:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBMethodNode methodsFor:'accessing'!

scope: aTScope
    ^ self propertyAt: #scope put: aTScope

    "Created: / 25-08-2015 / 22:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBProgramNode methodsFor:'accessing'!

binding
    ^ self propertyAt: #binding

    "Created: / 25-08-2015 / 22:15:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBProgramNode methodsFor:'accessing'!

binding: aTBinding
    self propertyAt: #binding put: aTBinding

    "Created: / 25-08-2015 / 22:15:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBProgramNode methodsFor:'testing'!

isInlineAssembly
        ^false

    "Created: / 02-09-2015 / 06:30:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBProgramNode methodsFor:'testing'!

isSpecialFormNode
    "return false here; to be redefined in subclass(es)"

    ^ false
! !

!RBProgramNode methodsFor:'accessing'!

scope
    ^ self parent scope

    "Created: / 25-08-2015 / 22:13:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBReturnNode methodsFor:'accessing'!

binding
    ^ value binding

    "Created: / 25-08-2015 / 23:38:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBReturnNode methodsFor:'accessing'!

binding: aTBinding
    self shouldNotImplement

    "Created: / 25-08-2015 / 23:39:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBToken methodsFor:'testing'!

isTInlineAssemblyBegin
    ^ false

    "Created: / 02-09-2015 / 06:19:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBToken methodsFor:'testing'!

isTInlineAssemblyEnd
    ^ false

    "Created: / 02-09-2015 / 06:19:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBVariableNode methodsFor:'accessing'!

type
    | spec |

    spec := self typeSpec.
    ^ spec notNil ifTrue:[ spec asType ] ifFalse:[ TAutomaticType new ]

    "Created: / 23-09-2015 / 16:29:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RBVariableNode methodsFor:'accessing'!

typeSpec
    "Return the TTypeSpecNode associated with this variable node
     (if this node is for variable declaration) or nil (otherwise)"

    ^ self propertyAt: #typeSpec ifAbsent: nil

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

!RBVariableNode methodsFor:'accessing'!

typeSpec: aTTypeSpecNode
    "Associate a TTypeSpecNode this variable node"

    ^ self propertyAt: #typeSpec put: aTTypeSpecNode

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

!RGClassDefinition methodsFor:'visiting'!

acceptVisitor: anObject
    ^ anObject acceptClassDefinition: self

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

!RGDefinition methodsFor:'testing types'!

isCompilationUnit

    ^false

    "Created: / 14-09-2015 / 10:29:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!RGMetaclassDefinition methodsFor:'visiting'!

acceptVisitor: anObject
    ^ anObject acceptMetaclassDefinition: self

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

!RGMethodDefinition methodsFor:'visiting'!

acceptVisitor: anObject
    ^ anObject acceptMethodDefinition: self

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

!jv_tea_compiler class methodsFor:'documentation'!

extensionsVersion_HG

    ^ '$Changeset: <not expanded> $'
! !