Restricting the scope for the compiler?

Andreas Raab Andreas.Raab at gmx.de
Sat Jul 13 19:19:45 UTC 2002


Tim,

Trivial to do - just implement #scopeHas:ifTrue: in the right place and
you can block access to about everything you don't want to have. The
only thing to keep in mind is that the code you want to compile needs to
compiled in that restricted class (but I figure you won't allow people
to add stuff to CompiledMethod anyways ;)

Cheers,
  - Andreas

> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org 
> [mailto:squeak-dev-admin at lists.squeakfoundation.org] On 
> Behalf Of Tim Rowledge
> Sent: Saturday, July 13, 2002 6:56 PM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Restricting the scope for the compiler?
> 
> 
> I would like to be able to restrict the scope/environment/whatever
> accessible to the compiler for use in an application.
> What I have right now is a simple text substitution of sorta-variable
> names followed by a simple {Compiler evaluate: '3 + 4'} level of
> function. Unfortunately this would allow people to enter nice little
> expressions like 'Smalltalk quitPrimitive' which would have an
> unfortunate effect upon a seaside server.....
> 
> So far as I can see I need to cut off access to just about 
> everything in
> Smalltalk-the-system-dictionary. The application is intended to allow
> pretty simple expressions that use simple literals (numbers, 
> characters,
> strings, collections of the above, stuff like that) to pose 
> questions to
> students. For example, a question might specify several variables
> (companyName, profit, sales) all of which are randomly chosen values
> >from lists (like #('enron' 'harken' 'worldcom') for example). The
> question might ask:- If {companyName} declares a profit of ${profit}
> after sales of ${sales}, what is the percentage rate of return for
> {companyName} directors? And the answer is calculated via:-
> {profit}/{sales} * 4000000000000000000000000000
> (this is an american company y'see).
> There's all sorts of neat things one could do, but for now it 
> has to be
> near trivial. It's for accounting students after all :-)
> 
> Is there anything already in the (3.2) system I can use, or 
> do I have to
> try to work it out? I really hate screwing around with compilers. They
> always seem to have more unannounced assumed invariants than royal
> banquet etiquette.
> 
> tim
> -- 
> Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
> Nostalgia:  The good old days multiplied by a bad memory...
> 
> 




More information about the Squeak-dev mailing list