@@ -46,7 +46,7 @@ public AddressedInstructions Visit(ArrayLiteral visitable)
4646 {
4747 var arraySize = visitable . Expressions . Count ;
4848
49- var arrayName = visitable . Id ;
49+ var arrayName = new Name ( visitable . Id ) ;
5050 var createArray = new CreateArray ( arrayName , arraySize ) ;
5151
5252 var result = new AddressedInstructions { createArray } ;
@@ -64,7 +64,7 @@ public AddressedInstructions Visit(ArrayLiteral visitable)
6464 else
6565 {
6666 result . AddRange ( expression . Accept ( This ) ) ;
67- var last = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
67+ var last = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
6868 result . Add ( new IndexAssignment ( arrayName , index , last ) ) ;
6969 }
7070 }
@@ -75,7 +75,7 @@ public AddressedInstructions Visit(ArrayLiteral visitable)
7575 public AddressedInstructions Visit ( ObjectLiteral visitable )
7676 {
7777 var objectId = visitable . Id ;
78- var createObject = new CreateObject ( objectId ) ;
78+ var createObject = new CreateObject ( new Name ( objectId ) ) ;
7979
8080 var result = new AddressedInstructions { createObject } ;
8181
@@ -89,7 +89,7 @@ public AddressedInstructions Visit(ObjectLiteral visitable)
8989
9090 public AddressedInstructions Visit ( Property visitable )
9191 {
92- var objectId = visitable . Object . Id ;
92+ var objectId = new Name ( visitable . Object . Id ) ;
9393
9494 var ( id , expression ) = visitable ;
9595 var propertyId = new Constant ( id ) ;
@@ -101,7 +101,7 @@ public AddressedInstructions Visit(Property visitable)
101101 _valueDtoConverter . Convert ( primary . ToValueDto ( ) ) ) ] ;
102102
103103 var instructions = expression . Accept ( This ) ;
104- var last = new Name ( instructions . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
104+ var last = instructions . OfType < Simple > ( ) . Last ( ) . Left ! ;
105105 instructions . Add ( new DotAssignment ( objectId , propertyId , last ) ) ;
106106
107107 return instructions ;
@@ -113,7 +113,7 @@ public AddressedInstructions Visit(UnaryExpression visitable)
113113 return [ new Simple ( visitable . Operator , _valueDtoConverter . Convert ( primary . ToValueDto ( ) ) ) ] ;
114114
115115 var result = visitable . Expression . Accept ( This ) ;
116- var last = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
116+ var last = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
117117 result . Add ( new Simple ( visitable . Operator , last ) ) ;
118118
119119 return result ;
@@ -122,7 +122,7 @@ public AddressedInstructions Visit(UnaryExpression visitable)
122122 public AddressedInstructions Visit ( BinaryExpression visitable )
123123 {
124124 if ( visitable is { Left : IdentifierReference arr , Right : PrimaryExpression primary , Operator : "::" } )
125- return [ new RemoveFromArray ( arr . Name , index : _valueDtoConverter . Convert ( primary . ToValueDto ( ) ) ) ] ;
125+ return [ new RemoveFromArray ( new Name ( arr ) , index : _valueDtoConverter . Convert ( primary . ToValueDto ( ) ) ) ] ;
126126
127127 var result = new AddressedInstructions ( ) ;
128128 IValue left , right ;
@@ -132,15 +132,15 @@ public AddressedInstructions Visit(BinaryExpression visitable)
132132 else
133133 {
134134 result . AddRange ( visitable . Left . Accept ( This ) ) ;
135- left = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
135+ left = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
136136 }
137137
138138 if ( visitable . Right is PrimaryExpression primaryRight )
139139 right = _valueDtoConverter . Convert ( primaryRight . ToValueDto ( ) ) ;
140140 else
141141 {
142142 result . AddRange ( visitable . Right . Accept ( This ) ) ;
143- right = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
143+ right = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
144144 }
145145
146146 result . Add ( new Simple ( left , visitable . Operator , right ) ) ;
@@ -154,15 +154,15 @@ public AddressedInstructions Visit(CastAsExpression visitable)
154154 return [ new AsString ( _valueDtoConverter . Convert ( primary . ToValueDto ( ) ) ) ] ;
155155
156156 var result = visitable . Expression . Accept ( This ) ;
157- var last = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
157+ var last = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
158158 result . Add ( new AsString ( last ) ) ;
159159
160160 return result ;
161161 }
162162
163163 public AddressedInstructions Visit ( WithExpression visitable )
164164 {
165- var objectId = visitable . ObjectLiteral . Id ;
165+ var objectId = new Name ( visitable . ObjectLiteral . Id ) ;
166166 var createObject = new CreateObject ( objectId ) ;
167167
168168 var result = new AddressedInstructions { createObject } ;
@@ -188,7 +188,7 @@ public AddressedInstructions Visit(WithExpression visitable)
188188
189189 var copyFrom = visitable . Expression is IdentifierReference objectIdent
190190 ? new Name ( objectIdent )
191- : new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
191+ : result . OfType < Simple > ( ) . Last ( ) . Left ! ;
192192
193193 for ( var i = 0 ; i < visitable . ComputedCopiedProperties . Count ; i ++ )
194194 {
@@ -214,7 +214,7 @@ public AddressedInstructions Visit(ConditionalExpression visitable)
214214 else
215215 {
216216 result . AddRange ( visitable . Test . Accept ( This ) ) ;
217- var last = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
217+ var last = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
218218 result . Add ( new IfNotGoto ( last , startBlockLabel ) ) ;
219219 }
220220
@@ -227,7 +227,7 @@ public AddressedInstructions Visit(ConditionalExpression visitable)
227227 result . OfType < Simple > ( ) . Last ( ) . Left = temp ;
228228 result . Add ( new EndBlock ( BlockType . Condition , blockId ) , endBlockLabel . Name ) ;
229229
230- result . Add ( new Simple ( new Name ( temp ) ) ) ;
230+ result . Add ( new Simple ( temp ) ) ;
231231
232232 return result ;
233233 }
@@ -241,14 +241,14 @@ public AddressedInstructions Visit(AssignmentExpression visitable)
241241 if ( last is IWriteToComplexData assignment )
242242 result . Add ( assignment . ToSimple ( ) ) ;
243243 else
244- result . Add ( new Simple ( new Name ( last . Left ! ) ) ) ;
244+ result . Add ( new Simple ( last . Left ! ) ) ;
245245 }
246246
247247 if ( visitable . Destination . Empty ( ) )
248- result . OfType < Simple > ( ) . Last ( ) . Left = visitable . Destination . Id ;
248+ result . OfType < Simple > ( ) . Last ( ) . Left = new Name ( visitable . Destination . Id ) ;
249249 else
250250 {
251- var last = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
251+ var last = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
252252 result . AddRange ( visitable . Destination . Accept ( This ) ) ;
253253 var lastRead = result . OfType < IReadFromComplexData > ( ) . Last ( ) ;
254254 result . Replace ( lastRead . ToInstruction ( ) , lastRead . ToAssignment ( last ) ) ;
@@ -270,7 +270,7 @@ public AddressedInstructions Visit(DotAccess visitable)
270270 return [ new DotRead ( new Name ( lhs . Id ) , right ) ] ;
271271
272272 var result = visitable . Prev ? . Accept ( This ) ?? [ ] ;
273- var left = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
273+ var left = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
274274 result . Add ( new DotRead ( left , right ) ) ;
275275
276276 return result ;
@@ -287,15 +287,15 @@ public AddressedInstructions Visit(IndexAccess visitable)
287287 else
288288 {
289289 result . AddRange ( visitable . Index . Accept ( This ) ) ;
290- right = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
290+ right = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
291291 }
292292
293293 if ( ! visitable . HasPrev ( ) && visitable . Parent is LeftHandSideExpression lhs )
294294 result . Add ( new IndexRead ( new Name ( lhs . Id ) , right ) ) ;
295295 else
296296 {
297297 result . AddRange ( visitable . Prev ? . Accept ( This ) ?? [ ] ) ;
298- var left = new Name ( result . OfType < Simple > ( ) . Last ( ) . Left ! ) ;
298+ var left = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
299299 result . Add ( new IndexRead ( left , right ) ) ;
300300 }
301301
@@ -320,8 +320,8 @@ public AddressedInstructions Visit(CallExpression visitable)
320320
321321 if ( methodCall )
322322 {
323- var caller = result . Any ( ) ? result . OfType < Simple > ( ) . Last ( ) . Left ! : visitable . Id ;
324- result . Add ( new PushParameter ( new Name ( caller ) ) ) ;
323+ var caller = result . Count > 0 ? result . OfType < Simple > ( ) . Last ( ) . Left ! : new Name ( visitable . Id ) ;
324+ result . Add ( new PushParameter ( caller ) ) ;
325325 }
326326
327327 for ( var i = 0 ; i < visitable . Parameters . Count ; i ++ )
@@ -333,7 +333,7 @@ public AddressedInstructions Visit(CallExpression visitable)
333333 {
334334 result . AddRange ( expr . Accept ( This ) ) ;
335335 var id = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
336- result . Add ( new PushParameter ( new Name ( id ) ) ) ;
336+ result . Add ( new PushParameter ( id ) ) ;
337337 }
338338 }
339339
0 commit comments