-
-
Notifications
You must be signed in to change notification settings - Fork 346
/
RFValueReification.class.st
128 lines (101 loc) · 3.42 KB
/
RFValueReification.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"
value
Assignment: the orginal value for before, new value for after.
Variables: current value (same for before and after)
Message: result of the message, only availabe for *after* links.
Return: what will be returned
"
Class {
#name : #RFValueReification,
#superclass : #RFReification,
#category : #'Reflectivity-Reifications'
}
{ #category : #'plugin interface' }
RFValueReification class >> entities [
^{RBVariableNode. RBAssignmentNode. RBReturnNode. RBMessageNode . RBLiteralValueNode . RBLiteralArrayNode. RBArrayNode . RBMethodNode . LiteralVariable . Slot}
]
{ #category : #'plugin interface' }
RFValueReification class >> key [
^#value
]
{ #category : #generate }
RFValueReification >> genForInstanceVariableSlot [
"entity in this case is the binding of the instance variable"
^ RBMessageNode
receiver: (RFLiteralVariableNode value: entity)
selector: #read:
arguments: {(RBVariableNode named: 'self')}
]
{ #category : #generate }
RFValueReification >> genForLiteralVariable [
"entity in this case is the binding of the literal variable"
^RFLiteralVariableNode value: entity value
]
{ #category : #generate }
RFValueReification >> genForRBArrayNode [
^RBVariableNode named: #RFReifyValueVar
]
{ #category : #generate }
RFValueReification >> genForRBAssignmentNode [
"#value for Assignemnt is the old value, is that what we want?"
^RBVariableNode named: entity variable name
]
{ #category : #generate }
RFValueReification >> genForRBLiteralArrayNode [
^RBLiteralArrayNode value: entity value
]
{ #category : #generate }
RFValueReification >> genForRBLiteralValueNode [
^RBLiteralValueNode value: entity value
]
{ #category : #generate }
RFValueReification >> genForRBMessageNode [
^RBVariableNode named: #RFReifyValueVar
]
{ #category : #generate }
RFValueReification >> genForRBMethodNode [
^RBTemporaryNode named: #RFValueReificationVar
]
{ #category : #generate }
RFValueReification >> genForRBReturnNode [
^RBVariableNode named: #RFReifyValueVar
]
{ #category : #generate }
RFValueReification >> genForRBVariableNode [
entity isGlobal ifTrue: [^RFLiteralVariableNode value: entity binding value].
^RBVariableNode named: entity name.
]
{ #category : #generate }
RFValueReification >> postamble: aNode [
(aNode isKindOf: RBProgramNode) ifFalse: [ ^#() ].
aNode isMessage ifTrue: [^RFStoreIntoTempNode named: 'RFReifyValueVar'. ].
^super postamble: aNode.
]
{ #category : #generate }
RFValueReification >> preamble: aNode [
(aNode isKindOf: RBProgramNode) ifFalse: [ ^#() ].
aNode isReturn ifTrue: [^RFStoreIntoTempNode named: #RFReifyValueVar].
aNode isDynamicArray ifTrue: [ ^self preambleForArray: aNode ].
^#().
]
{ #category : #generate }
RFValueReification >> preambleForArray: aNode [
| preamble arguments |
preamble := OrderedCollection new.
arguments := OrderedCollection new.
(1 to: aNode size) reverseWithIndexDo: [:each :index |
| name |
name := 'RFArg', index asString, 'RFReification'.
preamble add: (RFStorePopIntoTempNode named: name).
].
self flag: #TBD. "for #instead we do not need to build the stack up again as the array creation bytecode is missing"
(1 to: aNode size) withIndexDo: [:each :index |
| name |
name := 'RFArg', index asString, 'RFReification'.
arguments add: (RBTemporaryNode named: name).
].
preamble addAll: (RBArrayNode statements: arguments).
preamble add: (RFStorePopIntoTempNode named: 'RFReifyValueVar').
preamble addAll: arguments.
^ preamble
]