[squeak-dev] The Inbox: System-dtl.1164.mcz

David T. Lewis lewis at mail.msen.com
Fri Jun 12 21:40:05 UTC 2020


That's odd. I filed the class in to a new change set, and end up
with no class definition in the change set, that can't be right.

Updated change set attached.

Dave


On Fri, Jun 12, 2020 at 02:09:52PM -0700, tim Rowledge wrote:
> Erk - the changeset you posted doesn't include the class definition and so fails to load. Which makes it really hard to try out...
> 
> > On 2020-06-12, at 2:04 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> > 
> > It works pretty well actually:
> 
> 
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> Strange OpCodes: HCF: Halt and Catch Fire
> 
> 
> 
-------------- next part --------------
'From Squeak6.0alpha of 8 June 2020 [latest update: #19714] on 12 June 2020 at 5:35:30 pm'!
"Change Set:		DoItFirst-dtl
Date:			12 June 2020
Author:			David T Lewis

Be the first thing in the system startup list, and do things that should be done prior to any additional image initialization. If the first image argument is a recognized option, evalutate it. Image arguments are typically preceeded by a '--' token on the command line.

Possible command options:
   -filein {some file names}
   -doit {some strings}
   -evaluate {a single string & write result to stdout & quit"!

Object subclass: #DoItFirst
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'System-Support'!

!DoItFirst commentStamp: 'dtl 6/12/2020 17:29' prior: 0!
Be the first thing in the system startup list, and do things that should be done prior to any additional image initialization. If the first image argument is a recognized option, evalutate it. Image arguments are typically preceeded by a '--' token on the command line.

Possible command options:
   -filein {some file names}
   -doit {some strings}
   -evaluate {a single string & write result to stdout & quit

!


!DoItFirst class methodsFor: 'class initialization' stamp: 'dtl 6/11/2020 18:42'!
initialize

	"DoItFirst initialize"

	Smalltalk addToStartUpList: self before: SmallInteger.! !

!DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 14:41'!
doIt: arguments
	"Evaluate arguments and print the result on stdout, or error message on stderr.
	Exit the image after any error."
	FileStream startUp: true.
	arguments do: [ :arg |
		[FileStream stdout nextPutAll: (Compiler evaluate: arg) asString; lf; flush]
			on: Error
			do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush.
				Smalltalk quitPrimitive ]]! !

!DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 14:35'!
evaluate: arg
	"Evaluate arg and print the result on stdout, or error message on stderr.
	Exit immediately without saving the image."
	FileStream startUp: true.
	[FileStream stdout nextPutAll: (Compiler evaluate: arg) asString; lf; flush]
		on: Error
		do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush ].
	Smalltalk quitPrimitive! !

!DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 15:28'!
fileIn: fileNames
	"File in each named file. On error, print a message to stderr and exit the image."
	FileStream startUp: true.
	fileNames do: [ :arg |
		[ | fs |
		fs := FileStream oldFileNamed: arg.
		FileStream stdout nextPutAll: 'fiie in ', fs asString; lf; flush.
		fs fileIn ]
			on: Error
			do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush.
				Smalltalk quitPrimitive ]]! !

!DoItFirst class methodsFor: 'system startup' stamp: 'dtl 6/12/2020 14:47'!
startUp: resuming
	resuming ifTrue: [ | args |
		args := Smalltalk arguments.
		args size > 1
			ifTrue: [ args first
				caseOf: {
					[ '-doit' ] -> [ self doIt: args allButFirst ] .
					[ '--doit' ] -> [ self doIt: args allButFirst ] .
					[ '-evaluate' ] -> [ self evaluate: args second ] .
					[ '--evaluate' ] -> [ self evaluate: args second ] .
					[ '-filein' ] -> [ self fileIn: args allButFirst ] .
					[ '--filein' ] -> [ self fileIn: args allButFirst ]
				}
				otherwise: []]]
! !

DoItFirst initialize!
-------------- next part --------------
'From Squeak6.0alpha of 8 June 2020 [latest update: #19714] on 12 June 2020 at 5:30:03 pm'!
Object subclass: #DoItFirst
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'System-Support'!
!DoItFirst commentStamp: 'dtl 6/12/2020 17:29' prior: 0!
Be the first thing in the system startup list, and do things that should be done prior to any additional image initialization. If the first image argument is a recognized option, evalutate it. Image arguments are typically preceeded by a '--' token on the command line.

Possible command options:
   -filein {some file names}
   -doit {some strings}
   -evaluate {a single string & write result to stdout & quit

!


"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

DoItFirst class
	instanceVariableNames: ''!

!DoItFirst class methodsFor: 'class initialization' stamp: 'dtl 6/11/2020 18:42'!
initialize

	"DoItFirst initialize"

	Smalltalk addToStartUpList: self before: SmallInteger.! !


!DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 14:41'!
doIt: arguments
	"Evaluate arguments and print the result on stdout, or error message on stderr.
	Exit the image after any error."
	FileStream startUp: true.
	arguments do: [ :arg |
		[FileStream stdout nextPutAll: (Compiler evaluate: arg) asString; lf; flush]
			on: Error
			do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush.
				Smalltalk quitPrimitive ]]! !

!DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 14:35'!
evaluate: arg
	"Evaluate arg and print the result on stdout, or error message on stderr.
	Exit immediately without saving the image."
	FileStream startUp: true.
	[FileStream stdout nextPutAll: (Compiler evaluate: arg) asString; lf; flush]
		on: Error
		do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush ].
	Smalltalk quitPrimitive! !

!DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 15:28'!
fileIn: fileNames
	"File in each named file. On error, print a message to stderr and exit the image."
	FileStream startUp: true.
	fileNames do: [ :arg |
		[ | fs |
		fs := FileStream oldFileNamed: arg.
		FileStream stdout nextPutAll: 'fiie in ', fs asString; lf; flush.
		fs fileIn ]
			on: Error
			do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush.
				Smalltalk quitPrimitive ]]! !


!DoItFirst class methodsFor: 'system startup' stamp: 'dtl 6/12/2020 14:47'!
startUp: resuming
	resuming ifTrue: [ | args |
		args := Smalltalk arguments.
		args size > 1
			ifTrue: [ args first
				caseOf: {
					[ '-doit' ] -> [ self doIt: args allButFirst ] .
					[ '--doit' ] -> [ self doIt: args allButFirst ] .
					[ '-evaluate' ] -> [ self evaluate: args second ] .
					[ '--evaluate' ] -> [ self evaluate: args second ] .
					[ '-filein' ] -> [ self fileIn: args allButFirst ] .
					[ '--filein' ] -> [ self fileIn: args allButFirst ]
				}
				otherwise: []]]
! !


DoItFirst initialize!


More information about the Squeak-dev mailing list