lists.squeakfoundation.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Packages
January 2013
----- 2024 -----
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
packages@lists.squeakfoundation.org
1 participants
219 discussions
Start a n
N
ew thread
The Trunk: Environments-cwp.8.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Environments to project The Trunk:
http://source.squeak.org/trunk/Environments-cwp.8.mcz
==================== Summary ==================== Name: Environments-cwp.8 Author: cwp Time: 1 January 2013, 7:00:24.118 pm UUID: 0abedc80-5737-42fb-babd-6b2d69f1b352 Ancestors: Environments-cwp.7 Environments bootstrap - stage 3 =============== Diff against Environments-cwp.7 =============== Item was changed: ----- Method: Environment>>fileIn:announcing: (in category 'operations') ----- fileIn: aStream announcing: aString + (EnvironmentLoader for: self) - self shouldBeImplemented. - " (EnvironmentLoader for: self) fileIn: aStream announcing: aString + ! - "! Item was added: + Object subclass: #EnvironmentLoader + instanceVariableNames: 'environment' + classVariableNames: '' + poolDictionaries: '' + category: 'Environments-Core'! Item was added: + ----- Method: EnvironmentLoader class>>for: (in category 'as yet unclassified') ----- + for: anEnvironment + ^ self basicNew initializeWithEnvironment: anEnvironment! Item was added: + ----- Method: EnvironmentLoader>>evaluate:logged: (in category 'as yet unclassified') ----- + evaluate: chunk logged: aBoolean + ^ [Compiler evaluate: chunk environment: environment logged: aBoolean] + on: EnvironmentRequest + do: [:req | req resume: environment]! Item was added: + ----- Method: EnvironmentLoader>>fileIn:announcing: (in category 'as yet unclassified') ----- + fileIn: aStream announcing: aString + | val | + self logStart: aStream name. + aString displayProgressFrom: 0 to: aStream size during: + [:bar | + [aStream atEnd] whileFalse: + [bar value: aStream position. + aStream skipSeparators. + [val := self fileInChunkFrom: aStream] + on: InMidstOfFileinNotification + do: [:ex | ex resume: true]. + aStream skipStyleChunk]. + aStream close]. + self logEnd: aStream name. + ^ val! Item was added: + ----- Method: EnvironmentLoader>>fileInChunkFrom: (in category 'as yet unclassified') ----- + fileInChunkFrom: aStream + | chunk | + ^ (aStream peekFor: $!!) + ifTrue: [ + | reader | + chunk := aStream nextChunk. + reader := self evaluate: chunk logged: false. + reader scanFrom: aStream environment: environment] + ifFalse: [ + chunk := aStream nextChunk. + aStream checkForPreamble: chunk. + self evaluate: chunk logged: true ]! Item was added: + ----- Method: EnvironmentLoader>>initializeWithEnvironment: (in category 'as yet unclassified') ----- + initializeWithEnvironment: anEnvironment + self initialize. + environment := anEnvironment! Item was added: + ----- Method: EnvironmentLoader>>logEnd: (in category 'as yet unclassified') ----- + logEnd: filename + "Note: The main purpose of this banner is to flush the changes file." + SmalltalkImage current logChange: '----End fileIn of ' , filename , ' into ', environment name, '----' ! Item was added: + ----- Method: EnvironmentLoader>>logStart: (in category 'as yet unclassified') ----- + logStart: filename + SmalltalkImage current logChange: '----Start fileIn of ' , filename , ' into ' , environment name , '----'! Item was added: + Notification subclass: #EnvironmentRequest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'Environments-Core'!
1
0
0
0
The Trunk: Environments-cwp.8.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Environments to project The Trunk:
http://source.squeak.org/trunk/Environments-cwp.8.mcz
==================== Summary ==================== Name: Environments-cwp.8 Author: cwp Time: 1 January 2013, 7:00:24.118 pm UUID: 0abedc80-5737-42fb-babd-6b2d69f1b352 Ancestors: Environments-cwp.7 Environments bootstrap - stage 3 =============== Diff against Environments-cwp.7 =============== Item was changed: ----- Method: Environment>>fileIn:announcing: (in category 'operations') ----- fileIn: aStream announcing: aString + (EnvironmentLoader for: self) - self shouldBeImplemented. - " (EnvironmentLoader for: self) fileIn: aStream announcing: aString + ! - "! Item was added: + Object subclass: #EnvironmentLoader + instanceVariableNames: 'environment' + classVariableNames: '' + poolDictionaries: '' + category: 'Environments-Core'! Item was added: + ----- Method: EnvironmentLoader class>>for: (in category 'as yet unclassified') ----- + for: anEnvironment + ^ self basicNew initializeWithEnvironment: anEnvironment! Item was added: + ----- Method: EnvironmentLoader>>evaluate:logged: (in category 'as yet unclassified') ----- + evaluate: chunk logged: aBoolean + ^ [Compiler evaluate: chunk environment: environment logged: aBoolean] + on: EnvironmentRequest + do: [:req | req resume: environment]! Item was added: + ----- Method: EnvironmentLoader>>fileIn:announcing: (in category 'as yet unclassified') ----- + fileIn: aStream announcing: aString + | val | + self logStart: aStream name. + aString displayProgressFrom: 0 to: aStream size during: + [:bar | + [aStream atEnd] whileFalse: + [bar value: aStream position. + aStream skipSeparators. + [val := self fileInChunkFrom: aStream] + on: InMidstOfFileinNotification + do: [:ex | ex resume: true]. + aStream skipStyleChunk]. + aStream close]. + self logEnd: aStream name. + ^ val! Item was added: + ----- Method: EnvironmentLoader>>fileInChunkFrom: (in category 'as yet unclassified') ----- + fileInChunkFrom: aStream + | chunk | + ^ (aStream peekFor: $!!) + ifTrue: [ + | reader | + chunk := aStream nextChunk. + reader := self evaluate: chunk logged: false. + reader scanFrom: aStream environment: environment] + ifFalse: [ + chunk := aStream nextChunk. + aStream checkForPreamble: chunk. + self evaluate: chunk logged: true ]! Item was added: + ----- Method: EnvironmentLoader>>initializeWithEnvironment: (in category 'as yet unclassified') ----- + initializeWithEnvironment: anEnvironment + self initialize. + environment := anEnvironment! Item was added: + ----- Method: EnvironmentLoader>>logEnd: (in category 'as yet unclassified') ----- + logEnd: filename + "Note: The main purpose of this banner is to flush the changes file." + SmalltalkImage current logChange: '----End fileIn of ' , filename , ' into ', environment name, '----' ! Item was added: + ----- Method: EnvironmentLoader>>logStart: (in category 'as yet unclassified') ----- + logStart: filename + SmalltalkImage current logChange: '----Start fileIn of ' , filename , ' into ' , environment name , '----'! Item was added: + Notification subclass: #EnvironmentRequest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'Environments-Core'!
1
0
0
0
The Trunk: Environments-cwp.8.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Environments to project The Trunk:
http://source.squeak.org/trunk/Environments-cwp.8.mcz
==================== Summary ==================== Name: Environments-cwp.8 Author: cwp Time: 1 January 2013, 7:00:24.118 pm UUID: 0abedc80-5737-42fb-babd-6b2d69f1b352 Ancestors: Environments-cwp.7 Environments bootstrap - stage 3 =============== Diff against Environments-cwp.7 =============== Item was changed: ----- Method: Environment>>fileIn:announcing: (in category 'operations') ----- fileIn: aStream announcing: aString + (EnvironmentLoader for: self) - self shouldBeImplemented. - " (EnvironmentLoader for: self) fileIn: aStream announcing: aString + ! - "! Item was added: + Object subclass: #EnvironmentLoader + instanceVariableNames: 'environment' + classVariableNames: '' + poolDictionaries: '' + category: 'Environments-Core'! Item was added: + ----- Method: EnvironmentLoader class>>for: (in category 'as yet unclassified') ----- + for: anEnvironment + ^ self basicNew initializeWithEnvironment: anEnvironment! Item was added: + ----- Method: EnvironmentLoader>>evaluate:logged: (in category 'as yet unclassified') ----- + evaluate: chunk logged: aBoolean + ^ [Compiler evaluate: chunk environment: environment logged: aBoolean] + on: EnvironmentRequest + do: [:req | req resume: environment]! Item was added: + ----- Method: EnvironmentLoader>>fileIn:announcing: (in category 'as yet unclassified') ----- + fileIn: aStream announcing: aString + | val | + self logStart: aStream name. + aString displayProgressFrom: 0 to: aStream size during: + [:bar | + [aStream atEnd] whileFalse: + [bar value: aStream position. + aStream skipSeparators. + [val := self fileInChunkFrom: aStream] + on: InMidstOfFileinNotification + do: [:ex | ex resume: true]. + aStream skipStyleChunk]. + aStream close]. + self logEnd: aStream name. + ^ val! Item was added: + ----- Method: EnvironmentLoader>>fileInChunkFrom: (in category 'as yet unclassified') ----- + fileInChunkFrom: aStream + | chunk | + ^ (aStream peekFor: $!!) + ifTrue: [ + | reader | + chunk := aStream nextChunk. + reader := self evaluate: chunk logged: false. + reader scanFrom: aStream environment: environment] + ifFalse: [ + chunk := aStream nextChunk. + aStream checkForPreamble: chunk. + self evaluate: chunk logged: true ]! Item was added: + ----- Method: EnvironmentLoader>>initializeWithEnvironment: (in category 'as yet unclassified') ----- + initializeWithEnvironment: anEnvironment + self initialize. + environment := anEnvironment! Item was added: + ----- Method: EnvironmentLoader>>logEnd: (in category 'as yet unclassified') ----- + logEnd: filename + "Note: The main purpose of this banner is to flush the changes file." + SmalltalkImage current logChange: '----End fileIn of ' , filename , ' into ', environment name, '----' ! Item was added: + ----- Method: EnvironmentLoader>>logStart: (in category 'as yet unclassified') ----- + logStart: filename + SmalltalkImage current logChange: '----Start fileIn of ' , filename , ' into ' , environment name , '----'! Item was added: + Notification subclass: #EnvironmentRequest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'Environments-Core'!
1
0
0
0
The Trunk: Compiler-cwp.247.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-cwp.247.mcz
==================== Summary ==================== Name: Compiler-cwp.247 Author: cwp Time: 1 January 2013, 6:59:31.461 pm UUID: 22f2cbf1-9186-4d2f-8c9c-dffcc0518ffa Ancestors: Compiler-cwp.246 Environments bootstrap - stage 3 =============== Diff against Compiler-cwp.246 =============== Item was changed: ----- 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." + | methodNode method theClass | + theClass := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. + self from: textOrStream class: theClass context: aContext notifying: aRequestor. - | methodNode method | - class := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. - self from: textOrStream class: class context: aContext notifying: aRequestor. methodNode := self translate: sourceStream noPattern: true ifFail: [^failBlock value]. method := self interactive ifTrue: [ methodNode generateWithTempNames ] ifFalse: [methodNode generate]. logFlag ifTrue: [SystemChangeNotifier uniqueInstance evaluated: sourceStream contents context: aContext]. ^method! Item was changed: ----- Method: Compiler>>format:noPattern:ifFail: (in category 'private') ----- format: aStream noPattern: noPattern ifFail: failBlock ^(self parser parse: aStream + cue: cue - class: class noPattern: noPattern - context: context - notifying: requestor ifFail: [^failBlock value]) preen! Item was changed: ----- Method: Compiler>>interactive (in category 'private') ----- interactive "Answer true if compilation is interactive" + ^ cue requestor notNil! - ^requestor notNil! Item was changed: ----- Method: Compiler>>notify:at: (in category 'error handling') ----- notify: aString at: location "Refer to the comment in Object|notify:." + ^ cue requestor == nil - ^requestor == nil ifTrue: [SyntaxErrorNotification + inClass: cue getClass + category: cue category - inClass: class - category: category withCode: (sourceStream contents copyReplaceFrom: location to: location - 1 with: aString) doitFlag: false errorMessage: aString location: location] + ifFalse: [cue requestor - ifFalse: [requestor notify: aString at: location in: sourceStream]! Item was changed: ----- Method: Compiler>>parse:in:notifying: (in category 'public access') ----- parse: textOrStream in: aClass notifying: req "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." self from: textOrStream class: aClass context: nil notifying: req. ^self parser parse: sourceStream + cue: cue - class: class noPattern: false - context: context - notifying: requestor ifFail: []! Item was changed: ----- Method: Compiler>>parser (in category 'public access') ----- parser + parser ifNil: [parser := (cue getClass ifNil: [self class]) newParser]. - parser ifNil: [parser := (class ifNil: [self class]) newParser]. ^parser! Item was changed: ----- Method: Compiler>>translate:noPattern:ifFail: (in category 'private') ----- translate: aStream noPattern: noPattern ifFail: failBlock ^self parser parse: aStream + cue: cue - class: class - category: category noPattern: noPattern - context: context - notifying: requestor ifFail: [^failBlock value]! Item was changed: ----- Method: Compiler>>translate:noPattern:ifFail:parser: (in category 'public access') ----- translate: aStream noPattern: noPattern ifFail: failBlock parser: parser | tree | tree := parser parse: aStream + cue: cue - class: class noPattern: noPattern - context: context - notifying: requestor ifFail: [^ failBlock value]. ^ tree! Item was changed: ----- Method: Encoder>>associationForClass (in category 'results') ----- associationForClass | assoc | + assoc := self environment associationAt: cue getClass name ifAbsent: [nil]. + ^assoc value == cue getClass - assoc := self environment associationAt: class name ifAbsent: [nil]. - ^assoc value == class ifTrue: [assoc] + ifFalse: [Association new value: cue getClass]! - ifFalse: [Association new value: class]! Item was changed: ----- Method: Encoder>>bindTemp:in: (in category 'temps') ----- bindTemp: name in: methodSelector "Declare a temporary; error not if a field or class variable." scopeTable at: name ifPresent:[:node| "When non-interactive raise the error only if its a duplicate" (node isTemp or:[requestor interactive]) ifTrue:[^self notify:'Name is already defined'] ifFalse:[Transcript + show: '(', name, ' is shadowed in "' , cue getClass printString , '>>' , methodSelector printString , '")']]. - show: '(', name, ' is shadowed in "' , class printString , '>>' , methodSelector printString , '")']]. ^self reallyBind: name! Item was changed: ----- Method: Encoder>>classEncoding (in category 'private') ----- classEncoding "This is a hack so that the parser may findout what class it was parsing for when it wants to create a syntax error view." + ^ cue getClass! - ^ class! Item was changed: ----- Method: Encoder>>encodeLiteral: (in category 'encoding') ----- encodeLiteral: object ^self name: object + key: (cue literalScannedAs: object notifying: self) - key: (class literalScannedAs: object notifying: self) class: LiteralNode type: LdLitType set: litSet! Item was changed: ----- Method: Encoder>>encodeSelector: (in category 'encoding') ----- + encodeSelector: aSelector - encodeSelector: selector ^self + name: aSelector + key: aSelector - name: selector - key: selector class: SelectorNode type: SendType set: selectorSet! Item was changed: ----- Method: Encoder>>environment (in category 'encoding') ----- environment "Answer the environment of the current compilation context, be it in a class or global (e.g. a workspace)" + ^cue environment! - ^class == nil - ifTrue: [Smalltalk globals] - ifFalse: [class environment]! Item was changed: ----- Method: Encoder>>lookupInPools:ifFound: (in category 'private') ----- lookupInPools: varName ifFound: assocBlock ^Symbol hasInterned: varName ifTrue: [:sym| + (cue bindingOf: sym) - (class bindingOf: sym) ifNil: [^false] ifNotNil: [:assoc| assocBlock value: assoc]]! Item was changed: ----- Method: Encoder>>possibleNamesFor: (in category 'private') ----- possibleNamesFor: proposedName | results | + results := cue getClass + possibleVariablesFor: proposedName + continuedFrom: nil. - results := class possibleVariablesFor: proposedName continuedFrom: nil. ^ proposedName correctAgainst: nil continuedFrom: results. ! Item was changed: ----- Method: Encoder>>possibleVariablesFor: (in category 'private') ----- possibleVariablesFor: proposedVariable | results | results := proposedVariable correctAgainstDictionary: scopeTable continuedFrom: nil. proposedVariable first canBeGlobalVarInitial ifTrue: + [ results := cue getClass possibleVariablesFor: proposedVariable - [ results := class possibleVariablesFor: proposedVariable continuedFrom: results ]. ^ proposedVariable correctAgainst: nil continuedFrom: results. ! Item was changed: ----- Method: Encoder>>undeclared: (in category 'encoding') ----- undeclared: name | sym | requestor interactive ifTrue: [requestor requestor == #error: ifTrue: [requestor error: 'Undeclared']. ^self notify: 'Undeclared']. "Allow knowlegeable clients to squash the undeclared warning if they want (e.g. Diffing pretty printers that are simply formatting text). As this breaks compilation it should only be used by clients that want to discard the result of the compilation. To squash the warning use e.g. [Compiler format: code in: class notifying: nil decorated: false] on: UndeclaredVariableWarning do: [:ex| ex resume: false]" sym := name asSymbol. + ^(UndeclaredVariableWarning new name: name selector: selector class: cue getClass) signal - ^(UndeclaredVariableWarning new name: name selector: selector class: class) signal ifTrue: + [| undeclared | + undeclared := cue environment undeclared. + undeclared at: sym put: nil. + self global: (undeclared associationAt: sym) name: sym] - [Undeclared at: sym put: nil. - self global: (Undeclared associationAt: sym) name: sym] ifFalse: [self global: (Association key: sym) name: sym]! Item was changed: ----- Method: Encoder>>warnAboutShadowed: (in category 'private') ----- warnAboutShadowed: name requestor addWarning: name,' is shadowed'. selector ifNotNil: + [Transcript cr; show: cue getClass name,'>>', selector, '(', name,' is shadowed)']! - [Transcript cr; show: class name,'>>', selector, '(', name,' is shadowed)']! Item was changed: ----- Method: Parser>>ambiguousSelector:inRange: (in category 'error correction') ----- ambiguousSelector: aString inRange: anInterval | correctedSelector userSelection offset intervalWithOffset | self interactive ifFalse: [ "In non interactive mode, compile with backward comapatibility: $- is part of literal argument" Transcript cr; store: encoder classEncoding; nextPutAll:#'>>';store: encoder selector; show: ' would send ' , token , '-'. ^super ambiguousSelector: aString inRange: anInterval]. "handle the text selection" + userSelection := cue requestor selectionInterval. - userSelection := requestor selectionInterval. intervalWithOffset := anInterval first + requestorOffset to: anInterval last + requestorOffset. + cue requestor selectFrom: intervalWithOffset first to: intervalWithOffset last. + cue requestor select. - requestor selectFrom: intervalWithOffset first to: intervalWithOffset last. - requestor select. "Build the menu with alternatives" correctedSelector := AmbiguousSelector signalName: aString inRange: intervalWithOffset. correctedSelector ifNil: [^self fail]. "Execute the selected action" offset := self substituteWord: correctedSelector wordInterval: intervalWithOffset offset: 0. + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last + offset. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last + offset. token := (correctedSelector readStream upTo: Character space) asSymbol! Item was changed: ----- Method: Parser>>collectTemporaryDeclarationsFrom: (in category 'error correction') ----- collectTemporaryDeclarationsFrom: methodNode | tempsMarks str | tempsMarks := OrderedCollection new. + str := cue requestor text asString. - str := requestor text asString. methodNode accept: (ParseNodeEnumerator ofBlock: [ :aNode | | mark | (aNode class canUnderstand: #tempsMark) ifTrue: [mark := aNode tempsMark. (mark notNil and: [ mark between: 1 and: str size ] and: [ (str at: mark) = $| ]) ifTrue: [ tempsMarks addLast: aNode ]]]). (tempsMark notNil and: [ tempsMark between: 1 and: str size ] and: [ (str at: tempsMark) = $| ]) ifTrue: [ tempsMarks addLast: self ]. ^ tempsMarks sorted: [ :a :b | a tempsMark > b tempsMark ]! Item was changed: ----- Method: Parser>>correctSelector:wordIntervals:exprInterval:ifAbort: (in category 'error correction') ----- correctSelector: proposedKeyword wordIntervals: spots exprInterval: expInt ifAbort: abortAction "Correct the proposedKeyword to some selector symbol, correcting the original text if such action is indicated. abortAction is invoked if the proposedKeyword couldn't be converted into a valid selector. Spots is an ordered collection of intervals within the test stream of the for each of the keyword parts." | correctSelector userSelection | "If we can't ask the user, assume that the keyword will be defined later" self interactive ifFalse: [^proposedKeyword asSymbol]. + userSelection := cue requestor selectionInterval. + cue requestor selectFrom: spots first first to: spots last last. + cue requestor select. - userSelection := requestor selectionInterval. - requestor selectFrom: spots first first to: spots last last. - requestor select. correctSelector := UnknownSelector name: proposedKeyword. correctSelector ifNil: [^abortAction value]. + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last. self substituteSelector: correctSelector keywords wordIntervals: spots. ^(proposedKeyword last ~~ $: and: [correctSelector last == $:]) ifTrue: [abortAction value] ifFalse: [correctSelector]! Item was changed: ----- Method: Parser>>correctVariable:interval: (in category 'error correction') ----- correctVariable: proposedVariable interval: spot "Correct the proposedVariable to a known variable, or declare it as a new variable if such action is requested. We support declaring lowercase variables as temps or inst-vars, and uppercase variables as Globals or ClassVars, depending on whether the context is nil (class=UndefinedObject). Spot is the interval within the test stream of the variable. rr 3/4/2004 10:26 : adds the option to define a new class. " "Check if this is an i-var, that has been corrected already (ugly)" "Display the pop-up menu" | binding userSelection action | (encoder classEncoding instVarNames includes: proposedVariable) ifTrue: [^InstanceVariableNode new name: proposedVariable index: (encoder classEncoding allInstVarNames indexOf: proposedVariable)]. "If we can't ask the user for correction, make it undeclared" self interactive ifFalse: [^encoder undeclared: proposedVariable]. "First check to see if the requestor knows anything about the variable" + (binding := cue requestor bindingOf: proposedVariable) - (binding := requestor bindingOf: proposedVariable) ifNotNil: [^encoder global: binding name: proposedVariable]. + userSelection := cue requestor selectionInterval. + cue requestor selectFrom: spot first to: spot last. + cue requestor select. - userSelection := requestor selectionInterval. - requestor selectFrom: spot first to: spot last. - requestor select. "Build the menu with alternatives" action := UndeclaredVariable signalFor: self name: proposedVariable inRange: spot. action ifNil: [^self fail]. "Execute the selected action" + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last. ^action value! Item was changed: ----- Method: Parser>>declareUndeclaredTemps: (in category 'error correction') ----- declareUndeclaredTemps: methodNode "Declare any undeclared temps, declaring them at the smallest enclosing scope." | undeclared userSelection blocksToVars | (undeclared := encoder undeclaredTemps) isEmpty ifTrue: [^self]. + userSelection := cue requestor selectionInterval. - userSelection := requestor selectionInterval. blocksToVars := IdentityDictionary new. undeclared do: [:var| (blocksToVars at: (var tag == #method ifTrue: [methodNode block] ifFalse: [methodNode accept: (VariableScopeFinder new ofVariable: var)]) ifAbsentPut: [SortedCollection new]) add: var name]. (blocksToVars removeKey: methodNode block ifAbsent: []) ifNotNil: [:rootVars| rootVars do: [:varName| self pasteTempAtMethodLevel: varName]]. (blocksToVars keys sorted: [:a :b| a tempsMark < b tempsMark]) do: [:block| | decl | decl := (blocksToVars at: block) reduce: [:a :b| a, ' ', b]. block temporaries isEmpty ifTrue: [self substituteWord: ' | ', decl, ' |' wordInterval: (block tempsMark + 1 to: block tempsMark) offset: requestorOffset] ifFalse: [self substituteWord: decl, ' ' wordInterval: (block tempsMark to: block tempsMark - 1) offset: requestorOffset]]. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last + requestorOffset. - requestor selectInvisiblyFrom: userSelection first to: userSelection last + requestorOffset. ReparseAfterSourceEditing signal! Item was changed: ----- Method: Parser>>defineClass: (in category 'error correction') ----- defineClass: className "prompts the user to define a new class, asks for it's category, and lets the users edit further the definition" | sym cat def d2 | sym := className asSymbol. cat := UIManager default request: 'Enter class category : ' initialAnswer: self encoder classEncoding theNonMetaClass category. cat ifEmpty: [cat := 'Unknown']. def := 'Object subclass: #' , sym , ' instanceVariableNames: '''' classVariableNames: '''' poolDictionaries: '''' category: ''' , cat , ''''. d2 := UIManager default request: 'Edit class definition : ' initialAnswer: def. d2 ifEmpty: [d2 := def]. Compiler evaluate: d2. ^ encoder + global: (cue environment bindingOf: sym) - global: (Smalltalk globals associationAt: sym) name: sym! Item was changed: ----- Method: Parser>>externalFunctionDeclaration (in category 'primitives') ----- externalFunctionDeclaration "Parse the function declaration for a call to an external library." | descriptorClass callType modifier retType externalName args argType module fn | + descriptorClass := cue environment + valueOf: #ExternalFunction + ifAbsent: [^ false]. - descriptorClass := Smalltalk at: #ExternalFunction ifAbsent:[nil]. - descriptorClass == nil ifTrue:[^false]. callType := descriptorClass callingConventionFor: here. callType == nil ifTrue:[^false]. [modifier := descriptorClass callingConventionModifierFor: token. modifier notNil] whileTrue: [self advance. callType := callType bitOr: modifier]. "Parse return type" self advance. retType := self externalType: descriptorClass. retType == nil ifTrue:[^self expected:'return type']. "Parse function name or index" externalName := here. (self match: #string) ifTrue:[externalName := externalName asSymbol] ifFalse:[(self match:#number) ifFalse:[^self expected:'function name or index']]. (self matchToken: #'(') ifFalse:[^self expected:'argument list']. args := WriteStream on: Array new. [here == #')'] whileFalse:[ argType := self externalType: descriptorClass. argType == nil ifTrue:[^self expected:'argument']. argType isVoid & argType isPointerType not ifFalse:[args nextPut: argType]. ]. (self matchToken: #')') ifFalse:[^self expected:')']. (self matchToken: 'module:') ifTrue:[ module := here. (self match: #string) ifFalse:[^self expected: 'String']. module := module asSymbol]. Smalltalk at: #ExternalLibraryFunction ifPresent:[:xfn| fn := xfn name: externalName module: module callType: callType returnType: retType argumentTypes: args contents. self allocateLiteral: fn. ]. (self matchToken: 'error:') ifTrue: [| errorCodeVariable | errorCodeVariable := here. (hereType == #string or: [hereType == #word]) ifFalse:[^self expected: 'error code (a variable or string)']. self advance. self addPragma: (Pragma keyword: #primitive:error: arguments: (Array with: 120 with: errorCodeVariable)). fn ifNotNil: [fn setErrorCodeName: errorCodeVariable]] ifFalse: [self addPragma: (Pragma keyword: #primitive: arguments: #(120))]. ^true ! Item was changed: ----- Method: Parser>>interactive (in category 'error handling') ----- interactive "Answer true if compilation is interactive" + ^ cue requestor notNil! - ^requestor notNil! Item was changed: ----- Method: Parser>>notify:at: (in category 'error handling') ----- notify: string at: location + cue requestor isNil - requestor isNil ifTrue: [(encoder == self or: [encoder isNil]) ifTrue: [^ self fail "failure setting up syntax error"]. SyntaxErrorNotification inClass: encoder classEncoding + category: cue category - category: category withCode: (source contents asText copyReplaceFrom: location to: location - 1 with: ((string , ' ->') asText allBold addAttribute: TextColor red; yourself)) doitFlag: doitFlag errorMessage: string location: location] + ifFalse: [cue requestor - ifFalse: [requestor notify: string , ' ->' at: location in: source]. ^self fail! Item was changed: ----- Method: Parser>>pasteTempAtMethodLevel: (in category 'error correction') ----- pasteTempAtMethodLevel: name | insertion delta theTextString characterBeforeMark | + theTextString := cue requestor text string. - theTextString := requestor text string. characterBeforeMark := theTextString at: tempsMark-1 ifAbsent: [$ ]. (theTextString at: tempsMark) = $| ifTrue: [ "Paste it before the second vertical bar" insertion := name, ' '. characterBeforeMark isSeparator ifFalse: [insertion := ' ', insertion]. delta := 0. ] ifFalse: [ "No bars - insert some with CR, tab" insertion := '| ' , name , ' |',String cr. delta := 2. "the bar and CR" characterBeforeMark = Character tab ifTrue: [ insertion := insertion , String tab. delta := delta + 1. "the tab" ]. ]. tempsMark := tempsMark + (self substituteWord: insertion wordInterval: (tempsMark to: tempsMark-1) offset: 0) - delta! Item was changed: ----- Method: Parser>>queryUndefined (in category 'error correction') ----- queryUndefined | varStart varName | varName := parseNode key. varStart := self endOfLastToken + requestorOffset - varName size + 1. + cue requestor selectFrom: varStart to: varStart + varName size - 1; select. - requestor selectFrom: varStart to: varStart + varName size - 1; select. (UndefinedVariable name: varName) ifFalse: [^ self fail]! Item was changed: ----- Method: Parser>>removeEmptyTempDeclarationsFrom: (in category 'error correction') ----- removeEmptyTempDeclarationsFrom: methodNode | sourceCode madeChanges tempsMarkHolder | + sourceCode := cue requestor text asString. - sourceCode := requestor text asString. tempsMarkHolder := self collectTemporaryDeclarationsFrom: methodNode. madeChanges := false. tempsMarkHolder do: [ :currentBlock | | tempsMarkChar0 tempsMarkChar1 tempsMarkChar2 end start | tempsMarkChar0 := (sourceCode at: currentBlock tempsMark). tempsMarkChar1 := (sourceCode at: currentBlock tempsMark - 1). tempsMarkChar2 := (sourceCode at: currentBlock tempsMark - 2). tempsMarkChar0 = $| & tempsMarkChar1 = $| ifTrue: [ end := currentBlock tempsMark. start := end - 1]. tempsMarkChar0 = $| & tempsMarkChar1 = $ & tempsMarkChar2 = $| ifTrue: [ end := currentBlock tempsMark. start := end - 2]. start notNil & end notNil ifTrue: [ | lineStart lineEnd | lineStart := 1 + (sourceCode lastIndexOf: Character cr startingAt: start - 1 ifAbsent: [ 0 ]). lineEnd := sourceCode indexOf: Character cr startingAt: end + 1 ifAbsent: [ sourceCode size ]. ((sourceCode indexOfAnyOf: CharacterSet nonSeparators startingAt: lineStart) >= start and: [ (sourceCode indexOfAnyOf: CharacterSet nonSeparators startingAt: end + 1) > lineEnd ]) ifTrue: [ start := lineStart. end := lineEnd ]. + cue requestor correctFrom: start to: end with: ''. - requestor correctFrom: start to: end with: ''. madeChanges := true. currentBlock tempsMark: nil ] ]. madeChanges ifTrue: [ReparseAfterSourceEditing signal]! Item was changed: ----- Method: Parser>>removeUnusedTemporaryNamed:from:lookingAt:movingTempMarksOf: (in category 'error correction') ----- removeUnusedTemporaryNamed: temp from: str lookingAt: currentBlock movingTempMarksOf: someBlocks | start end | end := currentBlock tempsMark - 1. ["Beginning at right temp marker..." start := end - temp size + 1. end < temp size or: [ (str at: start) = $| ] or: [ temp = (str copyFrom: start to: end) and: [ ((str at: start - 1) = $| | (str at: start - 1) isSeparator) & ((str at: end + 1) = $| | (str at: end + 1) isSeparator) ] ]] whileFalse: [ "Search left for the unused temp" + end := cue requestor nextTokenFrom: end direction: -1 ]. - end := requestor nextTokenFrom: end direction: -1 ]. (end < temp size or: [ (str at: start) = $| ]) ifFalse: [(str at: start - 1) = $ ifTrue: [ start := start - 1 ]. + cue requestor correctFrom: start to: end with: ''. - requestor correctFrom: start to: end with: ''. someBlocks do: [ :aBlock | aBlock tempsMark: aBlock tempsMark - (end - start + 1)]. ^true ]. ^false! Item was changed: ----- Method: Parser>>removeUnusedTemps: (in category 'error correction') ----- removeUnusedTemps: methodNode "Scan for unused temp names, and prompt the user about the prospect of removing each one found" | madeChanges tempsMarkHolder unusedTempNames tempMarkHoldersToChange | madeChanges := false. tempMarkHoldersToChange := OrderedCollection new. tempsMarkHolder := self collectTemporaryDeclarationsFrom: methodNode. unusedTempNames := encoder unusedTempNames select: [ :temp | (encoder lookupVariable: temp ifAbsent: [ ]) isUndefTemp and: [ self queriedUnusedTemporaries at: temp ifAbsentPut: [UnusedVariable name: temp] ]]. tempsMarkHolder do: [ :currentBlock | tempMarkHoldersToChange add: currentBlock. unusedTempNames do: [ :temp | (self removeUnusedTemporaryNamed: temp + from: cue requestor text asString - from: requestor text asString lookingAt: currentBlock movingTempMarksOf: tempMarkHoldersToChange) ifTrue: [ madeChanges := true ]]]. madeChanges ifTrue: [ self removeEmptyTempDeclarationsFrom: methodNode. ReparseAfterSourceEditing signal ]! Item was changed: ----- Method: Parser>>substituteWord:wordInterval:offset: (in category 'error correction') ----- substituteWord: correctWord wordInterval: spot offset: o "Substitute the correctSelector into the (presumed interactive) receiver. Update requestorOffset based on the delta size and answer the updated offset." + cue requestor correctFrom: spot first + o to: spot last + o with: correctWord. - requestor correctFrom: spot first + o to: spot last + o with: correctWord. requestorOffset := requestorOffset + correctWord size - spot size. ^o + correctWord size - spot size! Item was changed: ----- Method: Parser>>temporaries (in category 'expression types') ----- temporaries " [ '|' (variable)* '|' ]" | vars theActualText | (self match: #verticalBar) ifFalse: ["no temps" doitFlag ifTrue: [tempsMark := self interactive + ifTrue: [cue requestor selectionInterval first] - ifTrue: [requestor selectionInterval first] ifFalse: [1]. ^ #()]. tempsMark := hereMark "formerly --> prevMark + prevToken". tempsMark > 0 ifTrue: [theActualText := source contents. [tempsMark < theActualText size and: [(theActualText at: tempsMark) isSeparator]] whileTrue: [tempsMark := tempsMark + 1]]. ^ #()]. vars := OrderedCollection new. [hereType == #word] whileTrue: [vars addLast: (encoder bindTemp: self advance)]. (self match: #verticalBar) ifTrue: [tempsMark := prevMark. ^ vars]. ^ self expected: 'Vertical bar' ! Item was changed: ----- Method: Parser>>temporariesIn: (in category 'expression types') ----- temporariesIn: methodSelector " [ '|' (variable)* '|' ]" | vars theActualText | (self match: #verticalBar) ifFalse: ["no temps" doitFlag ifTrue: [tempsMark := self interactive + ifTrue: [cue requestor selectionInterval first] - ifTrue: [requestor selectionInterval first] ifFalse: [1]. ^ #()]. tempsMark := hereMark "formerly --> prevMark + prevToken". tempsMark > 0 ifTrue: [theActualText := source contents. [tempsMark < theActualText size and: [(theActualText at: tempsMark) isSeparator]] whileTrue: [tempsMark := tempsMark + 1]]. ^ #()]. vars := OrderedCollection new. [hereType == #word] whileTrue: [vars addLast: (encoder bindTemp: self advance in: methodSelector)]. (self match: #verticalBar) ifTrue: [tempsMark := prevMark. ^ vars]. ^ self expected: 'Vertical bar'!
1
0
0
0
The Trunk: Compiler-cwp.247.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-cwp.247.mcz
==================== Summary ==================== Name: Compiler-cwp.247 Author: cwp Time: 1 January 2013, 6:59:31.461 pm UUID: 22f2cbf1-9186-4d2f-8c9c-dffcc0518ffa Ancestors: Compiler-cwp.246 Environments bootstrap - stage 3 =============== Diff against Compiler-cwp.246 =============== Item was changed: ----- 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." + | methodNode method theClass | + theClass := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. + self from: textOrStream class: theClass context: aContext notifying: aRequestor. - | methodNode method | - class := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. - self from: textOrStream class: class context: aContext notifying: aRequestor. methodNode := self translate: sourceStream noPattern: true ifFail: [^failBlock value]. method := self interactive ifTrue: [ methodNode generateWithTempNames ] ifFalse: [methodNode generate]. logFlag ifTrue: [SystemChangeNotifier uniqueInstance evaluated: sourceStream contents context: aContext]. ^method! Item was changed: ----- Method: Compiler>>format:noPattern:ifFail: (in category 'private') ----- format: aStream noPattern: noPattern ifFail: failBlock ^(self parser parse: aStream + cue: cue - class: class noPattern: noPattern - context: context - notifying: requestor ifFail: [^failBlock value]) preen! Item was changed: ----- Method: Compiler>>interactive (in category 'private') ----- interactive "Answer true if compilation is interactive" + ^ cue requestor notNil! - ^requestor notNil! Item was changed: ----- Method: Compiler>>notify:at: (in category 'error handling') ----- notify: aString at: location "Refer to the comment in Object|notify:." + ^ cue requestor == nil - ^requestor == nil ifTrue: [SyntaxErrorNotification + inClass: cue getClass + category: cue category - inClass: class - category: category withCode: (sourceStream contents copyReplaceFrom: location to: location - 1 with: aString) doitFlag: false errorMessage: aString location: location] + ifFalse: [cue requestor - ifFalse: [requestor notify: aString at: location in: sourceStream]! Item was changed: ----- Method: Compiler>>parse:in:notifying: (in category 'public access') ----- parse: textOrStream in: aClass notifying: req "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." self from: textOrStream class: aClass context: nil notifying: req. ^self parser parse: sourceStream + cue: cue - class: class noPattern: false - context: context - notifying: requestor ifFail: []! Item was changed: ----- Method: Compiler>>parser (in category 'public access') ----- parser + parser ifNil: [parser := (cue getClass ifNil: [self class]) newParser]. - parser ifNil: [parser := (class ifNil: [self class]) newParser]. ^parser! Item was changed: ----- Method: Compiler>>translate:noPattern:ifFail: (in category 'private') ----- translate: aStream noPattern: noPattern ifFail: failBlock ^self parser parse: aStream + cue: cue - class: class - category: category noPattern: noPattern - context: context - notifying: requestor ifFail: [^failBlock value]! Item was changed: ----- Method: Compiler>>translate:noPattern:ifFail:parser: (in category 'public access') ----- translate: aStream noPattern: noPattern ifFail: failBlock parser: parser | tree | tree := parser parse: aStream + cue: cue - class: class noPattern: noPattern - context: context - notifying: requestor ifFail: [^ failBlock value]. ^ tree! Item was changed: ----- Method: Encoder>>associationForClass (in category 'results') ----- associationForClass | assoc | + assoc := self environment associationAt: cue getClass name ifAbsent: [nil]. + ^assoc value == cue getClass - assoc := self environment associationAt: class name ifAbsent: [nil]. - ^assoc value == class ifTrue: [assoc] + ifFalse: [Association new value: cue getClass]! - ifFalse: [Association new value: class]! Item was changed: ----- Method: Encoder>>bindTemp:in: (in category 'temps') ----- bindTemp: name in: methodSelector "Declare a temporary; error not if a field or class variable." scopeTable at: name ifPresent:[:node| "When non-interactive raise the error only if its a duplicate" (node isTemp or:[requestor interactive]) ifTrue:[^self notify:'Name is already defined'] ifFalse:[Transcript + show: '(', name, ' is shadowed in "' , cue getClass printString , '>>' , methodSelector printString , '")']]. - show: '(', name, ' is shadowed in "' , class printString , '>>' , methodSelector printString , '")']]. ^self reallyBind: name! Item was changed: ----- Method: Encoder>>classEncoding (in category 'private') ----- classEncoding "This is a hack so that the parser may findout what class it was parsing for when it wants to create a syntax error view." + ^ cue getClass! - ^ class! Item was changed: ----- Method: Encoder>>encodeLiteral: (in category 'encoding') ----- encodeLiteral: object ^self name: object + key: (cue literalScannedAs: object notifying: self) - key: (class literalScannedAs: object notifying: self) class: LiteralNode type: LdLitType set: litSet! Item was changed: ----- Method: Encoder>>encodeSelector: (in category 'encoding') ----- + encodeSelector: aSelector - encodeSelector: selector ^self + name: aSelector + key: aSelector - name: selector - key: selector class: SelectorNode type: SendType set: selectorSet! Item was changed: ----- Method: Encoder>>environment (in category 'encoding') ----- environment "Answer the environment of the current compilation context, be it in a class or global (e.g. a workspace)" + ^cue environment! - ^class == nil - ifTrue: [Smalltalk globals] - ifFalse: [class environment]! Item was changed: ----- Method: Encoder>>lookupInPools:ifFound: (in category 'private') ----- lookupInPools: varName ifFound: assocBlock ^Symbol hasInterned: varName ifTrue: [:sym| + (cue bindingOf: sym) - (class bindingOf: sym) ifNil: [^false] ifNotNil: [:assoc| assocBlock value: assoc]]! Item was changed: ----- Method: Encoder>>possibleNamesFor: (in category 'private') ----- possibleNamesFor: proposedName | results | + results := cue getClass + possibleVariablesFor: proposedName + continuedFrom: nil. - results := class possibleVariablesFor: proposedName continuedFrom: nil. ^ proposedName correctAgainst: nil continuedFrom: results. ! Item was changed: ----- Method: Encoder>>possibleVariablesFor: (in category 'private') ----- possibleVariablesFor: proposedVariable | results | results := proposedVariable correctAgainstDictionary: scopeTable continuedFrom: nil. proposedVariable first canBeGlobalVarInitial ifTrue: + [ results := cue getClass possibleVariablesFor: proposedVariable - [ results := class possibleVariablesFor: proposedVariable continuedFrom: results ]. ^ proposedVariable correctAgainst: nil continuedFrom: results. ! Item was changed: ----- Method: Encoder>>undeclared: (in category 'encoding') ----- undeclared: name | sym | requestor interactive ifTrue: [requestor requestor == #error: ifTrue: [requestor error: 'Undeclared']. ^self notify: 'Undeclared']. "Allow knowlegeable clients to squash the undeclared warning if they want (e.g. Diffing pretty printers that are simply formatting text). As this breaks compilation it should only be used by clients that want to discard the result of the compilation. To squash the warning use e.g. [Compiler format: code in: class notifying: nil decorated: false] on: UndeclaredVariableWarning do: [:ex| ex resume: false]" sym := name asSymbol. + ^(UndeclaredVariableWarning new name: name selector: selector class: cue getClass) signal - ^(UndeclaredVariableWarning new name: name selector: selector class: class) signal ifTrue: + [| undeclared | + undeclared := cue environment undeclared. + undeclared at: sym put: nil. + self global: (undeclared associationAt: sym) name: sym] - [Undeclared at: sym put: nil. - self global: (Undeclared associationAt: sym) name: sym] ifFalse: [self global: (Association key: sym) name: sym]! Item was changed: ----- Method: Encoder>>warnAboutShadowed: (in category 'private') ----- warnAboutShadowed: name requestor addWarning: name,' is shadowed'. selector ifNotNil: + [Transcript cr; show: cue getClass name,'>>', selector, '(', name,' is shadowed)']! - [Transcript cr; show: class name,'>>', selector, '(', name,' is shadowed)']! Item was changed: ----- Method: Parser>>ambiguousSelector:inRange: (in category 'error correction') ----- ambiguousSelector: aString inRange: anInterval | correctedSelector userSelection offset intervalWithOffset | self interactive ifFalse: [ "In non interactive mode, compile with backward comapatibility: $- is part of literal argument" Transcript cr; store: encoder classEncoding; nextPutAll:#'>>';store: encoder selector; show: ' would send ' , token , '-'. ^super ambiguousSelector: aString inRange: anInterval]. "handle the text selection" + userSelection := cue requestor selectionInterval. - userSelection := requestor selectionInterval. intervalWithOffset := anInterval first + requestorOffset to: anInterval last + requestorOffset. + cue requestor selectFrom: intervalWithOffset first to: intervalWithOffset last. + cue requestor select. - requestor selectFrom: intervalWithOffset first to: intervalWithOffset last. - requestor select. "Build the menu with alternatives" correctedSelector := AmbiguousSelector signalName: aString inRange: intervalWithOffset. correctedSelector ifNil: [^self fail]. "Execute the selected action" offset := self substituteWord: correctedSelector wordInterval: intervalWithOffset offset: 0. + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last + offset. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last + offset. token := (correctedSelector readStream upTo: Character space) asSymbol! Item was changed: ----- Method: Parser>>collectTemporaryDeclarationsFrom: (in category 'error correction') ----- collectTemporaryDeclarationsFrom: methodNode | tempsMarks str | tempsMarks := OrderedCollection new. + str := cue requestor text asString. - str := requestor text asString. methodNode accept: (ParseNodeEnumerator ofBlock: [ :aNode | | mark | (aNode class canUnderstand: #tempsMark) ifTrue: [mark := aNode tempsMark. (mark notNil and: [ mark between: 1 and: str size ] and: [ (str at: mark) = $| ]) ifTrue: [ tempsMarks addLast: aNode ]]]). (tempsMark notNil and: [ tempsMark between: 1 and: str size ] and: [ (str at: tempsMark) = $| ]) ifTrue: [ tempsMarks addLast: self ]. ^ tempsMarks sorted: [ :a :b | a tempsMark > b tempsMark ]! Item was changed: ----- Method: Parser>>correctSelector:wordIntervals:exprInterval:ifAbort: (in category 'error correction') ----- correctSelector: proposedKeyword wordIntervals: spots exprInterval: expInt ifAbort: abortAction "Correct the proposedKeyword to some selector symbol, correcting the original text if such action is indicated. abortAction is invoked if the proposedKeyword couldn't be converted into a valid selector. Spots is an ordered collection of intervals within the test stream of the for each of the keyword parts." | correctSelector userSelection | "If we can't ask the user, assume that the keyword will be defined later" self interactive ifFalse: [^proposedKeyword asSymbol]. + userSelection := cue requestor selectionInterval. + cue requestor selectFrom: spots first first to: spots last last. + cue requestor select. - userSelection := requestor selectionInterval. - requestor selectFrom: spots first first to: spots last last. - requestor select. correctSelector := UnknownSelector name: proposedKeyword. correctSelector ifNil: [^abortAction value]. + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last. self substituteSelector: correctSelector keywords wordIntervals: spots. ^(proposedKeyword last ~~ $: and: [correctSelector last == $:]) ifTrue: [abortAction value] ifFalse: [correctSelector]! Item was changed: ----- Method: Parser>>correctVariable:interval: (in category 'error correction') ----- correctVariable: proposedVariable interval: spot "Correct the proposedVariable to a known variable, or declare it as a new variable if such action is requested. We support declaring lowercase variables as temps or inst-vars, and uppercase variables as Globals or ClassVars, depending on whether the context is nil (class=UndefinedObject). Spot is the interval within the test stream of the variable. rr 3/4/2004 10:26 : adds the option to define a new class. " "Check if this is an i-var, that has been corrected already (ugly)" "Display the pop-up menu" | binding userSelection action | (encoder classEncoding instVarNames includes: proposedVariable) ifTrue: [^InstanceVariableNode new name: proposedVariable index: (encoder classEncoding allInstVarNames indexOf: proposedVariable)]. "If we can't ask the user for correction, make it undeclared" self interactive ifFalse: [^encoder undeclared: proposedVariable]. "First check to see if the requestor knows anything about the variable" + (binding := cue requestor bindingOf: proposedVariable) - (binding := requestor bindingOf: proposedVariable) ifNotNil: [^encoder global: binding name: proposedVariable]. + userSelection := cue requestor selectionInterval. + cue requestor selectFrom: spot first to: spot last. + cue requestor select. - userSelection := requestor selectionInterval. - requestor selectFrom: spot first to: spot last. - requestor select. "Build the menu with alternatives" action := UndeclaredVariable signalFor: self name: proposedVariable inRange: spot. action ifNil: [^self fail]. "Execute the selected action" + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last. ^action value! Item was changed: ----- Method: Parser>>declareUndeclaredTemps: (in category 'error correction') ----- declareUndeclaredTemps: methodNode "Declare any undeclared temps, declaring them at the smallest enclosing scope." | undeclared userSelection blocksToVars | (undeclared := encoder undeclaredTemps) isEmpty ifTrue: [^self]. + userSelection := cue requestor selectionInterval. - userSelection := requestor selectionInterval. blocksToVars := IdentityDictionary new. undeclared do: [:var| (blocksToVars at: (var tag == #method ifTrue: [methodNode block] ifFalse: [methodNode accept: (VariableScopeFinder new ofVariable: var)]) ifAbsentPut: [SortedCollection new]) add: var name]. (blocksToVars removeKey: methodNode block ifAbsent: []) ifNotNil: [:rootVars| rootVars do: [:varName| self pasteTempAtMethodLevel: varName]]. (blocksToVars keys sorted: [:a :b| a tempsMark < b tempsMark]) do: [:block| | decl | decl := (blocksToVars at: block) reduce: [:a :b| a, ' ', b]. block temporaries isEmpty ifTrue: [self substituteWord: ' | ', decl, ' |' wordInterval: (block tempsMark + 1 to: block tempsMark) offset: requestorOffset] ifFalse: [self substituteWord: decl, ' ' wordInterval: (block tempsMark to: block tempsMark - 1) offset: requestorOffset]]. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last + requestorOffset. - requestor selectInvisiblyFrom: userSelection first to: userSelection last + requestorOffset. ReparseAfterSourceEditing signal! Item was changed: ----- Method: Parser>>defineClass: (in category 'error correction') ----- defineClass: className "prompts the user to define a new class, asks for it's category, and lets the users edit further the definition" | sym cat def d2 | sym := className asSymbol. cat := UIManager default request: 'Enter class category : ' initialAnswer: self encoder classEncoding theNonMetaClass category. cat ifEmpty: [cat := 'Unknown']. def := 'Object subclass: #' , sym , ' instanceVariableNames: '''' classVariableNames: '''' poolDictionaries: '''' category: ''' , cat , ''''. d2 := UIManager default request: 'Edit class definition : ' initialAnswer: def. d2 ifEmpty: [d2 := def]. Compiler evaluate: d2. ^ encoder + global: (cue environment bindingOf: sym) - global: (Smalltalk globals associationAt: sym) name: sym! Item was changed: ----- Method: Parser>>externalFunctionDeclaration (in category 'primitives') ----- externalFunctionDeclaration "Parse the function declaration for a call to an external library." | descriptorClass callType modifier retType externalName args argType module fn | + descriptorClass := cue environment + valueOf: #ExternalFunction + ifAbsent: [^ false]. - descriptorClass := Smalltalk at: #ExternalFunction ifAbsent:[nil]. - descriptorClass == nil ifTrue:[^false]. callType := descriptorClass callingConventionFor: here. callType == nil ifTrue:[^false]. [modifier := descriptorClass callingConventionModifierFor: token. modifier notNil] whileTrue: [self advance. callType := callType bitOr: modifier]. "Parse return type" self advance. retType := self externalType: descriptorClass. retType == nil ifTrue:[^self expected:'return type']. "Parse function name or index" externalName := here. (self match: #string) ifTrue:[externalName := externalName asSymbol] ifFalse:[(self match:#number) ifFalse:[^self expected:'function name or index']]. (self matchToken: #'(') ifFalse:[^self expected:'argument list']. args := WriteStream on: Array new. [here == #')'] whileFalse:[ argType := self externalType: descriptorClass. argType == nil ifTrue:[^self expected:'argument']. argType isVoid & argType isPointerType not ifFalse:[args nextPut: argType]. ]. (self matchToken: #')') ifFalse:[^self expected:')']. (self matchToken: 'module:') ifTrue:[ module := here. (self match: #string) ifFalse:[^self expected: 'String']. module := module asSymbol]. Smalltalk at: #ExternalLibraryFunction ifPresent:[:xfn| fn := xfn name: externalName module: module callType: callType returnType: retType argumentTypes: args contents. self allocateLiteral: fn. ]. (self matchToken: 'error:') ifTrue: [| errorCodeVariable | errorCodeVariable := here. (hereType == #string or: [hereType == #word]) ifFalse:[^self expected: 'error code (a variable or string)']. self advance. self addPragma: (Pragma keyword: #primitive:error: arguments: (Array with: 120 with: errorCodeVariable)). fn ifNotNil: [fn setErrorCodeName: errorCodeVariable]] ifFalse: [self addPragma: (Pragma keyword: #primitive: arguments: #(120))]. ^true ! Item was changed: ----- Method: Parser>>interactive (in category 'error handling') ----- interactive "Answer true if compilation is interactive" + ^ cue requestor notNil! - ^requestor notNil! Item was changed: ----- Method: Parser>>notify:at: (in category 'error handling') ----- notify: string at: location + cue requestor isNil - requestor isNil ifTrue: [(encoder == self or: [encoder isNil]) ifTrue: [^ self fail "failure setting up syntax error"]. SyntaxErrorNotification inClass: encoder classEncoding + category: cue category - category: category withCode: (source contents asText copyReplaceFrom: location to: location - 1 with: ((string , ' ->') asText allBold addAttribute: TextColor red; yourself)) doitFlag: doitFlag errorMessage: string location: location] + ifFalse: [cue requestor - ifFalse: [requestor notify: string , ' ->' at: location in: source]. ^self fail! Item was changed: ----- Method: Parser>>pasteTempAtMethodLevel: (in category 'error correction') ----- pasteTempAtMethodLevel: name | insertion delta theTextString characterBeforeMark | + theTextString := cue requestor text string. - theTextString := requestor text string. characterBeforeMark := theTextString at: tempsMark-1 ifAbsent: [$ ]. (theTextString at: tempsMark) = $| ifTrue: [ "Paste it before the second vertical bar" insertion := name, ' '. characterBeforeMark isSeparator ifFalse: [insertion := ' ', insertion]. delta := 0. ] ifFalse: [ "No bars - insert some with CR, tab" insertion := '| ' , name , ' |',String cr. delta := 2. "the bar and CR" characterBeforeMark = Character tab ifTrue: [ insertion := insertion , String tab. delta := delta + 1. "the tab" ]. ]. tempsMark := tempsMark + (self substituteWord: insertion wordInterval: (tempsMark to: tempsMark-1) offset: 0) - delta! Item was changed: ----- Method: Parser>>queryUndefined (in category 'error correction') ----- queryUndefined | varStart varName | varName := parseNode key. varStart := self endOfLastToken + requestorOffset - varName size + 1. + cue requestor selectFrom: varStart to: varStart + varName size - 1; select. - requestor selectFrom: varStart to: varStart + varName size - 1; select. (UndefinedVariable name: varName) ifFalse: [^ self fail]! Item was changed: ----- Method: Parser>>removeEmptyTempDeclarationsFrom: (in category 'error correction') ----- removeEmptyTempDeclarationsFrom: methodNode | sourceCode madeChanges tempsMarkHolder | + sourceCode := cue requestor text asString. - sourceCode := requestor text asString. tempsMarkHolder := self collectTemporaryDeclarationsFrom: methodNode. madeChanges := false. tempsMarkHolder do: [ :currentBlock | | tempsMarkChar0 tempsMarkChar1 tempsMarkChar2 end start | tempsMarkChar0 := (sourceCode at: currentBlock tempsMark). tempsMarkChar1 := (sourceCode at: currentBlock tempsMark - 1). tempsMarkChar2 := (sourceCode at: currentBlock tempsMark - 2). tempsMarkChar0 = $| & tempsMarkChar1 = $| ifTrue: [ end := currentBlock tempsMark. start := end - 1]. tempsMarkChar0 = $| & tempsMarkChar1 = $ & tempsMarkChar2 = $| ifTrue: [ end := currentBlock tempsMark. start := end - 2]. start notNil & end notNil ifTrue: [ | lineStart lineEnd | lineStart := 1 + (sourceCode lastIndexOf: Character cr startingAt: start - 1 ifAbsent: [ 0 ]). lineEnd := sourceCode indexOf: Character cr startingAt: end + 1 ifAbsent: [ sourceCode size ]. ((sourceCode indexOfAnyOf: CharacterSet nonSeparators startingAt: lineStart) >= start and: [ (sourceCode indexOfAnyOf: CharacterSet nonSeparators startingAt: end + 1) > lineEnd ]) ifTrue: [ start := lineStart. end := lineEnd ]. + cue requestor correctFrom: start to: end with: ''. - requestor correctFrom: start to: end with: ''. madeChanges := true. currentBlock tempsMark: nil ] ]. madeChanges ifTrue: [ReparseAfterSourceEditing signal]! Item was changed: ----- Method: Parser>>removeUnusedTemporaryNamed:from:lookingAt:movingTempMarksOf: (in category 'error correction') ----- removeUnusedTemporaryNamed: temp from: str lookingAt: currentBlock movingTempMarksOf: someBlocks | start end | end := currentBlock tempsMark - 1. ["Beginning at right temp marker..." start := end - temp size + 1. end < temp size or: [ (str at: start) = $| ] or: [ temp = (str copyFrom: start to: end) and: [ ((str at: start - 1) = $| | (str at: start - 1) isSeparator) & ((str at: end + 1) = $| | (str at: end + 1) isSeparator) ] ]] whileFalse: [ "Search left for the unused temp" + end := cue requestor nextTokenFrom: end direction: -1 ]. - end := requestor nextTokenFrom: end direction: -1 ]. (end < temp size or: [ (str at: start) = $| ]) ifFalse: [(str at: start - 1) = $ ifTrue: [ start := start - 1 ]. + cue requestor correctFrom: start to: end with: ''. - requestor correctFrom: start to: end with: ''. someBlocks do: [ :aBlock | aBlock tempsMark: aBlock tempsMark - (end - start + 1)]. ^true ]. ^false! Item was changed: ----- Method: Parser>>removeUnusedTemps: (in category 'error correction') ----- removeUnusedTemps: methodNode "Scan for unused temp names, and prompt the user about the prospect of removing each one found" | madeChanges tempsMarkHolder unusedTempNames tempMarkHoldersToChange | madeChanges := false. tempMarkHoldersToChange := OrderedCollection new. tempsMarkHolder := self collectTemporaryDeclarationsFrom: methodNode. unusedTempNames := encoder unusedTempNames select: [ :temp | (encoder lookupVariable: temp ifAbsent: [ ]) isUndefTemp and: [ self queriedUnusedTemporaries at: temp ifAbsentPut: [UnusedVariable name: temp] ]]. tempsMarkHolder do: [ :currentBlock | tempMarkHoldersToChange add: currentBlock. unusedTempNames do: [ :temp | (self removeUnusedTemporaryNamed: temp + from: cue requestor text asString - from: requestor text asString lookingAt: currentBlock movingTempMarksOf: tempMarkHoldersToChange) ifTrue: [ madeChanges := true ]]]. madeChanges ifTrue: [ self removeEmptyTempDeclarationsFrom: methodNode. ReparseAfterSourceEditing signal ]! Item was changed: ----- Method: Parser>>substituteWord:wordInterval:offset: (in category 'error correction') ----- substituteWord: correctWord wordInterval: spot offset: o "Substitute the correctSelector into the (presumed interactive) receiver. Update requestorOffset based on the delta size and answer the updated offset." + cue requestor correctFrom: spot first + o to: spot last + o with: correctWord. - requestor correctFrom: spot first + o to: spot last + o with: correctWord. requestorOffset := requestorOffset + correctWord size - spot size. ^o + correctWord size - spot size! Item was changed: ----- Method: Parser>>temporaries (in category 'expression types') ----- temporaries " [ '|' (variable)* '|' ]" | vars theActualText | (self match: #verticalBar) ifFalse: ["no temps" doitFlag ifTrue: [tempsMark := self interactive + ifTrue: [cue requestor selectionInterval first] - ifTrue: [requestor selectionInterval first] ifFalse: [1]. ^ #()]. tempsMark := hereMark "formerly --> prevMark + prevToken". tempsMark > 0 ifTrue: [theActualText := source contents. [tempsMark < theActualText size and: [(theActualText at: tempsMark) isSeparator]] whileTrue: [tempsMark := tempsMark + 1]]. ^ #()]. vars := OrderedCollection new. [hereType == #word] whileTrue: [vars addLast: (encoder bindTemp: self advance)]. (self match: #verticalBar) ifTrue: [tempsMark := prevMark. ^ vars]. ^ self expected: 'Vertical bar' ! Item was changed: ----- Method: Parser>>temporariesIn: (in category 'expression types') ----- temporariesIn: methodSelector " [ '|' (variable)* '|' ]" | vars theActualText | (self match: #verticalBar) ifFalse: ["no temps" doitFlag ifTrue: [tempsMark := self interactive + ifTrue: [cue requestor selectionInterval first] - ifTrue: [requestor selectionInterval first] ifFalse: [1]. ^ #()]. tempsMark := hereMark "formerly --> prevMark + prevToken". tempsMark > 0 ifTrue: [theActualText := source contents. [tempsMark < theActualText size and: [(theActualText at: tempsMark) isSeparator]] whileTrue: [tempsMark := tempsMark + 1]]. ^ #()]. vars := OrderedCollection new. [hereType == #word] whileTrue: [vars addLast: (encoder bindTemp: self advance in: methodSelector)]. (self match: #verticalBar) ifTrue: [tempsMark := prevMark. ^ vars]. ^ self expected: 'Vertical bar'!
1
0
0
0
The Trunk: Compiler-cwp.247.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-cwp.247.mcz
==================== Summary ==================== Name: Compiler-cwp.247 Author: cwp Time: 1 January 2013, 6:59:31.461 pm UUID: 22f2cbf1-9186-4d2f-8c9c-dffcc0518ffa Ancestors: Compiler-cwp.246 Environments bootstrap - stage 3 =============== Diff against Compiler-cwp.246 =============== Item was changed: ----- 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." + | methodNode method theClass | + theClass := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. + self from: textOrStream class: theClass context: aContext notifying: aRequestor. - | methodNode method | - class := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. - self from: textOrStream class: class context: aContext notifying: aRequestor. methodNode := self translate: sourceStream noPattern: true ifFail: [^failBlock value]. method := self interactive ifTrue: [ methodNode generateWithTempNames ] ifFalse: [methodNode generate]. logFlag ifTrue: [SystemChangeNotifier uniqueInstance evaluated: sourceStream contents context: aContext]. ^method! Item was changed: ----- Method: Compiler>>format:noPattern:ifFail: (in category 'private') ----- format: aStream noPattern: noPattern ifFail: failBlock ^(self parser parse: aStream + cue: cue - class: class noPattern: noPattern - context: context - notifying: requestor ifFail: [^failBlock value]) preen! Item was changed: ----- Method: Compiler>>interactive (in category 'private') ----- interactive "Answer true if compilation is interactive" + ^ cue requestor notNil! - ^requestor notNil! Item was changed: ----- Method: Compiler>>notify:at: (in category 'error handling') ----- notify: aString at: location "Refer to the comment in Object|notify:." + ^ cue requestor == nil - ^requestor == nil ifTrue: [SyntaxErrorNotification + inClass: cue getClass + category: cue category - inClass: class - category: category withCode: (sourceStream contents copyReplaceFrom: location to: location - 1 with: aString) doitFlag: false errorMessage: aString location: location] + ifFalse: [cue requestor - ifFalse: [requestor notify: aString at: location in: sourceStream]! Item was changed: ----- Method: Compiler>>parse:in:notifying: (in category 'public access') ----- parse: textOrStream in: aClass notifying: req "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." self from: textOrStream class: aClass context: nil notifying: req. ^self parser parse: sourceStream + cue: cue - class: class noPattern: false - context: context - notifying: requestor ifFail: []! Item was changed: ----- Method: Compiler>>parser (in category 'public access') ----- parser + parser ifNil: [parser := (cue getClass ifNil: [self class]) newParser]. - parser ifNil: [parser := (class ifNil: [self class]) newParser]. ^parser! Item was changed: ----- Method: Compiler>>translate:noPattern:ifFail: (in category 'private') ----- translate: aStream noPattern: noPattern ifFail: failBlock ^self parser parse: aStream + cue: cue - class: class - category: category noPattern: noPattern - context: context - notifying: requestor ifFail: [^failBlock value]! Item was changed: ----- Method: Compiler>>translate:noPattern:ifFail:parser: (in category 'public access') ----- translate: aStream noPattern: noPattern ifFail: failBlock parser: parser | tree | tree := parser parse: aStream + cue: cue - class: class noPattern: noPattern - context: context - notifying: requestor ifFail: [^ failBlock value]. ^ tree! Item was changed: ----- Method: Encoder>>associationForClass (in category 'results') ----- associationForClass | assoc | + assoc := self environment associationAt: cue getClass name ifAbsent: [nil]. + ^assoc value == cue getClass - assoc := self environment associationAt: class name ifAbsent: [nil]. - ^assoc value == class ifTrue: [assoc] + ifFalse: [Association new value: cue getClass]! - ifFalse: [Association new value: class]! Item was changed: ----- Method: Encoder>>bindTemp:in: (in category 'temps') ----- bindTemp: name in: methodSelector "Declare a temporary; error not if a field or class variable." scopeTable at: name ifPresent:[:node| "When non-interactive raise the error only if its a duplicate" (node isTemp or:[requestor interactive]) ifTrue:[^self notify:'Name is already defined'] ifFalse:[Transcript + show: '(', name, ' is shadowed in "' , cue getClass printString , '>>' , methodSelector printString , '")']]. - show: '(', name, ' is shadowed in "' , class printString , '>>' , methodSelector printString , '")']]. ^self reallyBind: name! Item was changed: ----- Method: Encoder>>classEncoding (in category 'private') ----- classEncoding "This is a hack so that the parser may findout what class it was parsing for when it wants to create a syntax error view." + ^ cue getClass! - ^ class! Item was changed: ----- Method: Encoder>>encodeLiteral: (in category 'encoding') ----- encodeLiteral: object ^self name: object + key: (cue literalScannedAs: object notifying: self) - key: (class literalScannedAs: object notifying: self) class: LiteralNode type: LdLitType set: litSet! Item was changed: ----- Method: Encoder>>encodeSelector: (in category 'encoding') ----- + encodeSelector: aSelector - encodeSelector: selector ^self + name: aSelector + key: aSelector - name: selector - key: selector class: SelectorNode type: SendType set: selectorSet! Item was changed: ----- Method: Encoder>>environment (in category 'encoding') ----- environment "Answer the environment of the current compilation context, be it in a class or global (e.g. a workspace)" + ^cue environment! - ^class == nil - ifTrue: [Smalltalk globals] - ifFalse: [class environment]! Item was changed: ----- Method: Encoder>>lookupInPools:ifFound: (in category 'private') ----- lookupInPools: varName ifFound: assocBlock ^Symbol hasInterned: varName ifTrue: [:sym| + (cue bindingOf: sym) - (class bindingOf: sym) ifNil: [^false] ifNotNil: [:assoc| assocBlock value: assoc]]! Item was changed: ----- Method: Encoder>>possibleNamesFor: (in category 'private') ----- possibleNamesFor: proposedName | results | + results := cue getClass + possibleVariablesFor: proposedName + continuedFrom: nil. - results := class possibleVariablesFor: proposedName continuedFrom: nil. ^ proposedName correctAgainst: nil continuedFrom: results. ! Item was changed: ----- Method: Encoder>>possibleVariablesFor: (in category 'private') ----- possibleVariablesFor: proposedVariable | results | results := proposedVariable correctAgainstDictionary: scopeTable continuedFrom: nil. proposedVariable first canBeGlobalVarInitial ifTrue: + [ results := cue getClass possibleVariablesFor: proposedVariable - [ results := class possibleVariablesFor: proposedVariable continuedFrom: results ]. ^ proposedVariable correctAgainst: nil continuedFrom: results. ! Item was changed: ----- Method: Encoder>>undeclared: (in category 'encoding') ----- undeclared: name | sym | requestor interactive ifTrue: [requestor requestor == #error: ifTrue: [requestor error: 'Undeclared']. ^self notify: 'Undeclared']. "Allow knowlegeable clients to squash the undeclared warning if they want (e.g. Diffing pretty printers that are simply formatting text). As this breaks compilation it should only be used by clients that want to discard the result of the compilation. To squash the warning use e.g. [Compiler format: code in: class notifying: nil decorated: false] on: UndeclaredVariableWarning do: [:ex| ex resume: false]" sym := name asSymbol. + ^(UndeclaredVariableWarning new name: name selector: selector class: cue getClass) signal - ^(UndeclaredVariableWarning new name: name selector: selector class: class) signal ifTrue: + [| undeclared | + undeclared := cue environment undeclared. + undeclared at: sym put: nil. + self global: (undeclared associationAt: sym) name: sym] - [Undeclared at: sym put: nil. - self global: (Undeclared associationAt: sym) name: sym] ifFalse: [self global: (Association key: sym) name: sym]! Item was changed: ----- Method: Encoder>>warnAboutShadowed: (in category 'private') ----- warnAboutShadowed: name requestor addWarning: name,' is shadowed'. selector ifNotNil: + [Transcript cr; show: cue getClass name,'>>', selector, '(', name,' is shadowed)']! - [Transcript cr; show: class name,'>>', selector, '(', name,' is shadowed)']! Item was changed: ----- Method: Parser>>ambiguousSelector:inRange: (in category 'error correction') ----- ambiguousSelector: aString inRange: anInterval | correctedSelector userSelection offset intervalWithOffset | self interactive ifFalse: [ "In non interactive mode, compile with backward comapatibility: $- is part of literal argument" Transcript cr; store: encoder classEncoding; nextPutAll:#'>>';store: encoder selector; show: ' would send ' , token , '-'. ^super ambiguousSelector: aString inRange: anInterval]. "handle the text selection" + userSelection := cue requestor selectionInterval. - userSelection := requestor selectionInterval. intervalWithOffset := anInterval first + requestorOffset to: anInterval last + requestorOffset. + cue requestor selectFrom: intervalWithOffset first to: intervalWithOffset last. + cue requestor select. - requestor selectFrom: intervalWithOffset first to: intervalWithOffset last. - requestor select. "Build the menu with alternatives" correctedSelector := AmbiguousSelector signalName: aString inRange: intervalWithOffset. correctedSelector ifNil: [^self fail]. "Execute the selected action" offset := self substituteWord: correctedSelector wordInterval: intervalWithOffset offset: 0. + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last + offset. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last + offset. token := (correctedSelector readStream upTo: Character space) asSymbol! Item was changed: ----- Method: Parser>>collectTemporaryDeclarationsFrom: (in category 'error correction') ----- collectTemporaryDeclarationsFrom: methodNode | tempsMarks str | tempsMarks := OrderedCollection new. + str := cue requestor text asString. - str := requestor text asString. methodNode accept: (ParseNodeEnumerator ofBlock: [ :aNode | | mark | (aNode class canUnderstand: #tempsMark) ifTrue: [mark := aNode tempsMark. (mark notNil and: [ mark between: 1 and: str size ] and: [ (str at: mark) = $| ]) ifTrue: [ tempsMarks addLast: aNode ]]]). (tempsMark notNil and: [ tempsMark between: 1 and: str size ] and: [ (str at: tempsMark) = $| ]) ifTrue: [ tempsMarks addLast: self ]. ^ tempsMarks sorted: [ :a :b | a tempsMark > b tempsMark ]! Item was changed: ----- Method: Parser>>correctSelector:wordIntervals:exprInterval:ifAbort: (in category 'error correction') ----- correctSelector: proposedKeyword wordIntervals: spots exprInterval: expInt ifAbort: abortAction "Correct the proposedKeyword to some selector symbol, correcting the original text if such action is indicated. abortAction is invoked if the proposedKeyword couldn't be converted into a valid selector. Spots is an ordered collection of intervals within the test stream of the for each of the keyword parts." | correctSelector userSelection | "If we can't ask the user, assume that the keyword will be defined later" self interactive ifFalse: [^proposedKeyword asSymbol]. + userSelection := cue requestor selectionInterval. + cue requestor selectFrom: spots first first to: spots last last. + cue requestor select. - userSelection := requestor selectionInterval. - requestor selectFrom: spots first first to: spots last last. - requestor select. correctSelector := UnknownSelector name: proposedKeyword. correctSelector ifNil: [^abortAction value]. + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last. self substituteSelector: correctSelector keywords wordIntervals: spots. ^(proposedKeyword last ~~ $: and: [correctSelector last == $:]) ifTrue: [abortAction value] ifFalse: [correctSelector]! Item was changed: ----- Method: Parser>>correctVariable:interval: (in category 'error correction') ----- correctVariable: proposedVariable interval: spot "Correct the proposedVariable to a known variable, or declare it as a new variable if such action is requested. We support declaring lowercase variables as temps or inst-vars, and uppercase variables as Globals or ClassVars, depending on whether the context is nil (class=UndefinedObject). Spot is the interval within the test stream of the variable. rr 3/4/2004 10:26 : adds the option to define a new class. " "Check if this is an i-var, that has been corrected already (ugly)" "Display the pop-up menu" | binding userSelection action | (encoder classEncoding instVarNames includes: proposedVariable) ifTrue: [^InstanceVariableNode new name: proposedVariable index: (encoder classEncoding allInstVarNames indexOf: proposedVariable)]. "If we can't ask the user for correction, make it undeclared" self interactive ifFalse: [^encoder undeclared: proposedVariable]. "First check to see if the requestor knows anything about the variable" + (binding := cue requestor bindingOf: proposedVariable) - (binding := requestor bindingOf: proposedVariable) ifNotNil: [^encoder global: binding name: proposedVariable]. + userSelection := cue requestor selectionInterval. + cue requestor selectFrom: spot first to: spot last. + cue requestor select. - userSelection := requestor selectionInterval. - requestor selectFrom: spot first to: spot last. - requestor select. "Build the menu with alternatives" action := UndeclaredVariable signalFor: self name: proposedVariable inRange: spot. action ifNil: [^self fail]. "Execute the selected action" + cue requestor deselect. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last. - requestor deselect. - requestor selectInvisiblyFrom: userSelection first to: userSelection last. ^action value! Item was changed: ----- Method: Parser>>declareUndeclaredTemps: (in category 'error correction') ----- declareUndeclaredTemps: methodNode "Declare any undeclared temps, declaring them at the smallest enclosing scope." | undeclared userSelection blocksToVars | (undeclared := encoder undeclaredTemps) isEmpty ifTrue: [^self]. + userSelection := cue requestor selectionInterval. - userSelection := requestor selectionInterval. blocksToVars := IdentityDictionary new. undeclared do: [:var| (blocksToVars at: (var tag == #method ifTrue: [methodNode block] ifFalse: [methodNode accept: (VariableScopeFinder new ofVariable: var)]) ifAbsentPut: [SortedCollection new]) add: var name]. (blocksToVars removeKey: methodNode block ifAbsent: []) ifNotNil: [:rootVars| rootVars do: [:varName| self pasteTempAtMethodLevel: varName]]. (blocksToVars keys sorted: [:a :b| a tempsMark < b tempsMark]) do: [:block| | decl | decl := (blocksToVars at: block) reduce: [:a :b| a, ' ', b]. block temporaries isEmpty ifTrue: [self substituteWord: ' | ', decl, ' |' wordInterval: (block tempsMark + 1 to: block tempsMark) offset: requestorOffset] ifFalse: [self substituteWord: decl, ' ' wordInterval: (block tempsMark to: block tempsMark - 1) offset: requestorOffset]]. + cue requestor selectInvisiblyFrom: userSelection first to: userSelection last + requestorOffset. - requestor selectInvisiblyFrom: userSelection first to: userSelection last + requestorOffset. ReparseAfterSourceEditing signal! Item was changed: ----- Method: Parser>>defineClass: (in category 'error correction') ----- defineClass: className "prompts the user to define a new class, asks for it's category, and lets the users edit further the definition" | sym cat def d2 | sym := className asSymbol. cat := UIManager default request: 'Enter class category : ' initialAnswer: self encoder classEncoding theNonMetaClass category. cat ifEmpty: [cat := 'Unknown']. def := 'Object subclass: #' , sym , ' instanceVariableNames: '''' classVariableNames: '''' poolDictionaries: '''' category: ''' , cat , ''''. d2 := UIManager default request: 'Edit class definition : ' initialAnswer: def. d2 ifEmpty: [d2 := def]. Compiler evaluate: d2. ^ encoder + global: (cue environment bindingOf: sym) - global: (Smalltalk globals associationAt: sym) name: sym! Item was changed: ----- Method: Parser>>externalFunctionDeclaration (in category 'primitives') ----- externalFunctionDeclaration "Parse the function declaration for a call to an external library." | descriptorClass callType modifier retType externalName args argType module fn | + descriptorClass := cue environment + valueOf: #ExternalFunction + ifAbsent: [^ false]. - descriptorClass := Smalltalk at: #ExternalFunction ifAbsent:[nil]. - descriptorClass == nil ifTrue:[^false]. callType := descriptorClass callingConventionFor: here. callType == nil ifTrue:[^false]. [modifier := descriptorClass callingConventionModifierFor: token. modifier notNil] whileTrue: [self advance. callType := callType bitOr: modifier]. "Parse return type" self advance. retType := self externalType: descriptorClass. retType == nil ifTrue:[^self expected:'return type']. "Parse function name or index" externalName := here. (self match: #string) ifTrue:[externalName := externalName asSymbol] ifFalse:[(self match:#number) ifFalse:[^self expected:'function name or index']]. (self matchToken: #'(') ifFalse:[^self expected:'argument list']. args := WriteStream on: Array new. [here == #')'] whileFalse:[ argType := self externalType: descriptorClass. argType == nil ifTrue:[^self expected:'argument']. argType isVoid & argType isPointerType not ifFalse:[args nextPut: argType]. ]. (self matchToken: #')') ifFalse:[^self expected:')']. (self matchToken: 'module:') ifTrue:[ module := here. (self match: #string) ifFalse:[^self expected: 'String']. module := module asSymbol]. Smalltalk at: #ExternalLibraryFunction ifPresent:[:xfn| fn := xfn name: externalName module: module callType: callType returnType: retType argumentTypes: args contents. self allocateLiteral: fn. ]. (self matchToken: 'error:') ifTrue: [| errorCodeVariable | errorCodeVariable := here. (hereType == #string or: [hereType == #word]) ifFalse:[^self expected: 'error code (a variable or string)']. self advance. self addPragma: (Pragma keyword: #primitive:error: arguments: (Array with: 120 with: errorCodeVariable)). fn ifNotNil: [fn setErrorCodeName: errorCodeVariable]] ifFalse: [self addPragma: (Pragma keyword: #primitive: arguments: #(120))]. ^true ! Item was changed: ----- Method: Parser>>interactive (in category 'error handling') ----- interactive "Answer true if compilation is interactive" + ^ cue requestor notNil! - ^requestor notNil! Item was changed: ----- Method: Parser>>notify:at: (in category 'error handling') ----- notify: string at: location + cue requestor isNil - requestor isNil ifTrue: [(encoder == self or: [encoder isNil]) ifTrue: [^ self fail "failure setting up syntax error"]. SyntaxErrorNotification inClass: encoder classEncoding + category: cue category - category: category withCode: (source contents asText copyReplaceFrom: location to: location - 1 with: ((string , ' ->') asText allBold addAttribute: TextColor red; yourself)) doitFlag: doitFlag errorMessage: string location: location] + ifFalse: [cue requestor - ifFalse: [requestor notify: string , ' ->' at: location in: source]. ^self fail! Item was changed: ----- Method: Parser>>pasteTempAtMethodLevel: (in category 'error correction') ----- pasteTempAtMethodLevel: name | insertion delta theTextString characterBeforeMark | + theTextString := cue requestor text string. - theTextString := requestor text string. characterBeforeMark := theTextString at: tempsMark-1 ifAbsent: [$ ]. (theTextString at: tempsMark) = $| ifTrue: [ "Paste it before the second vertical bar" insertion := name, ' '. characterBeforeMark isSeparator ifFalse: [insertion := ' ', insertion]. delta := 0. ] ifFalse: [ "No bars - insert some with CR, tab" insertion := '| ' , name , ' |',String cr. delta := 2. "the bar and CR" characterBeforeMark = Character tab ifTrue: [ insertion := insertion , String tab. delta := delta + 1. "the tab" ]. ]. tempsMark := tempsMark + (self substituteWord: insertion wordInterval: (tempsMark to: tempsMark-1) offset: 0) - delta! Item was changed: ----- Method: Parser>>queryUndefined (in category 'error correction') ----- queryUndefined | varStart varName | varName := parseNode key. varStart := self endOfLastToken + requestorOffset - varName size + 1. + cue requestor selectFrom: varStart to: varStart + varName size - 1; select. - requestor selectFrom: varStart to: varStart + varName size - 1; select. (UndefinedVariable name: varName) ifFalse: [^ self fail]! Item was changed: ----- Method: Parser>>removeEmptyTempDeclarationsFrom: (in category 'error correction') ----- removeEmptyTempDeclarationsFrom: methodNode | sourceCode madeChanges tempsMarkHolder | + sourceCode := cue requestor text asString. - sourceCode := requestor text asString. tempsMarkHolder := self collectTemporaryDeclarationsFrom: methodNode. madeChanges := false. tempsMarkHolder do: [ :currentBlock | | tempsMarkChar0 tempsMarkChar1 tempsMarkChar2 end start | tempsMarkChar0 := (sourceCode at: currentBlock tempsMark). tempsMarkChar1 := (sourceCode at: currentBlock tempsMark - 1). tempsMarkChar2 := (sourceCode at: currentBlock tempsMark - 2). tempsMarkChar0 = $| & tempsMarkChar1 = $| ifTrue: [ end := currentBlock tempsMark. start := end - 1]. tempsMarkChar0 = $| & tempsMarkChar1 = $ & tempsMarkChar2 = $| ifTrue: [ end := currentBlock tempsMark. start := end - 2]. start notNil & end notNil ifTrue: [ | lineStart lineEnd | lineStart := 1 + (sourceCode lastIndexOf: Character cr startingAt: start - 1 ifAbsent: [ 0 ]). lineEnd := sourceCode indexOf: Character cr startingAt: end + 1 ifAbsent: [ sourceCode size ]. ((sourceCode indexOfAnyOf: CharacterSet nonSeparators startingAt: lineStart) >= start and: [ (sourceCode indexOfAnyOf: CharacterSet nonSeparators startingAt: end + 1) > lineEnd ]) ifTrue: [ start := lineStart. end := lineEnd ]. + cue requestor correctFrom: start to: end with: ''. - requestor correctFrom: start to: end with: ''. madeChanges := true. currentBlock tempsMark: nil ] ]. madeChanges ifTrue: [ReparseAfterSourceEditing signal]! Item was changed: ----- Method: Parser>>removeUnusedTemporaryNamed:from:lookingAt:movingTempMarksOf: (in category 'error correction') ----- removeUnusedTemporaryNamed: temp from: str lookingAt: currentBlock movingTempMarksOf: someBlocks | start end | end := currentBlock tempsMark - 1. ["Beginning at right temp marker..." start := end - temp size + 1. end < temp size or: [ (str at: start) = $| ] or: [ temp = (str copyFrom: start to: end) and: [ ((str at: start - 1) = $| | (str at: start - 1) isSeparator) & ((str at: end + 1) = $| | (str at: end + 1) isSeparator) ] ]] whileFalse: [ "Search left for the unused temp" + end := cue requestor nextTokenFrom: end direction: -1 ]. - end := requestor nextTokenFrom: end direction: -1 ]. (end < temp size or: [ (str at: start) = $| ]) ifFalse: [(str at: start - 1) = $ ifTrue: [ start := start - 1 ]. + cue requestor correctFrom: start to: end with: ''. - requestor correctFrom: start to: end with: ''. someBlocks do: [ :aBlock | aBlock tempsMark: aBlock tempsMark - (end - start + 1)]. ^true ]. ^false! Item was changed: ----- Method: Parser>>removeUnusedTemps: (in category 'error correction') ----- removeUnusedTemps: methodNode "Scan for unused temp names, and prompt the user about the prospect of removing each one found" | madeChanges tempsMarkHolder unusedTempNames tempMarkHoldersToChange | madeChanges := false. tempMarkHoldersToChange := OrderedCollection new. tempsMarkHolder := self collectTemporaryDeclarationsFrom: methodNode. unusedTempNames := encoder unusedTempNames select: [ :temp | (encoder lookupVariable: temp ifAbsent: [ ]) isUndefTemp and: [ self queriedUnusedTemporaries at: temp ifAbsentPut: [UnusedVariable name: temp] ]]. tempsMarkHolder do: [ :currentBlock | tempMarkHoldersToChange add: currentBlock. unusedTempNames do: [ :temp | (self removeUnusedTemporaryNamed: temp + from: cue requestor text asString - from: requestor text asString lookingAt: currentBlock movingTempMarksOf: tempMarkHoldersToChange) ifTrue: [ madeChanges := true ]]]. madeChanges ifTrue: [ self removeEmptyTempDeclarationsFrom: methodNode. ReparseAfterSourceEditing signal ]! Item was changed: ----- Method: Parser>>substituteWord:wordInterval:offset: (in category 'error correction') ----- substituteWord: correctWord wordInterval: spot offset: o "Substitute the correctSelector into the (presumed interactive) receiver. Update requestorOffset based on the delta size and answer the updated offset." + cue requestor correctFrom: spot first + o to: spot last + o with: correctWord. - requestor correctFrom: spot first + o to: spot last + o with: correctWord. requestorOffset := requestorOffset + correctWord size - spot size. ^o + correctWord size - spot size! Item was changed: ----- Method: Parser>>temporaries (in category 'expression types') ----- temporaries " [ '|' (variable)* '|' ]" | vars theActualText | (self match: #verticalBar) ifFalse: ["no temps" doitFlag ifTrue: [tempsMark := self interactive + ifTrue: [cue requestor selectionInterval first] - ifTrue: [requestor selectionInterval first] ifFalse: [1]. ^ #()]. tempsMark := hereMark "formerly --> prevMark + prevToken". tempsMark > 0 ifTrue: [theActualText := source contents. [tempsMark < theActualText size and: [(theActualText at: tempsMark) isSeparator]] whileTrue: [tempsMark := tempsMark + 1]]. ^ #()]. vars := OrderedCollection new. [hereType == #word] whileTrue: [vars addLast: (encoder bindTemp: self advance)]. (self match: #verticalBar) ifTrue: [tempsMark := prevMark. ^ vars]. ^ self expected: 'Vertical bar' ! Item was changed: ----- Method: Parser>>temporariesIn: (in category 'expression types') ----- temporariesIn: methodSelector " [ '|' (variable)* '|' ]" | vars theActualText | (self match: #verticalBar) ifFalse: ["no temps" doitFlag ifTrue: [tempsMark := self interactive + ifTrue: [cue requestor selectionInterval first] - ifTrue: [requestor selectionInterval first] ifFalse: [1]. ^ #()]. tempsMark := hereMark "formerly --> prevMark + prevToken". tempsMark > 0 ifTrue: [theActualText := source contents. [tempsMark < theActualText size and: [(theActualText at: tempsMark) isSeparator]] whileTrue: [tempsMark := tempsMark + 1]]. ^ #()]. vars := OrderedCollection new. [hereType == #word] whileTrue: [vars addLast: (encoder bindTemp: self advance in: methodSelector)]. (self match: #verticalBar) ifTrue: [tempsMark := prevMark. ^ vars]. ^ self expected: 'Vertical bar'!
1
0
0
0
The Trunk: Compiler-cwp.246.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-cwp.246.mcz
==================== Summary ==================== Name: Compiler-cwp.246 Author: cwp Time: 1 January 2013, 6:57:00.489 pm UUID: 54460c3c-db04-4159-8269-3bd83cc3c9f3 Ancestors: Compiler-cwp.245 Environments bootstrap - stage 2 =============== Diff against Compiler-cwp.245 =============== Item was changed: ----- 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 setCue: (CompilationCue + source: textOrStream + context: aContext + receiver: receiver + class: theClass + environment: theClass environment + category: nil + requestor: aRequestor). + ^ self evaluate: textOrStream cue: cue ifFail: failBlock logged: logFlag! - - | methodNode method value toLog itsSelection itsSelectionString | - class := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. - self from: textOrStream class: class context: aContext notifying: aRequestor. - methodNode := self translate: sourceStream noPattern: true ifFail: [^failBlock value]. - - method := self interactive - ifTrue: [methodNode generateWithTempNames] - ifFalse: [methodNode generate]. - - value := receiver - withArgs: (context ifNil: [#()] ifNotNil: [{context}]) - executeMethod: method. - - logFlag ifTrue: - [toLog := ((requestor respondsTo: #selection) - and:[(itsSelection := requestor selection) notNil - and:[(itsSelectionString := itsSelection asString) isEmptyOrNil not]]) - ifTrue:[itsSelectionString] - ifFalse:[sourceStream contents]. - SystemChangeNotifier uniqueInstance evaluated: toLog context: aContext]. - ^ value! Item was changed: ----- Method: Compiler>>from:class:classified:context:notifying: (in category 'public access') ----- from: textOrStream class: aClass classified: aCategory context: aContext notifying: req + self source: textOrStream. + self setCue: + (CompilationCue + source: textOrStream + context: aContext + class: aClass + category: aCategory + requestor: req)! - - sourceStream := (textOrStream isKindOf: PositionableStream) - ifTrue: [textOrStream] - ifFalse: [ReadStream on: textOrStream asString]. - class := aClass. - context := aContext. - requestor := req. - category := aCategory - ! Item was changed: ----- Method: Compiler>>from:class:context:notifying: (in category 'private') ----- from: textOrStream class: aClass context: aContext notifying: req + self source: textOrStream. + self setCue: + (CompilationCue + source: textOrStream + context: aContext + class: aClass + requestor: req) + ! - - (textOrStream isKindOf: PositionableStream) - ifTrue: [sourceStream := textOrStream] - ifFalse: [sourceStream := ReadStream on: textOrStream asString]. - class := aClass. - context := aContext. - requestor := req! Item was changed: ----- Method: Encoder>>init:context:notifying: (in category 'initialize-release') ----- + init: aClass context: aContext notifying: anObject + | c | + c := CompilationCue + context: aContext + class: aClass + requestor: nil. + self init: c notifying: anObject! - init: aClass context: aContext notifying: req - requestor := req. - class := aClass. - nTemps := 0. - supered := false. - self initScopeAndLiteralTables. - class variablesAndOffsetsDo: - [:variable "<String|CFieldDefinition>" :offset "<Integer|nil>" | - offset isNil - ifTrue: [scopeTable at: variable name put: (FieldNode new fieldDefinition: variable)] - ifFalse: [scopeTable - at: variable - put: (offset >= 0 - ifTrue: [InstanceVariableNode new - name: variable index: offset] - ifFalse: [MaybeContextInstanceVariableNode new - name: variable index: offset negated])]]. - aContext ~~ nil ifTrue: - [| homeNode | - homeNode := self bindTemp: self doItInContextName. - "0th temp = aContext passed as arg" - aContext tempNames withIndexDo: - [:variable :index| - scopeTable - at: variable - put: (MessageAsTempNode new - receiver: homeNode - selector: #namedTempAt: - arguments: (Array with: (self encodeLiteral: index)) - precedence: 3 - from: self)]]. - sourceRanges := Dictionary new: 32. - globalSourceRanges := OrderedCollection new: 32! Item was changed: ----- Method: Encoder>>temps:literals:class: (in category 'initialize-release') ----- temps: tempVars literals: lits class: cl "Initialize this encoder for decompilation." + self setCue: (CompilationCue class: cl). supered := false. - class := cl. nTemps := tempVars size. tempVars do: [:node | scopeTable at: node name put: node]. literalStream := WriteStream on: (Array new: lits size). literalStream nextPutAll: lits. sourceRanges := Dictionary new: 32. globalSourceRanges := OrderedCollection new: 32.! Item was changed: ----- Method: Parser>>initPattern:notifying:return: (in category 'private') ----- initPattern: aString notifying: req return: aBlock | result | self init: (ReadStream on: aString asString) + cue: (CompilationCue source: aString requestor: req) - notifying: req failBlock: [^nil]. encoder := self. result := aBlock value: (self pattern: false inContext: nil). encoder := failBlock := nil. "break cycles" ^result! Item was changed: ----- Method: Parser>>parse:class:category:noPattern:context:notifying:ifFail: (in category 'public access') ----- + parse: sourceStream class: class category: aCategory noPattern: noPattern context: aContext notifying: req ifFail: aBlock + | c | + c := CompilationCue + source: sourceStream + context: aContext + class: class + category: aCategory + requestor: req. + ^ self + parse: sourceStream + cue: c + noPattern: noPattern + ifFail: aBlock! - parse: sourceStream class: class category: aCategory noPattern: noPattern context: ctxt notifying: req ifFail: aBlock - "Answer a MethodNode for the argument, sourceStream, that is the root of - a parse tree. Parsing is done with respect to the argument, class, to find - instance, class, and pool variables; and with respect to the argument, - ctxt, to find temporary variables. Errors in parsing are reported to the - argument, req, if not nil; otherwise aBlock is evaluated. The argument - noPattern is a Boolean that is true if the the sourceStream does not - contain a method header (i.e., for DoIts)." - - | methNode repeatNeeded myStream s p subSelection | - category := aCategory. - myStream := sourceStream. - [repeatNeeded := false. - p := myStream position. - s := myStream upToEnd. - myStream position: p. - subSelection := req notNil and: [req selectionInterval = (p + 1 to: p + s size)]. - self encoder init: class context: ctxt notifying: self. - self init: myStream notifying: req failBlock: [^ aBlock value]. - doitFlag := noPattern. - failBlock:= aBlock. - [methNode := self - method: noPattern - context: ctxt] - on: ReparseAfterSourceEditing - do: [ :ex | - repeatNeeded := true. - myStream := subSelection - ifTrue: - [ReadStream - on: requestor text string - from: requestor selectionInterval first - to: requestor selectionInterval last] - ifFalse: - [ReadStream on: requestor text string]]. - repeatNeeded] whileTrue: - [encoder := self encoder class new]. - methNode sourceText: s. - ^methNode!
1
0
0
0
The Trunk: Compiler-cwp.246.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-cwp.246.mcz
==================== Summary ==================== Name: Compiler-cwp.246 Author: cwp Time: 1 January 2013, 6:57:00.489 pm UUID: 54460c3c-db04-4159-8269-3bd83cc3c9f3 Ancestors: Compiler-cwp.245 Environments bootstrap - stage 2 =============== Diff against Compiler-cwp.245 =============== Item was changed: ----- 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 setCue: (CompilationCue + source: textOrStream + context: aContext + receiver: receiver + class: theClass + environment: theClass environment + category: nil + requestor: aRequestor). + ^ self evaluate: textOrStream cue: cue ifFail: failBlock logged: logFlag! - - | methodNode method value toLog itsSelection itsSelectionString | - class := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. - self from: textOrStream class: class context: aContext notifying: aRequestor. - methodNode := self translate: sourceStream noPattern: true ifFail: [^failBlock value]. - - method := self interactive - ifTrue: [methodNode generateWithTempNames] - ifFalse: [methodNode generate]. - - value := receiver - withArgs: (context ifNil: [#()] ifNotNil: [{context}]) - executeMethod: method. - - logFlag ifTrue: - [toLog := ((requestor respondsTo: #selection) - and:[(itsSelection := requestor selection) notNil - and:[(itsSelectionString := itsSelection asString) isEmptyOrNil not]]) - ifTrue:[itsSelectionString] - ifFalse:[sourceStream contents]. - SystemChangeNotifier uniqueInstance evaluated: toLog context: aContext]. - ^ value! Item was changed: ----- Method: Compiler>>from:class:classified:context:notifying: (in category 'public access') ----- from: textOrStream class: aClass classified: aCategory context: aContext notifying: req + self source: textOrStream. + self setCue: + (CompilationCue + source: textOrStream + context: aContext + class: aClass + category: aCategory + requestor: req)! - - sourceStream := (textOrStream isKindOf: PositionableStream) - ifTrue: [textOrStream] - ifFalse: [ReadStream on: textOrStream asString]. - class := aClass. - context := aContext. - requestor := req. - category := aCategory - ! Item was changed: ----- Method: Compiler>>from:class:context:notifying: (in category 'private') ----- from: textOrStream class: aClass context: aContext notifying: req + self source: textOrStream. + self setCue: + (CompilationCue + source: textOrStream + context: aContext + class: aClass + requestor: req) + ! - - (textOrStream isKindOf: PositionableStream) - ifTrue: [sourceStream := textOrStream] - ifFalse: [sourceStream := ReadStream on: textOrStream asString]. - class := aClass. - context := aContext. - requestor := req! Item was changed: ----- Method: Encoder>>init:context:notifying: (in category 'initialize-release') ----- + init: aClass context: aContext notifying: anObject + | c | + c := CompilationCue + context: aContext + class: aClass + requestor: nil. + self init: c notifying: anObject! - init: aClass context: aContext notifying: req - requestor := req. - class := aClass. - nTemps := 0. - supered := false. - self initScopeAndLiteralTables. - class variablesAndOffsetsDo: - [:variable "<String|CFieldDefinition>" :offset "<Integer|nil>" | - offset isNil - ifTrue: [scopeTable at: variable name put: (FieldNode new fieldDefinition: variable)] - ifFalse: [scopeTable - at: variable - put: (offset >= 0 - ifTrue: [InstanceVariableNode new - name: variable index: offset] - ifFalse: [MaybeContextInstanceVariableNode new - name: variable index: offset negated])]]. - aContext ~~ nil ifTrue: - [| homeNode | - homeNode := self bindTemp: self doItInContextName. - "0th temp = aContext passed as arg" - aContext tempNames withIndexDo: - [:variable :index| - scopeTable - at: variable - put: (MessageAsTempNode new - receiver: homeNode - selector: #namedTempAt: - arguments: (Array with: (self encodeLiteral: index)) - precedence: 3 - from: self)]]. - sourceRanges := Dictionary new: 32. - globalSourceRanges := OrderedCollection new: 32! Item was changed: ----- Method: Encoder>>temps:literals:class: (in category 'initialize-release') ----- temps: tempVars literals: lits class: cl "Initialize this encoder for decompilation." + self setCue: (CompilationCue class: cl). supered := false. - class := cl. nTemps := tempVars size. tempVars do: [:node | scopeTable at: node name put: node]. literalStream := WriteStream on: (Array new: lits size). literalStream nextPutAll: lits. sourceRanges := Dictionary new: 32. globalSourceRanges := OrderedCollection new: 32.! Item was changed: ----- Method: Parser>>initPattern:notifying:return: (in category 'private') ----- initPattern: aString notifying: req return: aBlock | result | self init: (ReadStream on: aString asString) + cue: (CompilationCue source: aString requestor: req) - notifying: req failBlock: [^nil]. encoder := self. result := aBlock value: (self pattern: false inContext: nil). encoder := failBlock := nil. "break cycles" ^result! Item was changed: ----- Method: Parser>>parse:class:category:noPattern:context:notifying:ifFail: (in category 'public access') ----- + parse: sourceStream class: class category: aCategory noPattern: noPattern context: aContext notifying: req ifFail: aBlock + | c | + c := CompilationCue + source: sourceStream + context: aContext + class: class + category: aCategory + requestor: req. + ^ self + parse: sourceStream + cue: c + noPattern: noPattern + ifFail: aBlock! - parse: sourceStream class: class category: aCategory noPattern: noPattern context: ctxt notifying: req ifFail: aBlock - "Answer a MethodNode for the argument, sourceStream, that is the root of - a parse tree. Parsing is done with respect to the argument, class, to find - instance, class, and pool variables; and with respect to the argument, - ctxt, to find temporary variables. Errors in parsing are reported to the - argument, req, if not nil; otherwise aBlock is evaluated. The argument - noPattern is a Boolean that is true if the the sourceStream does not - contain a method header (i.e., for DoIts)." - - | methNode repeatNeeded myStream s p subSelection | - category := aCategory. - myStream := sourceStream. - [repeatNeeded := false. - p := myStream position. - s := myStream upToEnd. - myStream position: p. - subSelection := req notNil and: [req selectionInterval = (p + 1 to: p + s size)]. - self encoder init: class context: ctxt notifying: self. - self init: myStream notifying: req failBlock: [^ aBlock value]. - doitFlag := noPattern. - failBlock:= aBlock. - [methNode := self - method: noPattern - context: ctxt] - on: ReparseAfterSourceEditing - do: [ :ex | - repeatNeeded := true. - myStream := subSelection - ifTrue: - [ReadStream - on: requestor text string - from: requestor selectionInterval first - to: requestor selectionInterval last] - ifFalse: - [ReadStream on: requestor text string]]. - repeatNeeded] whileTrue: - [encoder := self encoder class new]. - methNode sourceText: s. - ^methNode!
1
0
0
0
The Trunk: Compiler-cwp.246.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-cwp.246.mcz
==================== Summary ==================== Name: Compiler-cwp.246 Author: cwp Time: 1 January 2013, 6:57:00.489 pm UUID: 54460c3c-db04-4159-8269-3bd83cc3c9f3 Ancestors: Compiler-cwp.245 Environments bootstrap - stage 2 =============== Diff against Compiler-cwp.245 =============== Item was changed: ----- 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 setCue: (CompilationCue + source: textOrStream + context: aContext + receiver: receiver + class: theClass + environment: theClass environment + category: nil + requestor: aRequestor). + ^ self evaluate: textOrStream cue: cue ifFail: failBlock logged: logFlag! - - | methodNode method value toLog itsSelection itsSelectionString | - class := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class. - self from: textOrStream class: class context: aContext notifying: aRequestor. - methodNode := self translate: sourceStream noPattern: true ifFail: [^failBlock value]. - - method := self interactive - ifTrue: [methodNode generateWithTempNames] - ifFalse: [methodNode generate]. - - value := receiver - withArgs: (context ifNil: [#()] ifNotNil: [{context}]) - executeMethod: method. - - logFlag ifTrue: - [toLog := ((requestor respondsTo: #selection) - and:[(itsSelection := requestor selection) notNil - and:[(itsSelectionString := itsSelection asString) isEmptyOrNil not]]) - ifTrue:[itsSelectionString] - ifFalse:[sourceStream contents]. - SystemChangeNotifier uniqueInstance evaluated: toLog context: aContext]. - ^ value! Item was changed: ----- Method: Compiler>>from:class:classified:context:notifying: (in category 'public access') ----- from: textOrStream class: aClass classified: aCategory context: aContext notifying: req + self source: textOrStream. + self setCue: + (CompilationCue + source: textOrStream + context: aContext + class: aClass + category: aCategory + requestor: req)! - - sourceStream := (textOrStream isKindOf: PositionableStream) - ifTrue: [textOrStream] - ifFalse: [ReadStream on: textOrStream asString]. - class := aClass. - context := aContext. - requestor := req. - category := aCategory - ! Item was changed: ----- Method: Compiler>>from:class:context:notifying: (in category 'private') ----- from: textOrStream class: aClass context: aContext notifying: req + self source: textOrStream. + self setCue: + (CompilationCue + source: textOrStream + context: aContext + class: aClass + requestor: req) + ! - - (textOrStream isKindOf: PositionableStream) - ifTrue: [sourceStream := textOrStream] - ifFalse: [sourceStream := ReadStream on: textOrStream asString]. - class := aClass. - context := aContext. - requestor := req! Item was changed: ----- Method: Encoder>>init:context:notifying: (in category 'initialize-release') ----- + init: aClass context: aContext notifying: anObject + | c | + c := CompilationCue + context: aContext + class: aClass + requestor: nil. + self init: c notifying: anObject! - init: aClass context: aContext notifying: req - requestor := req. - class := aClass. - nTemps := 0. - supered := false. - self initScopeAndLiteralTables. - class variablesAndOffsetsDo: - [:variable "<String|CFieldDefinition>" :offset "<Integer|nil>" | - offset isNil - ifTrue: [scopeTable at: variable name put: (FieldNode new fieldDefinition: variable)] - ifFalse: [scopeTable - at: variable - put: (offset >= 0 - ifTrue: [InstanceVariableNode new - name: variable index: offset] - ifFalse: [MaybeContextInstanceVariableNode new - name: variable index: offset negated])]]. - aContext ~~ nil ifTrue: - [| homeNode | - homeNode := self bindTemp: self doItInContextName. - "0th temp = aContext passed as arg" - aContext tempNames withIndexDo: - [:variable :index| - scopeTable - at: variable - put: (MessageAsTempNode new - receiver: homeNode - selector: #namedTempAt: - arguments: (Array with: (self encodeLiteral: index)) - precedence: 3 - from: self)]]. - sourceRanges := Dictionary new: 32. - globalSourceRanges := OrderedCollection new: 32! Item was changed: ----- Method: Encoder>>temps:literals:class: (in category 'initialize-release') ----- temps: tempVars literals: lits class: cl "Initialize this encoder for decompilation." + self setCue: (CompilationCue class: cl). supered := false. - class := cl. nTemps := tempVars size. tempVars do: [:node | scopeTable at: node name put: node]. literalStream := WriteStream on: (Array new: lits size). literalStream nextPutAll: lits. sourceRanges := Dictionary new: 32. globalSourceRanges := OrderedCollection new: 32.! Item was changed: ----- Method: Parser>>initPattern:notifying:return: (in category 'private') ----- initPattern: aString notifying: req return: aBlock | result | self init: (ReadStream on: aString asString) + cue: (CompilationCue source: aString requestor: req) - notifying: req failBlock: [^nil]. encoder := self. result := aBlock value: (self pattern: false inContext: nil). encoder := failBlock := nil. "break cycles" ^result! Item was changed: ----- Method: Parser>>parse:class:category:noPattern:context:notifying:ifFail: (in category 'public access') ----- + parse: sourceStream class: class category: aCategory noPattern: noPattern context: aContext notifying: req ifFail: aBlock + | c | + c := CompilationCue + source: sourceStream + context: aContext + class: class + category: aCategory + requestor: req. + ^ self + parse: sourceStream + cue: c + noPattern: noPattern + ifFail: aBlock! - parse: sourceStream class: class category: aCategory noPattern: noPattern context: ctxt notifying: req ifFail: aBlock - "Answer a MethodNode for the argument, sourceStream, that is the root of - a parse tree. Parsing is done with respect to the argument, class, to find - instance, class, and pool variables; and with respect to the argument, - ctxt, to find temporary variables. Errors in parsing are reported to the - argument, req, if not nil; otherwise aBlock is evaluated. The argument - noPattern is a Boolean that is true if the the sourceStream does not - contain a method header (i.e., for DoIts)." - - | methNode repeatNeeded myStream s p subSelection | - category := aCategory. - myStream := sourceStream. - [repeatNeeded := false. - p := myStream position. - s := myStream upToEnd. - myStream position: p. - subSelection := req notNil and: [req selectionInterval = (p + 1 to: p + s size)]. - self encoder init: class context: ctxt notifying: self. - self init: myStream notifying: req failBlock: [^ aBlock value]. - doitFlag := noPattern. - failBlock:= aBlock. - [methNode := self - method: noPattern - context: ctxt] - on: ReparseAfterSourceEditing - do: [ :ex | - repeatNeeded := true. - myStream := subSelection - ifTrue: - [ReadStream - on: requestor text string - from: requestor selectionInterval first - to: requestor selectionInterval last] - ifFalse: - [ReadStream on: requestor text string]]. - repeatNeeded] whileTrue: - [encoder := self encoder class new]. - methNode sourceText: s. - ^methNode!
1
0
0
0
The Trunk: Environments-cwp.7.mcz
by commits@source.squeak.org
02 Jan '13
02 Jan '13
Colin Putney uploaded a new version of Environments to project The Trunk:
http://source.squeak.org/trunk/Environments-cwp.7.mcz
==================== Summary ==================== Name: Environments-cwp.7 Author: cwp Time: 1 January 2013, 6:53:18.035 pm UUID: de965a02-dce2-4ece-9299-c73b235a251d Ancestors: Environments-cwp.6 Environments bootstrap - stage 1 =============== Diff against Environments-cwp.6 =============== Item was changed: ----- Method: Environment class>>initialize (in category 'as yet unclassified') ----- initialize + self install! - self uninstall!
1
0
0
0
← Newer
1
...
16
17
18
19
20
21
22
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Results per page:
10
25
50
100
200