[Modules][Fix] Reloading VMConstruction + others

Henrik Gedenryd h.gedenryd at open.ac.uk
Mon May 20 09:08:21 UTC 2002


Does the attached cs fix the translator problems for you, wrt pool
constants?

> Also, and this is the thing I don't understand, you've changed in
> various places the references to globals residing in the same module by
> a Module @ #(Foo Bar Mumble) reference (for instance refs to Interpreter
> in InterpreterSupportCode and refs to FXBltSimulation in
> FXBltSimulator).
> Why is this necessary for a module in order to be unloaded and loaded
> again? Does this mean we have to qualify every reference to a global
> explicitly?! If not, what are the rules when and where explicit
> references are required?!

These had to be changed because they cause circular dependencies, which
prevent them from being loaded as independent modules if there are
sub/superclass relationships between these modules. Removing the references
in this manner is only necessary in such cases.

In many/most cases, these circularities occur in really non-essential code,
because someone has hacked up a quick solution to some minor problem.
Typically it happens on the class side, where all kinds of odd glue code is
put. Nevertheless, the circularity is there. As we discussed last weekend,
if someone writes an Undeclared facility for sub/superclass relationships
then this won't be a problem any more. And note that this facility could be
made 100% independent of the module code, so no special knowledge is
required.

In the case of the FX classes, it might have been more appropriate to move
the simulator/plugin classes together with the other plugins.

>> fixChessPool converts the chess pool to a module to remove
>> various problems.
> 
> Talking about pools - is there any anticipated way of dealing with the
> issue of providing a module through initialization code?! The question
> is basically, what do you do if you want to provide a (single) file in
> which should contain the appropriated definitions?! Reviewing the
> information on the Swiki it says that you have to convert pools into
> pool modules and describes how to do that in ModuleRefactorer but what
> about people who need some _new_ shared constants?! ;-)

When you store a module the variables defined in it (but not their contents)
are stored with the other definitions. So your initializing code can assume
the variables to exist and just initialize their values. No more Undeclared
voodoo practices necessary.


-------------- next part --------------
'From Squeak3.3alpha of 30 January 2002 [latest update: #4843] on 19 May 2002 at 6:06:59 pm'!
"Change Set:		codegeneratorModuleFix
Date:			19 May 2002
Author:			Henrik Gedenryd

Make plugins use constants from modules instead of pools."!


!CCodeGenerator methodsFor: 'public' stamp: 'hg 5/19/2002 18:05'!
addClass: aClass 
	"Add the variables and methods of the given class to the code base."
	| source |
	self checkClassForNameConflicts: aClass.
	self addClassVarsFor: aClass.
	self addConstantsForClass: aClass.
	variables addAll: aClass instVarNames.
	'Adding Class ' , aClass name , '...'
		displayProgressAt: Sensor cursorPoint
		from: 0
		to: aClass selectors size
		during: [:bar | aClass selectors
				doWithIndex: 
					[:sel :i | 
					bar value: i.
					source _ aClass sourceCodeAt: sel.
					self addMethod: ((Compiler new
							parse: source
							in: aClass
							notifying: nil)
							asTranslationMethodOfClass: self translationMethodClass)]]! !

!CCodeGenerator methodsFor: 'public' stamp: 'hg 5/19/2002 18:04'!
addConstantsForClass: aPluginClass

	aPluginClass constantModules do: [:mod |
		self addConstantsFromModule: mod].! !

!CCodeGenerator methodsFor: 'public' stamp: 'hg 5/19/2002 18:05'!
addConstantsFromModule: aModule 
	"Add the definitions in the given module to the code base as constants."

	aModule exportedNames keysAndValuesDo: [:key :value |
			constants at: key asString 
				put: (TConstantNode new setValue: value)]! !


!InterpreterPlugin class methodsFor: 'translation' stamp: 'hg 5/19/2002 17:50'!
constantModules
	"return a list of modules whose globals should be provided as constants for the code of this plugin"

	^{}! !


!B3DEnginePlugin class methodsFor: 'translation' stamp: 'hg 5/19/2002 17:51'!
constantModules
	"return a list of modules whose globals should be provided as constants for the code of this plugin"

	^{Module @ #(Squeak Balloon3D Engine B3DEngineConstants)}! !


!BalloonEngineBase class methodsFor: 'accessing' stamp: 'hg 5/19/2002 17:59'!
constantModules
	"return a list of modules whose globals should be provided as constants for the code of this plugin"

	^{Module @ #(Squeak Balloon Engine BalloonEngineConstants)}! !


!FFIPlugin class methodsFor: 'accessing' stamp: 'hg 5/19/2002 17:52'!
constantModules
	"return a list of modules whose globals should be provided as constants for the code of this plugin"

	^{Module @ #(Squeak FFI Kernel FFIConstants)}! !


!KlattSynthesizerPlugin class methodsFor: 'translation' stamp: 'hg 5/19/2002 18:00'!
constantModules
	"return a list of modules whose globals should be provided as constants for the code of this plugin"

	^{Module @ #(Squeak Speech Klatt KlattResonatorIndices)}! !



More information about the Squeak-dev mailing list