The Trunk: Compiler-nice.279.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Compiler-nice.279.mcz

commits-2
Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-nice.279.mcz

==================== Summary ====================

Name: Compiler-nice.279
Author: nice
Time: 16 December 2013, 3:39:42.986 pm
UUID: 94b1b5f8-f71b-4425-b035-461d3dc94e3f
Ancestors: Compiler-fbs.278

Provide a complete protocol for invoking Compiler without logging - that is without logged: parameter.
Make the logging (logged:) version send the non logging version rather than the contrary.
This step may help moving logging out of Compiler in a future version.

=============== Diff against Compiler-fbs.278 ===============

Item was changed:
  ----- Method: Compiler class>>evaluate: (in category 'evaluating') -----
  evaluate: textOrString
  "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."
 
+ ^self evaluate: textOrString for: nil!
- ^self evaluate: textOrString for: nil logged: false!

Item was changed:
  ----- Method: Compiler class>>evaluate:environment: (in category 'evaluating') -----
  evaluate: aString environment: anEnvironment
+ ^  self new
+ evaluateCue: (CompilationCue
+ source: aString
+ environment: anEnvironment)
+ ifFail: [^ nil]!
- ^ self
- evaluate: aString
- environment: anEnvironment
- logged: false!

Item was changed:
+ ----- Method: Compiler class>>evaluate:environment:logged: (in category 'evaluating logged') -----
- ----- Method: Compiler class>>evaluate:environment:logged: (in category 'evaluating') -----
  evaluate: aString environment: anEnvironment logged: aBoolean
  ^ self new
  evaluateCue: (CompilationCue
  source: aString
  environment: anEnvironment)
  ifFail: [^ nil]
  logged: aBoolean!

Item was added:
+ ----- Method: Compiler class>>evaluate:for: (in category 'evaluating') -----
+ evaluate: textOrString for: anObject  
+ "See Compiler|evaluate:for:notifying:. If a compilation error occurs,
+ a Syntax Error view is created rather than notifying any requestor."
+
+ ^self evaluate: textOrString for: anObject notifying: nil!

Item was changed:
+ ----- Method: Compiler class>>evaluate:for:logged: (in category 'evaluating logged') -----
- ----- Method: Compiler class>>evaluate:for:logged: (in category 'evaluating') -----
  evaluate: textOrString for: anObject logged: logFlag
  "See Compiler|evaluate:for:notifying:logged:. If a compilation error occurs,
  a Syntax Error view is created rather than notifying any requestor."
 
  ^self evaluate: textOrString for: anObject notifying: nil logged: logFlag!

Item was added:
+ ----- Method: Compiler class>>evaluate:for:notifying: (in category 'evaluating') -----
+ evaluate: textOrString for: anObject notifying: aController
+ "Compile and execute the argument, textOrString with respect to the class
+ of anObject. If a compilation error occurs, notify aController."
+
+ ^ self new
+ evaluate: textOrString
+ in: nil
+ to: anObject
+ notifying: aController
+ ifFail: [^nil]!

Item was changed:
+ ----- Method: Compiler class>>evaluate:for:notifying:logged: (in category 'evaluating logged') -----
- ----- Method: Compiler class>>evaluate:for:notifying:logged: (in category 'evaluating') -----
  evaluate: textOrString for: anObject notifying: aController logged: logFlag
  "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."
 
  ^ self new
  evaluate: textOrString
  in: nil
  to: anObject
  notifying: aController
  ifFail: [^nil]
  logged: logFlag.!

Item was changed:
+ ----- Method: Compiler class>>evaluate:logged: (in category 'evaluating logged') -----
- ----- Method: Compiler class>>evaluate:logged: (in category 'evaluating') -----
  evaluate: textOrString logged: logFlag
  "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."
 
  ^self evaluate: textOrString for: nil logged: logFlag!

Item was added:
+ ----- Method: Compiler class>>evaluate:notifying: (in category 'evaluating') -----
+ evaluate: textOrString notifying: aController
+ "See Compiler|evaluate:for:notifying:logged:. Compilation is carried out
+ with respect to nil, i.e., no object."
+
+ ^self evaluate: textOrString for: nil notifying: aController!

Item was changed:
+ ----- Method: Compiler class>>evaluate:notifying:logged: (in category 'evaluating logged') -----
- ----- Method: Compiler class>>evaluate:notifying:logged: (in category 'evaluating') -----
  evaluate: textOrString notifying: aController logged: logFlag
  "See Compiler|evaluate:for:notifying:logged:. Compilation is carried out
  with respect to nil, i.e., no object."
 
  ^self evaluate: textOrString for: nil notifying: aController logged: logFlag!

Item was added:
+ ----- Method: Compiler>>compiledMethodFor:in:to:notifying:ifFail: (in category 'public access') -----
+ compiledMethodFor: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock
+ "Compiles the sourceStream into a parse tree, then generates code
+ into a method, and answers it.  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."
+
+ | methodNode method theClass |
+ theClass := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class.
+ methodNode := self
+ compileNoPattern: textOrStream
+ in: theClass
+ context: aContext
+ notifying: aRequestor
+ ifFail: [^failBlock value].
+ method := self interactive
+ ifTrue: [ methodNode generateWithTempNames ]
+ ifFalse: [ methodNode generate ].
+ ^method!

Item was changed:
+ ----- Method: Compiler>>compiledMethodFor:in:to:notifying:ifFail:logged: (in category 'public access logging') -----
- ----- Method: Compiler>>compiledMethodFor:in:to:notifying:ifFail:logged: (in category 'public access') -----
  compiledMethodFor: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag
  "Compiles the sourceStream into a parse tree, then generates code
  into a method, and answers it.  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."
 
+ | method |
+ method := self
+ compiledMethodFor: textOrStream
+ in: aContext
+ to: receiver
- | methodNode method theClass |
- theClass := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class.
- methodNode := self
- compileNoPattern: textOrStream
- in: theClass
- context: aContext
  notifying: aRequestor
  ifFail: [^failBlock value].
- method := self interactive
- ifTrue: [ methodNode generateWithTempNames ]
- ifFalse: [ methodNode generate ].
-
  logFlag ifTrue:
  [SystemChangeNotifier uniqueInstance evaluated: cue stringToLog context: aContext].
  ^method!

Item was changed:
  ----- Method: Compiler>>evaluate: (in category 'public access') -----
  evaluate: textOrString
  "See 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."
 
+ ^self evaluate: textOrString for: nil!
- ^self evaluate: textOrString for: nil logged: false!

Item was added:
+ ----- Method: Compiler>>evaluate:for: (in category 'public access') -----
+ evaluate: textOrString for: anObject
+ "See evaluate:for:notifying:logged:. If a compilation error occurs,
+ a Syntax Error view is created rather than notifying any requestor."
+
+ ^self evaluate: textOrString for: anObject notifying: nil!

Item was changed:
+ ----- Method: Compiler>>evaluate:for:logged: (in category 'public access logging') -----
- ----- Method: Compiler>>evaluate:for:logged: (in category 'public access') -----
  evaluate: textOrString for: anObject logged: logFlag
  "See evaluate:for:notifying:logged:. If a compilation error occurs,
  a Syntax Error view is created rather than notifying any requestor."
 
  ^self evaluate: textOrString for: anObject notifying: nil logged: logFlag!

Item was added:
+ ----- Method: Compiler>>evaluate:for:notifying: (in category 'public access') -----
+ evaluate: textOrString for: anObject notifying: aController
+ "Compile and execute the argument, textOrString with respect to the class
+ of anObject. If a compilation error occurs, notify aController."
+
+ ^ self
+ evaluate: textOrString
+ in: nil
+ to: anObject
+ notifying: aController
+ ifFail: [^nil]!

Item was changed:
+ ----- Method: Compiler>>evaluate:for:notifying:logged: (in category 'public access logging') -----
- ----- Method: Compiler>>evaluate:for:notifying:logged: (in category 'public access') -----
  evaluate: textOrString for: anObject notifying: aController logged: logFlag
  "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."
 
  ^ self
  evaluate: textOrString
  in: nil
  to: anObject
  notifying: aController
  ifFail: [^nil]
  logged: logFlag.!

Item was changed:
  ----- Method: Compiler>>evaluate:in:to:notifying:ifFail: (in category 'public access') -----
  evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock
+ "Compiles the sourceStream into a parse tree, then generates code into
+ a method. 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 via withArgs:executeMethod:, hence
+ the system no longer creates Doit method litter on errors."
+
+ | theClass |
+ theClass := ((aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class).
+ ^self
+ evaluateCue: (CompilationCue
+ source: textOrStream
+ context: aContext
+ receiver: receiver
+ class: theClass
+ environment: theClass environment
+ requestor: aRequestor)
+ ifFail: failBlock!
- ^ self evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: false.!

Item was changed:
+ ----- Method: Compiler>>evaluate:in:to:notifying:ifFail:logged: (in category 'public access logging') -----
- ----- Method: Compiler>>evaluate:in:to:notifying:ifFail:logged: (in category 'public access') -----
  evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag
  "Compiles the sourceStream into a parse tree, then generates code into
  a method. 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 via withArgs:executeMethod:, hence
  the system no longer creates Doit method litter on errors."
 
  | theClass |
  theClass := ((aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class).
  ^self
  evaluateCue: (CompilationCue
  source: textOrStream
  context: aContext
  receiver: receiver
  class: theClass
  environment: theClass environment
  requestor: aRequestor)
  ifFail: failBlock
  logged: logFlag!

Item was changed:
+ ----- Method: Compiler>>evaluate:logged: (in category 'public access logging') -----
- ----- Method: Compiler>>evaluate:logged: (in category 'public access') -----
  evaluate: textOrString logged: logFlag
  "See 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."
 
  ^self evaluate: textOrString for: nil logged: logFlag!

Item was added:
+ ----- Method: Compiler>>evaluate:notifying: (in category 'public access') -----
+ evaluate: textOrString notifying: aController
+ "See evaluate:for:notifying:. Compilation is carried out
+ with respect to nil, i.e., no object."
+
+ ^self evaluate: textOrString for: nil notifying: aController!

Item was changed:
+ ----- Method: Compiler>>evaluate:notifying:logged: (in category 'public access logging') -----
- ----- Method: Compiler>>evaluate:notifying:logged: (in category 'public access') -----
  evaluate: textOrString notifying: aController logged: logFlag
  "See evaluate:for:notifying:logged:. Compilation is carried out
  with respect to nil, i.e., no object."
 
  ^self evaluate: textOrString for: nil notifying: aController logged: logFlag!

Item was added:
+ ----- Method: Compiler>>evaluateCue:ifFail: (in category 'private') -----
+ evaluateCue: aCue ifFail: failBlock
+ "Compiles the cue source into a parse tree, then generates code into
+ a method. Finally, the compiled method is invoked from here via withArgs:executeMethod:, hence the system no longer creates Doit method
+ litter on errors."
+
+ | methodNode method value |
+ methodNode := self compileCue: aCue noPattern: true ifFail: [^failBlock value].
+
+ method := self interactive
+ ifTrue: [methodNode generateWithTempNames]
+ ifFalse: [methodNode generate].
+
+ value := cue receiver
+ withArgs: (cue context ifNil: [#()] ifNotNil: [{cue context}])
+ executeMethod: method.
+ ^ value
+ !

Item was changed:
  ----- Method: Compiler>>evaluateCue:ifFail:logged: (in category 'private') -----
  evaluateCue: aCue ifFail: failBlock logged: logFlag
  "Compiles the cue source into a parse tree, then generates code into
  a method. Finally, the compiled method is invoked from here via withArgs:executeMethod:, hence the system no longer creates Doit method
  litter on errors."
 
+ | value |
+ value := self evaluateCue: aCue ifFail: [^failBlock value].
- | methodNode method value |
- methodNode := self compileCue: aCue noPattern: true ifFail: [^failBlock value].
-
- method := self interactive
- ifTrue: [methodNode generateWithTempNames]
- ifFalse: [methodNode generate].
-
- value := cue receiver
- withArgs: (cue context ifNil: [#()] ifNotNil: [{cue context}])
- executeMethod: method.
-
  logFlag ifTrue:
  [SystemChangeNotifier uniqueInstance evaluated: cue stringToLog context: cue context].
  ^ value
  !


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Compiler-nice.279.mcz

Frank Shearar-3
On 16 December 2013 14:39,  <[hidden email]> wrote:

> Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
> http://source.squeak.org/trunk/Compiler-nice.279.mcz
>
> ==================== Summary ====================
>
> Name: Compiler-nice.279
> Author: nice
> Time: 16 December 2013, 3:39:42.986 pm
> UUID: 94b1b5f8-f71b-4425-b035-461d3dc94e3f
> Ancestors: Compiler-fbs.278
>
> Provide a complete protocol for invoking Compiler without logging - that is without logged: parameter.
> Make the logging (logged:) version send the non logging version rather than the contrary.
> This step may help moving logging out of Compiler in a future version.
>
> =============== Diff against Compiler-fbs.278 ===============

Nice! Thanks, nice!

frank

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Compiler-nice.279.mcz

Nicolas Cellier
Now let's see which are the loggers:
- ParagrapEditor and TextEditor>>evaluateSelectionAndDo: (for doIt/printIt menus)
- several ways for defining a class
  (PseudoClass>>evaluate:  Browser>>copyClass / defineClass:notifying: / defineTrait:notifying: MessageSet>>contents:notifying:)
- the many implementations for filing in chunks
  (PositionalStream>>fileInAnnouncing: / fileInSilentlyAnnouncing: / fileInFor:announcing:
  EnvironmentLoader>>fileInChunkFrom:
  ObjectScanner>>scanFrom: / lookAhead:
  ImageSegment>>scanFrom:)

Note that defineClass:notifying: does not log anymore...
Some notifications could be as well moved to ClassDescription like removeSelector: already does.


2013/12/16 Frank Shearar <[hidden email]>
On 16 December 2013 14:39,  <[hidden email]> wrote:
> Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
> http://source.squeak.org/trunk/Compiler-nice.279.mcz
>
> ==================== Summary ====================
>
> Name: Compiler-nice.279
> Author: nice
> Time: 16 December 2013, 3:39:42.986 pm
> UUID: 94b1b5f8-f71b-4425-b035-461d3dc94e3f
> Ancestors: Compiler-fbs.278
>
> Provide a complete protocol for invoking Compiler without logging - that is without logged: parameter.
> Make the logging (logged:) version send the non logging version rather than the contrary.
> This step may help moving logging out of Compiler in a future version.
>
> =============== Diff against Compiler-fbs.278 ===============

Nice! Thanks, nice!

frank