I will read the rest :)

eval: aString
        ^{'return eval(aString);'}
!

visitBlockNode: aNode
        stream nextPutAll: '(function('.
        aNode parameters 
            do: [:each |
                stream nextPutAll: each]
            separatedBy: [stream nextPutAll: ', '].
        stream nextPutAll: '){'.
        aNode nodes do: [:each | self visit: each].
        stream nextPutAll: '})'

visitMethodNode: aNode
        | str currentSelector |
        currentSelector := aNode selector asSelector.
        nestedBlocks := 0.
        earlyReturn := false.
        stream 
            nextPutAll: 'smalltalk.method({', String cr;
            nextPutAll: 'selector: "', aNode selector, '",', String cr;
            nextPutAll: 'source: unescape("', aNode source escaped, '"),', 
String cr;
            nextPutAll: 'fn: function('.
        aNode arguments 
            do: [:each | stream nextPutAll: each]
            separatedBy: [stream nextPutAll: ', '].
        stream 
            nextPutAll: '){', String cr;
            nextPutAll: 'var self=this;', String cr.
        str := stream.
        stream := '' writeStream.
        aNode nodes do: [:each |
            self visit: each].
        earlyReturn ifTrue: [
            str nextPutAll: 'try{'].
        str nextPutAll: stream contents.
        stream := str.
        stream 
            nextPutAll: String cr; 
            nextPutAll: 'return self;'.
        earlyReturn ifTrue: [
            stream nextPutAll: String cr, '} catch(e) {if(e.name === 
''stReturn'' && e.selector === ', currentSelector printString, '){return 
e.fn()} throw(e)}'].
        stream 
            nextPutAll: '}', String cr;
            nextPutAll: '})'

ok now I understand. 

Stef

Reply via email to