Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-nice.456.mcz ==================== Summary ==================== Name: Compiler-nice.456 Author: nice Time: 13 April 2021, 5:52:23.50842 pm UUID: 3acf97cf-d6b4-5545-9976-f16c287011ba Ancestors: Compiler-tobe.455 Simplify Symbol lookup a little bit. Similar to rewrite rule same assignment in both ifTrue:ifFalse: branches. =============== Diff against Compiler-tobe.455 =============== Item was changed: ----- Method: Parser>>messagePart:repeat: (in category 'expression types') ----- messagePart: level repeat: repeat | start receiver selector args precedence words keywordStart | [receiver := parseNode. (hereType == #keyword and: [level >= 3]) ifTrue: [start := self startOfNextToken. selector := WriteStream on: (String new: 32). args := OrderedCollection new. words := OrderedCollection new. [hereType == #keyword] whileTrue: [keywordStart := self startOfNextToken + requestorOffset. selector nextPutAll: self advance. words addLast: (keywordStart to: self endOfLastToken + requestorOffset). self primaryExpression ifFalse: [^self expected: 'Argument']. self messagePart: 2 repeat: true. args addLast: parseNode]. + selector := (Symbol lookup: selector contents) + ifNil: [ self correctSelector: selector contents + wordIntervals: words + exprInterval: (start to: self endOfLastToken) + ifAbort: [ ^ self fail ] ]. - (Symbol hasInterned: selector contents ifTrue: [ :sym | selector := sym]) - ifFalse: [ selector := self correctSelector: selector contents - wordIntervals: words - exprInterval: (start to: self endOfLastToken) - ifAbort: [ ^ self fail ] ]. precedence := 3] ifFalse: [ (level >= 2 and: [hereType == #verticalBar]) ifTrue: [self transformAVerticalBarIntoABinarySelector]. (hereType == #binary and: [level >= 2]) ifTrue: [start := self startOfNextToken. selector := self advance asOctetString asSymbol. self primaryExpression ifFalse: [^self expected: 'Argument']. self messagePart: 1 repeat: true. args := Array with: parseNode. precedence := 2] ifFalse: [hereType == #word ifTrue: [start := self startOfNextToken. selector := self advance. args := #(). words := OrderedCollection with: (start + requestorOffset to: self endOfLastToken + requestorOffset). + selector := (Symbol lookup: selector) + ifNil: [ self correctSelector: selector + wordIntervals: words + exprInterval: (start to: self endOfLastToken) + ifAbort: [ ^ self fail ] ]. - (Symbol hasInterned: selector ifTrue: [ :sym | selector := sym]) - ifFalse: [ selector := self correctSelector: selector - wordIntervals: words - exprInterval: (start to: self endOfLastToken) - ifAbort: [ ^ self fail ] ]. precedence := 1] ifFalse: [^args notNil]]]. parseNode := MessageNode new receiver: receiver selector: selector arguments: args precedence: precedence from: encoder sourceRange: (start to: self endOfLastToken). repeat] whileTrue: []. ^true! Item was changed: ----- Method: Parser>>pragmaStatementKeywords (in category 'pragmas') ----- pragmaStatementKeywords "Read a single pragma statement. Parse all generic pragmas in the form of: <key1: val1 key2: val2 ...> and remember them, including primitives." | selector arguments words index keyword | selector := String new. arguments := OrderedCollection new. words := OrderedCollection new. [ hereType = #keyword or: [ (hereType = #word or: [ hereType = #binary ]) and: [ selector isEmpty ] ] ] whileTrue: [ index := self startOfNextToken + requestorOffset. selector := selector , self advance. words add: (index to: self endOfLastToken + requestorOffset). (selector last = $: or: [ selector first isLetter not ]) ifTrue: [ arguments add: (self pragmaLiteral: selector) ] ]. selector numArgs ~= arguments size ifTrue: [ ^ self expected: 'pragma argument' ]. + keyword := (Symbol lookup: selector) + ifNil: [ self - (Symbol hasInterned: selector - ifTrue: [ :value | keyword := value]) - ifFalse: [ - keyword := self correctSelector: selector wordIntervals: words exprInterval: (words first first to: words last last) ifAbort: [ ^ self fail ] ]. self addPragma: (Pragma keyword: keyword arguments: arguments asArray). ^ true! |
Free forum by Nabble | Edit this page |