IRFunction.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 30 Oct 2014 22:45:30 +0000
changeset 46 2fb37cf149fb
parent 45 04a50b0d540a
permissions -rw-r--r--
Fixed testSendSuper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41
f3898a3b378d Package renamed from cvut:stx/goodies/newcompiler to ctu:ircompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
     1
"{ Package: 'ctu:ircompiler' }"
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
Object subclass:#IRFunction
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
	instanceVariableNames:'startSequence primitiveNode tempKeys tempMap numRargs properties
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
		additionalLiterals maxOrderNumber sourceMap environmentIr
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
		compiledCode'
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
42
acdc3ec6d152 Better class category name - IR Compiler-*
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 41
diff changeset
     9
	category:'IR Compiler-IR'
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
10
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    13
!IRFunction class methodsFor:'instance creation'!
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    14
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    15
new
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    16
    ^ self basicNew initialize.
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    17
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    18
    "Created: / 11-06-2008 / 00:52:34 / Jan Vrany <vranyj1@fel.cvut.cz>"
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    19
! !
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
    20
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
!IRFunction methodsFor:'accessing'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
addLiteral: aSymbol
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    24
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
	additionalLiterals add: aSymbol.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
addLiterals: anArray
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    29
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
	additionalLiterals addAll: anArray.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
addTemps: newKeys
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
    | keys i new |
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
    keys := self tempKeys.
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    37
    i := keys size -
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    38
	    (self isIRMethod
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    39
		ifTrue:[1 "zero-based (index 0 equals receiver - self)"]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    40
		ifFalse:[0]).
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
    new := OrderedCollection new.
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    42
    newKeys do:
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    43
	[:key |
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    44
	tempMap at: key ifAbsentPut:
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    45
	    [new add: key.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
    46
	    i := i + 1]].
21
a5d30403049c Small improvement in IRFunction>>addTemps:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 10
diff changeset
    47
    new isEmpty ifTrue:[^self].
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    self tempKeys: keys, new.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
21
a5d30403049c Small improvement in IRFunction>>addTemps:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 10
diff changeset
    50
    "Modified: / 12-08-2009 / 09:22:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
additionalLiterals
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
	^additionalLiterals.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
allInstructions
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
	" return irNodes as a flat collection "
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
	| irInstructions |
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
	irInstructions := OrderedCollection new.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
	startSequence withAllSuccessorsDo: [:seq | seq do: [:bc | irInstructions add: bc]].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
	^irInstructions
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
allInstructionsMatching: aBlock
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
	" return irNodes as a flat collection "
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
	| irInstructions |
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
	irInstructions := OrderedCollection new.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
	startSequence withAllSuccessorsDo: [:seq | seq do: [:bc | (aBlock value: bc) ifTrue: [irInstructions add: bc]]].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
	^irInstructions
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
allSendInstructions
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
	^self allInstructionsMatching: [:bc | bc isSend].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
allSequences
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
	^ startSequence withAllSuccessors
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
allTempAccessInstructions
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
	^self allInstructionsMatching: [:bc | bc isTempAccess].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
allTempReadInstructions
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
	^self allInstructionsMatching: [:bc | bc isTempRead].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
allTempWriteInstructions
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
	^self allInstructionsMatching: [:bc | bc isTempStore].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
ir
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
	^self.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
method
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
	^self.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
numArgs
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   106
	^ self numRargs
10
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
   107
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
   108
    "Modified: / 30-03-2009 / 18:47:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
numRargs
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
	^ numRargs
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
10
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
   116
numVars
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
   117
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   118
	^ self tempKeys size - self numRargs
10
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
   119
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
   120
    "Created: / 30-03-2009 / 18:37:47 / Jan Vrany <vranyj1@fel.cvut.cz>"
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
   121
!
0fd549e0c784 First simple block works. See IRBuilderTest>>testBlock_blockTempArg.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 9
diff changeset
   122
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
primitiveNode
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
	^ primitiveNode
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
properties
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
	^properties
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
properties: propDict
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
	properties := propDict.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
startSequence
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
	^ startSequence
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
tempKeys
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
	^ tempKeys
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
tempMap
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
    ^ tempMap
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
tempNames
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
	"All temp names in context order"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
	| varNames |
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
	varNames _ OrderedCollection new.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
	self tempKeys do: [:var | | name |
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
		name _ var asString.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
		"vars are unique but inlined to:do: loop vars may have the same name, so munge the names to make them different"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
		[varNames includes: name] whileTrue: [name _ name, 'X'].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
		varNames add: name.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
	].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
	^ varNames asArray
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
!IRFunction methodsFor:'accessing - defaults'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
defaultCompiledCodeClass
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
    "raise an error: must be redefined in concrete subclass(es)"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
    ^ self subclassResponsibility
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
!IRFunction methodsFor:'debugging support'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
inspector2TabIRCode
45
04a50b0d540a Reduced dependencies to only stx:libbasic and stx:libcomp.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   175
    <inspector2Tab>
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
45
04a50b0d540a Reduced dependencies to only stx:libbasic and stx:libcomp.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   177
    ^(Smalltalk at: #Tools::Inspector2Tab) new
04a50b0d540a Reduced dependencies to only stx:libbasic and stx:libcomp.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   178
        label: 'IR Code';
04a50b0d540a Reduced dependencies to only stx:libbasic and stx:libcomp.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   179
        priority: 75;
04a50b0d540a Reduced dependencies to only stx:libbasic and stx:libcomp.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   180
        text: [ self longPrintString ];
04a50b0d540a Reduced dependencies to only stx:libbasic and stx:libcomp.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   181
        yourself
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
    "Created: / 11-06-2008 / 01:05:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
45
04a50b0d540a Reduced dependencies to only stx:libbasic and stx:libcomp.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   184
    "Modified: / 30-10-2014 / 22:33:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
!IRFunction methodsFor:'decompiling'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
ast
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
	^ IRDecompiler new decompileIR: self
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
!IRFunction methodsFor:'initialize'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
initialize
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   198
	primitiveNode := PrimitiveNode primitiveNumber: 0.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   199
	tempKeys := OrderedCollection new.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   200
	tempMap := Dictionary new.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   201
	properties := Dictionary new.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   202
	additionalLiterals := OrderedCollection new.
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
    "Modified: / 30-03-2009 / 11:16:15 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
numRargs: n
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
	numRargs _ n
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
primitiveNode: aPrimitiveNode
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
	primitiveNode _ aPrimitiveNode
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   215
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
startSequence: irSequence
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
	startSequence _ irSequence.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
	irSequence method: self.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   222
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
tempKeys: objects
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   224
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   225
	tempKeys _ objects
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   226
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   227
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   228
!IRFunction methodsFor:'inlining'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   229
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   230
addInstructionsAfter: aCollection
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   231
	| returningSeqs  lastInstr |
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   232
	aCollection ifEmpty: [^self].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   233
	returningSeqs := self allSequences select: [:each | each last isReturn].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   234
	lastInstr := returningSeqs last last.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   235
	lastInstr addInstructionsBefore: aCollection.
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   236
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   237
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   238
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   239
addInstructionsBefore: aCollection
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   240
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   241
	(self startSequence nextSequence first) addInstructionsBefore: aCollection.
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   242
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   243
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   244
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   245
methodForInlining
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   246
	^self removeReturnSelf removeEmptyStart.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   248
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
removeReturn
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
	self allSequences last removeLast.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   252
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   253
removeReturnSelf
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   254
	self removeReturn.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   255
	self allSequences last removeLast.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   256
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   257
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   258
!IRFunction methodsFor:'instructions - helpers'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   259
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   260
pushTemp: tempName in: irFunction level: level
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   261
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   262
    | index kind |
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   263
    index := tempMap
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   264
		at: tempName
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   265
		ifAbsent:
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   266
		    [environmentIr
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   267
			ifNil:[self error:'No such temp: ', tempName]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   268
			ifNotNil:[^environmentIr pushTemp: tempName in: irFunction level: level + 1]].
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   269
    kind := (index <= self numArgs)
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   270
		ifTrue: [self tempArgKindForLevel: level]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   271
		ifFalse:[
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   272
		    index := index - self numArgs.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   273
		    self tempVarKindForLevel: level
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   274
		].
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   275
    ^IRInstruction pushTemp: index kind: kind level: level
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   276
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   277
    "Created: / 30-03-2009 / 11:54:14 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   278
    "Modified: / 30-03-2009 / 13:59:14 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   279
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   280
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   281
storeTemp: tempName in: irFunction level: level
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   282
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   283
    | index kind |
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   284
    index := tempMap
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   285
		at: tempName
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   286
		ifAbsent:
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   287
		    [environmentIr
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   288
			ifNil:[self error:'No such temp: ', tempName]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   289
			ifNotNil:[^environmentIr storeTemp: tempName in: irFunction level: level + 1]].
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   290
    kind := (index <= self numArgs)
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   291
		ifTrue: [self tempArgKindForLevel: level]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   292
		ifFalse:[
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   293
		    index := index - self numArgs.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   294
		    self tempVarKindForLevel: level
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   295
		].
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   296
    ^IRInstruction storeTemp: index kind: kind level: level
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   297
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   298
    "Created: / 30-03-2009 / 11:57:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   299
    "Modified: / 30-03-2009 / 13:59:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   300
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   301
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   302
tempArgKindForLevel: level
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   303
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   304
    ^self subclassResponsibility
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   305
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   306
    "Created: / 30-03-2009 / 11:58:15 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   307
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   308
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   309
tempVarKindForLevel: level
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   310
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   311
    ^self subclassResponsibility
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   312
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   313
    "Created: / 30-03-2009 / 11:58:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   314
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   315
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   316
!IRFunction methodsFor:'mapping'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   317
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   318
sourceMap
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   319
    "Return a mapping from bytecode pcs to source code ranges"
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   320
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   321
    |start map|
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   322
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   323
    "Besides getting start position, make sure bytecodeIndices are filled in"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   324
    start := self compiledCode initialPC - 1.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   325
    map := OrderedCollection new.
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   326
    self allSequences do:[:seq |
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   327
	seq do:[:instr |
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   328
	    |node|
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   329
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   330
	    ((node := instr sourceNode) notNil
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   331
		and:[
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   332
		    node debugHighlightStart notNil
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   333
			and:[ node debugHighlightStop notNil and:[ instr bytecodeIndex notNil ] ]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   334
		])
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   335
		    ifTrue:[
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   336
			map add:instr bytecodeIndex + start
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   337
				    -> (node debugHighlightStart to:node debugHighlightStop)
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   338
		    ]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   339
	]
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   340
    ].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   341
    ^ map
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   342
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   343
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   344
!IRFunction methodsFor:'optimizing'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   345
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   346
absorbConstantConditionalJumps
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   347
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   348
	startSequence absorbConstantConditionalJumps: IdentitySet new
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   349
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   350
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   351
absorbJumpsToSingleInstrs
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   352
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   353
	startSequence absorbJumpToSingleInstr: IdentitySet new
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   354
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   355
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   356
absorbSinglePredecessor
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   357
	| predecessor |
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   358
	startSequence
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   359
		detectSinglePredecessor: (predecessor := IdentityDictionary new)
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   360
		seen: IdentitySet new.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   361
	startSequence collapseSinglePredecessor: predecessor seen: IdentitySet new
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   362
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   363
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   364
maxOrderNumber
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   365
	maxOrderNumber ifNil: [
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   366
		maxOrderNumber := self startSequence orderNumber.
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   367
		self startSequence withAllSuccessorsDo: [:seq | maxOrderNumber := maxOrderNumber max: seq orderNumber].
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   368
	].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   369
	^ maxOrderNumber.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   370
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   371
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   372
newSeq
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   373
	maxOrderNumber _ self maxOrderNumber  +1.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   374
	^ IRSequence new  orderNumber:maxOrderNumber
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   375
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   376
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   377
optimize
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   378
	self removeEmptyStart.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   379
	self absorbJumpsToSingleInstrs.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   380
	self absorbConstantConditionalJumps.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   381
	self absorbJumpsToSingleInstrs
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   382
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   383
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   384
removeEmptyStart
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   385
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   386
	startSequence size = 1 ifTrue: [
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   387
		"startSeq is just unconditional jump, forget it"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   388
		startSequence _ startSequence last destination].
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   389
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   390
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   391
!IRFunction methodsFor:'printing'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   392
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   393
longPrintOn: stream
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   394
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   395
	IRPrinter new
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   396
		indent: 0;
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   397
		stream: stream;
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   398
		interpret: self
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   399
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   400
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   401
longPrintString
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   402
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   403
    | s |
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   404
    s := String new writeStream.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   405
    self longPrintOn: s.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   406
    ^s contents.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   407
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   408
    "Created: / 11-06-2008 / 01:05:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   409
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   410
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   411
!IRFunction methodsFor:'testing'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   412
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   413
isIRClosure
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   414
    ^ false
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   415
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   416
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   417
isIRMethod
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   418
    ^ false
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   419
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   420
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   421
isSend
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   422
	^false.
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   423
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   424
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   425
!IRFunction methodsFor:'translating'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   426
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   427
bytecodes
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   428
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   429
	|translator|
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   430
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   431
	^ compiledCode isNil
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   432
	    ifTrue:[
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   433
		translator := IRTranslator new.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   434
		translator interpret: self.
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   435
		translator bytecodes
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   436
	    ]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   437
	    ifFalse: [compiledCode byteCode].
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   438
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   439
    "Rewrited due to compilation error: Fatal: [bytecodes 10] block not prescanned inline "
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   440
"/        ^ compiledCode
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   441
"/            ifNotNil:
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   442
"/                [compiledCode byteCode]
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   443
"/            ifNil:
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   444
"/                [IRTranslator new
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   445
"/                    interpret: self;
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   446
"/                    bytecodes]
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   447
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   448
    "Created: / 03-11-2008 / 08:38:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   449
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   450
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   451
compiledCode
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   452
    ^ compiledCode
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   453
	ifNil:[ self compiledCodeUsing:self defaultCompiledCodeClass ]
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   454
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   455
    "Created: / 30-03-2009 / 16:34:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   456
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   457
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   458
compiledCodeUsing:aCompiledCodeClass
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   459
    ^ compiledCode := (IRTranslator new)
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   460
		interpret:self;
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   461
		compiledCodeUsing:aCompiledCodeClass
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   462
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   463
    "Created: / 11-06-2008 / 11:06:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   464
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   465
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   466
literals
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   467
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   468
	^(IRTranslator new
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   469
	    interpret: self;
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   470
	    literals)
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   471
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   472
    "Created: / 03-11-2008 / 09:08:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   473
!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   474
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   475
setCompiledCode:aCompiledCode
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   476
    compiledCode := aCompiledCode
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   477
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   478
    "Created: / 11-06-2008 / 11:05:57 / Jan Vrany <vranyj1@fel.cvut.cz>"
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   479
! !
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   480
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   481
!IRFunction class methodsFor:'documentation'!
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   482
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   483
version_CVS
41
f3898a3b378d Package renamed from cvut:stx/goodies/newcompiler to ctu:ircompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   484
    ^ 'Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRFunction.st,v 1.4 2009/10/08 11:59:08 fm Exp '
23
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   485
!
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   486
377bc46cad12 Moved to package cvut:stx/goodies/newcompiler to be in sync with eXept
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 21
diff changeset
   487
version_SVN
37
be8c2dd09dff Build files regenerated
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   488
    ^ '$Id::                                                                                                                        $'
9
04518c7fb91c Initial support for closures.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   489
! !
42
acdc3ec6d152 Better class category name - IR Compiler-*
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 41
diff changeset
   490