Spaces:
Running
Running
File size: 1,454 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 30 31 32 33 34 35 36 |
utilities
addMethodFor: aClass selector: selector
"Add the given method to the code base and answer its translation
or nil if it shouldn't be translated."
| method tmethod |
method := aClass compiledMethodAt: selector.
method requiresConcreteImplementation ifTrue: [abstractDeclarations add: selector].
method isAbstract ifTrue: [^nil].
(method pragmaAt: #doNotGenerate) ifNotNil: [^nil].
"process optional methods by interpreting the argument to the option: pragma as either
a Cogit class name or a class variable name or a variable name in VMBasicConstants."
(method pragmaAt: #option:) ifNotNil:
[:pragma| | key |
key := pragma argumentAt: 1.
"((Cogit withAllSubclasses anySatisfy: [:c| c name = key])
and: [VMClass getVMMaker cogitClassName ~= key]) ifTrue:
[^nil]."
(aClass bindingOf: key) ifNotNil:
[:binding|
binding value ifFalse: [^nil]].
(VMBasicConstants bindingOf: key) ifNotNil:
[:binding|
binding value ifFalse: [^nil]]].
tmethod := self compileToJSMethodSelector: selector in: aClass.
tmethod hasDoNotGenerateStatement ifTrue: [^nil].
self addMethod: tmethod.
"If the method has a macro then add the macro. But keep the method
for analysis purposes (e.g. its variable accesses)."
(method pragmaAt: #cmacro:) ifNotNil:
[:pragma|
self addMacro: (pragma argumentAt: 1) for: selector].
(method propertyValueAt: #cmacro:) ifNotNil:
[:macro|
self addMacro: macro for: selector].
^tmethod |