Open melkyades opened 1 year ago
Surprisingly, V8 is not very good at inlining things like this:
Boolean.prototype.ifTrue_ = function(closure) { if (this == true) { return closure() } else {return nil } } function x (aBoolean) { aBoolean.ifTrue_(() => { console.log('it is true!') }); }
So we have to improve our transliterator to generate code like this:
function x (aBoolean) { if (aBoolean) { console.log('it is true!'); } }
This is complex because usually ifTrue: is used like this:
a := aBoolean ifTrue: [x] ifFalse: [y]
or worse:
a := aBoolean ifTrue: [^self].
The same applies to ifTrue:/ifFalse:/ifTrue:ifFalse:/whileTrue/whileFalse/whileTrue:/whileFalse:/ifNil:/ifNotNil: among others
ifTrue:/ifFalse:/ifTrue:ifFalse:/whileTrue/whileFalse/whileTrue:/whileFalse:/ifNil:/ifNotNil:
Instead of directly generating code, I think we may want to first generate an intermediate Javascript AST, and then write that down. See https://hal.archives-ouvertes.fr/hal-02297860/document
Surprisingly, V8 is not very good at inlining things like this:
So we have to improve our transliterator to generate code like this:
This is complex because usually ifTrue: is used like this:
or worse:
The same applies to
ifTrue:/ifFalse:/ifTrue:ifFalse:/whileTrue/whileFalse/whileTrue:/whileFalse:/ifNil:/ifNotNil:
among othersInstead of directly generating code, I think we may want to first generate an intermediate Javascript AST, and then write that down. See https://hal.archives-ouvertes.fr/hal-02297860/document