Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!math.fu-berlin.de!opal!fauern!unido!laura!nermal!huba From: huba@ls5.informatik.uni-dortmund.de (Hubert Baumeister) Newsgroups: comp.lang.smalltalk Subject: Re: SmallTalk Methods - from Self Documenting to Cryptic Message-ID: <3129@laura.UUCP> Date: 28 Mar 91 10:26:29 GMT References: <1986@gemini.cs.nps.navy.mil> <1260003@hpcc01.HP.COM> Sender: news@laura.UUCP Reply-To: huba@ls5.informatik.uni-dortmund.de (Hubert Baumeister) Organization: University of Dortmund, Germany Lines: 125 In article <1260003@hpcc01.HP.COM>, takamine@hpcc01.HP.COM (Derek Takamine) writes: |> I believe you are experiencing a stuck 'left shift' hack syndrome. |> If you look in CompiledCode>>getSourceForUserIfNone: method you'll |> see a nifty peice of code that is great for intermittent debugging, |> among other uses. I would guess that you had accidently hit your left |> shit on your Mac keyboard while you clicked on a method in the |> Browser. Now, for some unknown reason, it is always in that mode (maybe |> it suposed to act like a toggle?) Try holding down the left shift key |> again while clicking on a method. At least in Smalltalk-80 >= v2.2 left shift is not a toggle. The bytecodes will be decompiled when you press the left shift key while selecting. This is useful when your changes file is lost or when your changes file is corruped so that the pointers in the image point to wrong places in the changes file. There is to my knowledge only one way to always display the decompiled version of a method, that is when SourcesFiles is nil. If SourceFiles is not nil then selecting a method will result in an notifier when SourcesFiles at: i is nil or points to a nonexistent file. |> |> By the way, whats being displayed in your browser now is a text representation |> of the compiled code. This is how the byte code interpreter interprets |> your method. It's useful if you are trying to optimize performance of |> your method. What's being displayed is the source code reconstructed from the bytecodes. This restructed code can be than again compiled. In most cases this code looks exactly as the original source code, except for certain variable names and comments. If you really want to see a symbolic representation of the bytecodes then use ( compiledMethodAt: ) symbolic e.g. for the method DocumentBrowser>rename you will get (Smalltalk-80 r4.0) original: rename "Rename the currently viewed document." | section title | self changeRequest ifFalse: [^self]. section _ selection isNil ifTrue: [document] ifFalse: [selection]. title _ DialogView request: 'new name' initialAnswer: section title copy. title = '' ifTrue: [^self]. selection isNil ifTrue: [document title: title. self changed: #windowLabel with: title] ifFalse: [selection title: title. self changed: #document] decompiled (left shift select) rename | t1 t2 | self changeRequest ifFalse: [^self]. t1 := selection isNil ifTrue: [document] ifFalse: [selection]. (t2 := DialogView request: 'new name' initialAnswer: t1 title copy) = '' ifTrue: [^self]. selection isNil ifTrue: [document title: t2. self changed: #windowLabel with: t2] ifFalse: [selection title: t2. self changed: #document]. ^self Bytecode "assembler": (DocumentBrowser compiledMethodAt: #rename) symbolic 'normal CompiledMethod numArgs=0 numTemps=2 frameSize=12 literals: ({DialogView} ''new name'' #title #request:initialAnswer: '''' #title: #windowLabel #changed:with: #document ) 1 <44> push self 2 non-immediate send changeRequest 4 jump true 7 6 <60> push self; return 7 <02> push inst 2 8 send isNil 9 jump false 12 10 <01> push inst 1 11 <6B> jump 13 12 <02> push inst 2 13 <4C> store local 0; pop 14 <34> push DialogView 15 <1D> push ''new name'' 16 <10> push local 0 17 <72> send title 18 send copy 20 <93> send request:initialAnswer: 21 <4D> store local 1; pop 22 <11> push local 1 23 <20> push '''' 24 send = 25 jump false 27 26 <60> push self; return 27 <02> push inst 2 28 send isNil 29 jump false 42 31 <01> push inst 1 32 <11> push local 1 33 <85> send title: 34 <45> pop; push self 35 <22> push #windowLabel 36 <11> push local 1 37 non-immediate send changed:with: 39 <66> pop 40 jump 50 42 <02> push inst 2 43 <11> push local 1 44 <85> send title: 45 <45> pop; push self 46 <24> push #document 47 non-immediate send changed: 49 <66> pop 50 <60> push self; return ' Hubert Baumeister (huba@ls5.informatik.uni-dortmund.de)