[Pharo-dev] Compiler: add the concept of a Production Environment

Marcus Denker marcus.denker at inria.fr
Wed Jul 3 04:44:22 EDT 2019


Hi,

We added support for setting a “production environment” for the compiler:

When compiling, there might be the case that the result of the compiler (the compiledMethod) should not be an instance of the class CompiledMethod from the environment
in which we compile, but from some other environment.

(e.g. imagine you have multiple environments and want to cross cross compile)

This PR adds the concept of a productionEnvironment and enables it for CompiledMethod.
(other use cases might make sense, too, for example all the literals in the CompiledMethod, this is future work but can be done similarly by handing the context into the Scanner)

This is our test for CompiledMethod:

testCompileWithProductionEnvironment
| environment method return |
environment := {#CompiledMethod -> MyCompiledMethodForTesting} asDictionary.
method := Smalltalk compiler
	productionEnvironment: environment;
	compile: 'tt ^1+2'.

self assert: method class equals: MyCompiledMethodForTesting.			
return := method valueWithReceiver: nil arguments: #().
self assert: return equals: 3.

As one can see, the produces compiled method of the Compiler is an instance of our class.

PR needs a Review: https://github.com/pharo-project/pharo/pull/3749/files





More information about the Pharo-dev mailing list