Nicolas Cellier uploaded a new version of Traits to project The Trunk:
http://source.squeak.org/trunk/Traits-nice.288.mcz
==================== Summary ====================
Name: Traits-nice.288
Author: nice
Time: 30 March 2011, 9:47:27.896 pm
UUID: 2c2016d2-acf3-448a-b3b9-836089b17a9e
Ancestors: Traits-nice.287
Use #newCompiler #newParser
=============== Diff against Traits-nice.287 ===============
Item was changed:
----- Method: ClassDescription>>replaceSelector:withAlias:in: (in category '*Traits-NanoKernel') -----
replaceSelector: originalSelector withAlias: aliasSelector in: source
"replaces originalSelector with aliasSelector in in given source code"
| oldKeywords newKeywords args selectorWithArgs s |
oldKeywords := originalSelector keywords.
newKeywords := aliasSelector keywords.
oldKeywords size = newKeywords size ifFalse:[self error: 'Keyword mismatch'].
+ args := (self newParser parseArgsAndTemps: source asString notifying: nil)
- args := (self parserClass new parseArgsAndTemps: source asString notifying: nil)
copyFrom: 1 to: originalSelector numArgs.
selectorWithArgs := String streamContents: [:stream |
newKeywords keysAndValuesDo: [:index :keyword |
stream nextPutAll: keyword.
stream space.
args size >= index ifTrue: [
stream nextPutAll: (args at: index); space]]].
s := source asString readStream.
oldKeywords do: [ :each | s match: each ].
args isEmpty ifFalse: [ s match: args last ].
^selectorWithArgs withBlanksTrimmed asText , s upToEnd
!
Item was changed:
----- Method: ClassDescription>>traitAddSelector:withMethod: (in category '*Traits-NanoKernel') -----
traitAddSelector: selector withMethod: traitMethod
"Add a method inherited from a trait.
Recompiles to avoid sharing and implement aliasing."
| oldMethod source methodNode newMethod originalSelector |
oldMethod := self compiledMethodAt: selector ifAbsent:[nil].
oldMethod ifNotNil:[
"The following is an important optimization as it prevents exponential
growth in recompilation. If T1 is used by T2 and T2 by T3 then (without
this optimization) any change in T1 would cause all methods in T2 to be
recompiled and each recompilation of a method in T2 would cause T3
to be fully recompiled. The test eliminates all such situations."
(oldMethod sameTraitCodeAs: traitMethod) ifTrue:[^oldMethod].
].
originalSelector := traitMethod selector.
source := traitMethod methodClass sourceCodeAt: originalSelector.
originalSelector == selector ifFalse:[
"Replace source selectors for aliases"
source := self replaceSelector: originalSelector withAlias: selector in: source.
].
+ methodNode := self newCompiler
- methodNode := self compilerClass new
compile: source in: self classified: nil notifying: nil ifFail:[^nil].
newMethod := methodNode generate: self defaultMethodTrailer.
newMethod putSource: source fromParseNode: methodNode inFile: 2
withPreamble: [:f | f cr; nextPut: $!!; nextChunkPut: 'Trait method'; cr].
newMethod originalTraitMethod: traitMethod.
^super addSelectorSilently: selector withMethod: newMethod.!
Nicolas Cellier uploaded a new version of Traits to project The Trunk:
http://source.squeak.org/trunk/Traits-nice.288.mcz
==================== Summary ====================
Name: Traits-nice.288
Author: nice
Time: 30 March 2011, 9:47:27.896 pm
UUID: 2c2016d2-acf3-448a-b3b9-836089b17a9e
Ancestors: Traits-nice.287
Use #newCompiler #newParser
=============== Diff against Traits-nice.287 ===============
Item was changed:
----- Method: ClassDescription>>replaceSelector:withAlias:in: (in category '*Traits-NanoKernel') -----
replaceSelector: originalSelector withAlias: aliasSelector in: source
"replaces originalSelector with aliasSelector in in given source code"
| oldKeywords newKeywords args selectorWithArgs s |
oldKeywords := originalSelector keywords.
newKeywords := aliasSelector keywords.
oldKeywords size = newKeywords size ifFalse:[self error: 'Keyword mismatch'].
+ args := (self newParser parseArgsAndTemps: source asString notifying: nil)
- args := (self parserClass new parseArgsAndTemps: source asString notifying: nil)
copyFrom: 1 to: originalSelector numArgs.
selectorWithArgs := String streamContents: [:stream |
newKeywords keysAndValuesDo: [:index :keyword |
stream nextPutAll: keyword.
stream space.
args size >= index ifTrue: [
stream nextPutAll: (args at: index); space]]].
s := source asString readStream.
oldKeywords do: [ :each | s match: each ].
args isEmpty ifFalse: [ s match: args last ].
^selectorWithArgs withBlanksTrimmed asText , s upToEnd
!
Item was changed:
----- Method: ClassDescription>>traitAddSelector:withMethod: (in category '*Traits-NanoKernel') -----
traitAddSelector: selector withMethod: traitMethod
"Add a method inherited from a trait.
Recompiles to avoid sharing and implement aliasing."
| oldMethod source methodNode newMethod originalSelector |
oldMethod := self compiledMethodAt: selector ifAbsent:[nil].
oldMethod ifNotNil:[
"The following is an important optimization as it prevents exponential
growth in recompilation. If T1 is used by T2 and T2 by T3 then (without
this optimization) any change in T1 would cause all methods in T2 to be
recompiled and each recompilation of a method in T2 would cause T3
to be fully recompiled. The test eliminates all such situations."
(oldMethod sameTraitCodeAs: traitMethod) ifTrue:[^oldMethod].
].
originalSelector := traitMethod selector.
source := traitMethod methodClass sourceCodeAt: originalSelector.
originalSelector == selector ifFalse:[
"Replace source selectors for aliases"
source := self replaceSelector: originalSelector withAlias: selector in: source.
].
+ methodNode := self newCompiler
- methodNode := self compilerClass new
compile: source in: self classified: nil notifying: nil ifFail:[^nil].
newMethod := methodNode generate: self defaultMethodTrailer.
newMethod putSource: source fromParseNode: methodNode inFile: 2
withPreamble: [:f | f cr; nextPut: $!!; nextChunkPut: 'Trait method'; cr].
newMethod originalTraitMethod: traitMethod.
^super addSelectorSilently: selector withMethod: newMethod.!
Nicolas Cellier uploaded a new version of Traits to project The Trunk:
http://source.squeak.org/trunk/Traits-nice.288.mcz
==================== Summary ====================
Name: Traits-nice.288
Author: nice
Time: 30 March 2011, 9:47:27.896 pm
UUID: 2c2016d2-acf3-448a-b3b9-836089b17a9e
Ancestors: Traits-nice.287
Use #newCompiler #newParser
=============== Diff against Traits-nice.287 ===============
Item was changed:
----- Method: ClassDescription>>replaceSelector:withAlias:in: (in category '*Traits-NanoKernel') -----
replaceSelector: originalSelector withAlias: aliasSelector in: source
"replaces originalSelector with aliasSelector in in given source code"
| oldKeywords newKeywords args selectorWithArgs s |
oldKeywords := originalSelector keywords.
newKeywords := aliasSelector keywords.
oldKeywords size = newKeywords size ifFalse:[self error: 'Keyword mismatch'].
+ args := (self newParser parseArgsAndTemps: source asString notifying: nil)
- args := (self parserClass new parseArgsAndTemps: source asString notifying: nil)
copyFrom: 1 to: originalSelector numArgs.
selectorWithArgs := String streamContents: [:stream |
newKeywords keysAndValuesDo: [:index :keyword |
stream nextPutAll: keyword.
stream space.
args size >= index ifTrue: [
stream nextPutAll: (args at: index); space]]].
s := source asString readStream.
oldKeywords do: [ :each | s match: each ].
args isEmpty ifFalse: [ s match: args last ].
^selectorWithArgs withBlanksTrimmed asText , s upToEnd
!
Item was changed:
----- Method: ClassDescription>>traitAddSelector:withMethod: (in category '*Traits-NanoKernel') -----
traitAddSelector: selector withMethod: traitMethod
"Add a method inherited from a trait.
Recompiles to avoid sharing and implement aliasing."
| oldMethod source methodNode newMethod originalSelector |
oldMethod := self compiledMethodAt: selector ifAbsent:[nil].
oldMethod ifNotNil:[
"The following is an important optimization as it prevents exponential
growth in recompilation. If T1 is used by T2 and T2 by T3 then (without
this optimization) any change in T1 would cause all methods in T2 to be
recompiled and each recompilation of a method in T2 would cause T3
to be fully recompiled. The test eliminates all such situations."
(oldMethod sameTraitCodeAs: traitMethod) ifTrue:[^oldMethod].
].
originalSelector := traitMethod selector.
source := traitMethod methodClass sourceCodeAt: originalSelector.
originalSelector == selector ifFalse:[
"Replace source selectors for aliases"
source := self replaceSelector: originalSelector withAlias: selector in: source.
].
+ methodNode := self newCompiler
- methodNode := self compilerClass new
compile: source in: self classified: nil notifying: nil ifFail:[^nil].
newMethod := methodNode generate: self defaultMethodTrailer.
newMethod putSource: source fromParseNode: methodNode inFile: 2
withPreamble: [:f | f cr; nextPut: $!!; nextChunkPut: 'Trait method'; cr].
newMethod originalTraitMethod: traitMethod.
^super addSelectorSilently: selector withMethod: newMethod.!
Nicolas Cellier uploaded a new version of ST80 to project The Trunk:
http://source.squeak.org/trunk/ST80-nice.126.mcz
==================== Summary ====================
Name: ST80-nice.126
Author: nice
Time: 30 March 2011, 9:34:56.706 pm
UUID: 5c20c89b-78d2-468c-9679-6d50ae37b2d1
Ancestors: ST80-dtl.125
Use #newParser
=============== Diff against ST80-dtl.125 ===============
Item was changed:
----- Method: ParagraphEditor>>explainTemp: (in category 'explain') -----
explainTemp: string
"Is string the name of a temporary variable (method or block argument or temporary)?"
| selectedClass methodNode tempNode |
(model respondsTo: #selectedMessageName) ifFalse: [^ nil].
model selectedMessageName ifNil: [^nil]. "not in a method"
selectedClass := model selectedClassOrMetaClass.
+ methodNode := selectedClass newParser parse: model selectedMessage class: selectedClass.
- methodNode := selectedClass parserClass new parse: model selectedMessage class: selectedClass.
tempNode := methodNode encoder tempNodes detect: [:n| n name = string] ifNone: [^nil].
^(tempNode isArg
ifTrue: ['"is an argument to this ']
ifFalse: ['"is a temporary variable in this ']),
(tempNode isDeclaredAtMethodLevel
ifTrue: ['method"']
ifFalse: ['block"'])!
Nicolas Cellier uploaded a new version of ST80 to project The Trunk:
http://source.squeak.org/trunk/ST80-nice.126.mcz
==================== Summary ====================
Name: ST80-nice.126
Author: nice
Time: 30 March 2011, 9:34:56.706 pm
UUID: 5c20c89b-78d2-468c-9679-6d50ae37b2d1
Ancestors: ST80-dtl.125
Use #newParser
=============== Diff against ST80-dtl.125 ===============
Item was changed:
----- Method: ParagraphEditor>>explainTemp: (in category 'explain') -----
explainTemp: string
"Is string the name of a temporary variable (method or block argument or temporary)?"
| selectedClass methodNode tempNode |
(model respondsTo: #selectedMessageName) ifFalse: [^ nil].
model selectedMessageName ifNil: [^nil]. "not in a method"
selectedClass := model selectedClassOrMetaClass.
+ methodNode := selectedClass newParser parse: model selectedMessage class: selectedClass.
- methodNode := selectedClass parserClass new parse: model selectedMessage class: selectedClass.
tempNode := methodNode encoder tempNodes detect: [:n| n name = string] ifNone: [^nil].
^(tempNode isArg
ifTrue: ['"is an argument to this ']
ifFalse: ['"is a temporary variable in this ']),
(tempNode isDeclaredAtMethodLevel
ifTrue: ['method"']
ifFalse: ['block"'])!
Nicolas Cellier uploaded a new version of ST80 to project The Trunk:
http://source.squeak.org/trunk/ST80-nice.126.mcz
==================== Summary ====================
Name: ST80-nice.126
Author: nice
Time: 30 March 2011, 9:34:56.706 pm
UUID: 5c20c89b-78d2-468c-9679-6d50ae37b2d1
Ancestors: ST80-dtl.125
Use #newParser
=============== Diff against ST80-dtl.125 ===============
Item was changed:
----- Method: ParagraphEditor>>explainTemp: (in category 'explain') -----
explainTemp: string
"Is string the name of a temporary variable (method or block argument or temporary)?"
| selectedClass methodNode tempNode |
(model respondsTo: #selectedMessageName) ifFalse: [^ nil].
model selectedMessageName ifNil: [^nil]. "not in a method"
selectedClass := model selectedClassOrMetaClass.
+ methodNode := selectedClass newParser parse: model selectedMessage class: selectedClass.
- methodNode := selectedClass parserClass new parse: model selectedMessage class: selectedClass.
tempNode := methodNode encoder tempNodes detect: [:n| n name = string] ifNone: [^nil].
^(tempNode isArg
ifTrue: ['"is an argument to this ']
ifFalse: ['"is a temporary variable in this ']),
(tempNode isDeclaredAtMethodLevel
ifTrue: ['method"']
ifFalse: ['block"'])!