Hi: On 17 Jan 2012, at 09:47, Mariano Martinez Peck wrote:
Stefan, another approach would be to store the source code in the compiled method trailer. Looks like everything is there already, but it does not seem to work stable enough.
With the code below, this should work: (do not apply the change to getSourceFromFile!!) ------------- |trailer source m | m := (Gofer>>#load). trailer := m trailer. source := m getSource. trailer sourceCode: source. m recompileWithTrailer: trailer. ------------- Here the code: ------------- !Behavior methodsFor: 'compiling' stamp: 'StefanMarr 1/17/2012 15:14' prior: 82391250! recompile: selector from: oldClass withNewTrailer: trailer "Compile the method associated with selector in the receiver's method dictionary." "ar 7/10/1999: Use oldClass compiledMethodAt: not self compiledMethodAt:" | method methodNode | method := oldClass compiledMethodAt: selector. methodNode := self compilerClass new compile: (oldClass sourceCodeAt: selector) in: self notifying: nil ifFail: [^ self]. "Assume OK after proceed from SyntaxError" selector == methodNode selector ifFalse: [self error: 'selector changed!!']. self basicAddSelector: selector withMethod: (methodNode generate: trailer). ! ! !Behavior methodsFor: 'compiling' stamp: 'StefanMarr 1/17/2012 15:15' prior: 82391969! recompile: selector from: oldClass | method | method := oldClass compiledMethodAt: selector. self recompile: selector from: oldClass withNewTrailer: method trailer. ! ! !CompiledMethod methodsFor: 'as yet unclassified' stamp: 'StefanMarr 1/17/2012 15:16' prior: 82392229! recompileWithTrailer: trailer self methodClass recompile: self selector from: self methodClass withNewTrailer: trailer.! ! !CompiledMethod methodsFor: 'source code management' stamp: 'StefanMarr 1/17/2012 15:23' prior: 68352220! getSourceFromFile "Read the source code from file, determining source file index and file position from the last 3 bytes of this method." | position source trailer | trailer := self trailer. source := trailer sourceCode. source ifNotNil: [ ^ source ]. (position := self filePosition) = 0 ifTrue: [^ nil]. source := (RemoteString newFileNumber: self fileIndex position: position) string. trailer sourceCode: source. self recompileWithTrailer: trailer. ^ source.! ! ------------- This is unfortunately undebuggable. At least I do not get a debugger (which seems logical if there is something going wrong and recurses in getSource...) Good that we have a stratified system. Best regards Stefan
PS: I will interested if you do it :)
In return, I would really appreciate if you could learn a bit about etiquette and quoting http://www.gweep.ca/~edmonds/usenet/ml-etiquette.html#SECTION000900000000000... And I am apparently not the only one who would like that. See the recent reference to http://emailcharter.org/ -- Stefan Marr Software Languages Lab Vrije Universiteit Brussel Pleinlaan 2 / B-1050 Brussels / Belgium http://soft.vub.ac.be/~smarr Phone: +32 2 629 2974 Fax: +32 2 629 3525