Spaces:
Running
Running
File size: 1,023 Bytes
8f3f8db |
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 |
translating builtins
generateAsIfVarAsValue: aNode on: aStream indent: anInteger
| cName fName class index fetchNode |
cName := String streamContents:
[:scStr | self emitJSExpression: aNode args first on: scStr].
class := Smalltalk
at: (cName asSymbol)
ifAbsent: [nil].
(class isNil not and: [class isBehavior]) ifFalse:
[^self error: 'first arg must identify class'].
fName := aNode args second value.
index := class allInstVarNames
indexOf: fName
ifAbsent: [^self error: 'second arg must be instVar'].
fetchNode := TSendNode new
setSelector: #fetchPointer:ofObject:
receiver: (TVariableNode new setName: 'interpreterProxy')
arguments: (Array
with: (TConstantNode new setValue: index - 1)
with: aNode receiver).
cName := aNode args third nameOrValue.
class := Smalltalk
at: (cName asSymbol)
ifAbsent: [nil].
(class isNil not and: [class isBehavior]) ifFalse:
[^self error: 'third arg must identify class'].
class jscg: self generateCoerceToValueFrom: fetchNode on: aStream
|