Squeak Class Documentation category index | class index  
 
Compiler
  category: System-Compiler
  superclass: Object
  subclasses:

The compiler accepts Smalltalk source code and compiles it with respect to a given class. The user of the compiler supplies a context so that temporary variables are accessible during compilation. If there is an error, a requestor (usually a kind of StringHolderController) is sent the message notify:at:in: so that the error message can be displayed. If there is no error, then the result of compilation is a MethodNode, which is the root of a parse tree whose nodes are kinds of ParseNodes. The parse tree can be sent messages to (1) generate code for a CompiledMethod (this is done for compiling methods or evaluating expressions); (2) pretty-print the code (for formatting); or (3) produce a map from object code back to source code (used by debugger program-counter selection). See also Parser, Encoder, ParseNode.

instance methods
  error handling
  interactive
notify:
notify:at:

  private
  format:noPattern:ifFail:
from:class:context:notifying:
translate:noPattern:ifFail:

  public access
  compile:in:notifying:ifFail:
compileNoPattern:in:context:notifying:ifFail:
evaluate:in:to:notifying:ifFail:
format:in:notifying:contentsSymbol:
format:in:notifying:decorated:
parse:in:notifying:
parse:in:notifying:dialect:

class methods
  accessing
  parserClass

  evaluating
  evaluate:
evaluate:for:logged:
evaluate:for:notifying:logged:
evaluate:logged:
evaluate:notifying:logged:

instance methods
  error handling top  
 

interactive

Answer whether there is a requestor of the compiler who should be
informed that an error occurred.


 

notify:

Refer to the comment in Object|notify:.


 

notify:at:

Refer to the comment in Object|notify:.


  private top  
 

format:noPattern:ifFail:


 

from:class:context:notifying:


 

translate:noPattern:ifFail:


  public access top  
 

compile:in:notifying:ifFail:

Answer a MethodNode for the argument, textOrStream. If the
MethodNode can not be created, notify the argument, aRequestor; if
aRequestor is nil, evaluate failBlock instead. The MethodNode is the root
of a parse tree. It can be told to generate a CompiledMethod to be
installed in the method dictionary of the argument, aClass.


 

compileNoPattern:in:context:notifying:ifFail:

Similar to #compile:in:notifying:ifFail:, but the compiled code is
expected to be a do-it expression, with no message pattern.


 

evaluate:in:to:notifying:ifFail:

Compiles the sourceStream into a parse tree, then generates code into a
method. This method is then installed in the receiver's class so that it
can be invoked. In other words, if receiver is not nil, then the text can
refer to instance variables of that receiver (the Inspector uses this). If
aContext is not nil, the text can refer to temporaries in that context (the
Debugger uses this). If aRequestor is not nil, then it will receive a
notify:at: message before the attempt to evaluate is aborted. Finally, the
compiled method is invoked from here as DoIt or (in the case of
evaluation in aContext) DoItIn:. The method is subsequently removed
from the class, but this will not get done if the invocation causes an
error which is terminated. Such garbage can be removed by executing:
Smalltalk allBehaviorsDo: [:cl | cl removeSelector: #DoIt; removeSelector:
#DoItIn:].


 

format:in:notifying:contentsSymbol:

Compile a parse tree from the argument, textOrStream. Answer a string containing the original code, formatted nicely. If aBoolean is true, then decorate the resulting text with color and hypertext actions


 

format:in:notifying:decorated:

Compile a parse tree from the argument, textOrStream. Answer a string containing the original code, formatted nicely. If aBoolean is true, then decorate the resulting text with color and hypertext actions


 

parse:in:notifying:

Compile the argument, textOrStream, with respect to the class, aClass,
and answer the MethodNode that is the root of the resulting parse tree.
Notify the argument, req, if an error occurs. The failBlock is defaulted to
an empty block.


 

parse:in:notifying:dialect:

Compile the argument, textOrStream, with respect to the class, aClass,
and answer the MethodNode that is the root of the resulting parse tree.
Notify the argument, req, if an error occurs. The failBlock is defaulted to
an empty block.


class methods
  accessing top  
 

parserClass

Return a parser class to use for parsing method headers.


  evaluating top  
 

evaluate:

See Compiler|evaluate:for:notifying:logged:. If a compilation error occurs,
a Syntax Error view is created rather than notifying any requestor.
Compilation is carried out with respect to nil, i.e., no object, and the
invocation is not logged.


 

evaluate:for:logged:

See Compiler|evaluate:for:notifying:logged:. If a compilation error occurs,
a Syntax Error view is created rather than notifying any requestor.


 

evaluate:for:notifying:logged:

Compile and execute the argument, textOrString with respect to the class
of anObject. If a compilation error occurs, notify aController. If both
compilation and execution are successful then, if logFlag is true, log
(write) the text onto a system changes file so that it can be replayed if
necessary.


 

evaluate:logged:

See Compiler|evaluate:for:notifying:logged:. If a compilation error occurs,
a Syntax Error view is created rather than notifying any requestor.
Compilation is carried out with respect to nil, i.e., no object.


 

evaluate:notifying:logged:

See Compiler|evaluate:for:notifying:logged:. Compilation is carried out
with respect to nil, i.e., no object.