Path: katsu From: katsu@sra.co.jp (WATANABE Katsuhiro) Message-ID: Date: 02 Mar 1994 14:10:51 GMT Organization: Software Research Associates, Inc.,Japan In-reply-to: katsu@sra.co.jp's message of 02 Mar 1994 13:17:57 GMT Newsgroups: fj.lang.st80 Subject: Re: The Smalltalk Textbook 20 Distribution: fj References: 私の投稿した記事 で > EngiBrowser (Smalltalk TextBook 20) >  ここで,あるクラスのメッセージ(メソッド)のソースコードを得てみましょ > う。 > > Point sourceCodeAt: #x > >  sourceCodeAt:をクラスに送ってソースコードを得るときに,シフトキーを > 押しておくと,デコンパイル(Smalltalk仮想マシンのバイトコードを逆コンパ > イル)したソースコードが得られます。デコンパイルソースコードは,コメン > トなどが拭い取られ,引数や変数に付けた名前がtで始まる文字列に置き換わ > り,とても読みにくいコードです。このデコンパイラは,ソースファイルの在 > りかが不明な(*.sourcesまたは*.changesが分からない)場合に,自動的に働く > ようになっています。シフトキーの押下は,その状況を一時的に作りだすので > す。  上のような理由で、付録10の縁起システム専用ブラウザでシフトキーを押し ながら save sources をすると、デコンパイルされたソースが書き出されてし まいます。これは標準のブラウザで file out する時と同様の仕様です。しか し、縁起ブラウザの save sources のほうはシフトキーを押しながら出すメニュー から出すようになっているので、事故あるいは偶然にシフトキーを押したまま save sources してしまう場合が、ひょっとするとあるかもしれません。  デコンパイルされたソースは書き出したくないという人は、この記事の最後 に付けた code を取り込んでみてください。シフトキーが離されるのを待つよ うになります。 -- 渡邊克宏@SRA 'From Objectworks¥Smalltalk(R), Release 4.1 (J1.2) of 1 September 1992 on 2 March 1994 at 10:13:56 pm'! !EngiBrowser methodsFor: 'private-engi system'! engiCategoryMenu "EngiBrowser flushMenus." | collection boolean size array | EngiCategoryMenu isNil ifTrue: [collection := OrderedCollection new. collection add: 'about Engi System' -> [:aController | EngiSystem about]. collection add: nil. collection add: 'number of classes' -> [:aController | Cursor wait showWhile: [size := EngiSystem classes size]. (PopUpMenu labels: size printString , ' classes') startUp]. collection add: 'number of messages' -> [:aController | Cursor wait showWhile: [array := EngiSystem numberOfMessages]. array at: 1 put: (array at: 1) printString , ' instance messages'. array at: 2 put: (array at: 2) printString , ' class messages'. (PopUpMenu labelArray: array) startUp]. collection add: nil. collection add: 'save sources' -> [:aController | boolean := DialogView confirm: 'Do you want to save sources?' initialAnswer: true. boolean = true ifTrue: [InputState default shiftDown ifTrue: [ Transcript cr; show: 'Please keep shift key releasing.']. [InputState default shiftDown] whileTrue: [aController poll. Processor yield]. EngiSystem save]]. collection add: 'save image' -> [:aController | boolean := DialogView confirm: 'Do you want to save this image?' initialAnswer: true. boolean = true ifTrue: [ObjectMemory saveDialogThenQuit: false]]. collection add: nil. collection add: 'condense changes' -> [:aController | boolean := DialogView confirm: 'Do you want to condense changes?' initialAnswer: false. boolean = true ifTrue: [SourceFileManager default condenseChanges]]. EngiCategoryMenu := EngiMenuMaker fromCollection: collection]. ^EngiCategoryMenu! !