Marcel Taeumel uploaded a new version of ShoutCore to project The Trunk:
http://source.squeak.org/trunk/ShoutCore-mt.79.mcz ==================== Summary ==================== Name: ShoutCore-mt.79 Author: mt Time: 13 June 2020, 10:34:17.329351 am UUID: 20850ea4-bd6b-9642-9333-ed6b4ce1e81d Ancestors: ShoutCore-mt.78 Tweaks performance of method lookup for pragma parsing. See http://forum.world.st/The-Inbox-ShoutCore-mt-78-mcz-td5118289.html =============== Diff against ShoutCore-mt.77 =============== Item was removed: - ----- Method: SHParserST80>>isTokenExternalFunctionCallingConvention (in category 'token testing') ----- - isTokenExternalFunctionCallingConvention - - currentToken ifNil: [ ^false ]. - ^(Smalltalk classNamed: #ExternalFunction) - ifNil: [ false ] - ifNotNil: [ :descriptorClass | - (descriptorClass callingConventionFor: currentToken) notNil ]! Item was removed: - ----- Method: SHParserST80>>parseExternalCall (in category 'parse') ----- - parseExternalCall - [self scanNext. - ((Smalltalk at: #ExternalFunction) callingConventionModifierFor: currentToken) notNil] - whileTrue. - self failUnless: currentToken notNil. - self scanPast: #externalCallType. - currentToken = '*' - ifTrue: [self scanPast: #externalCallTypePointerIndicator]. - currentTokenFirst isDigit - ifTrue: [self scanPast: #integer] - ifFalse: [ - self failUnless: currentTokenFirst == $'. - self parseString]. - self failUnless: currentTokenFirst == $(. - self scanPast: #leftParenthesis. - [currentTokenFirst ~= $)] - whileTrue: [ - self failUnless: currentToken notNil. - self scanPast: #externalCallType. - currentToken = '*' - ifTrue: [self scanPast: #externalCallTypePointerIndicator]]. - self scanPast: #rightParenthesis. - currentToken = 'module:' - ifTrue: [ - self scanPast: #module. - self parseStringOrSymbol ]. - currentToken = 'error:' ifTrue: [ - self scanPast: #primitive. "there's no rangeType for error" - self currentTokenType == #name - ifTrue: [ self parseTemporary: #patternTempVar ] - ifFalse: [ self parseStringOrSymbol ] ]. - self failUnless: currentToken = '>'. - self scanPast: #primitiveOrExternalCallEnd! Item was changed: + ----- Method: SHParserST80>>parsePragmaBinary (in category 'parse pragma') ----- - ----- Method: SHParserST80>>parsePragmaBinary (in category 'parse') ----- parsePragmaBinary self scanPast: #pragmaBinary. self currentTokenType == #name ifTrue:[self scanPast: (self resolvePragmaArgument: currentToken)] ifFalse:[ self parseLiteral: false]. self failUnless: currentToken = '>'. self scanPast: #primitiveOrExternalCallEnd! Item was changed: + ----- Method: SHParserST80>>parsePragmaKeyword (in category 'parse pragma') ----- - ----- Method: SHParserST80>>parsePragmaKeyword (in category 'parse') ----- parsePragmaKeyword [self currentTokenType == #keyword] whileTrue:[ self scanPast: #pragmaKeyword. self currentTokenType == #name ifTrue:[self scanPast: (self resolvePragmaArgument: currentToken)] ifFalse:[ self parseLiteral: false]]. self failUnless: currentToken = '>'. self scanPast: #primitiveOrExternalCallEnd! Item was changed: + ----- Method: SHParserST80>>parsePragmaSequence (in category 'parse pragma') ----- - ----- Method: SHParserST80>>parsePragmaSequence (in category 'parse') ----- parsePragmaSequence + [currentToken = '<' ] + whileTrue: [ - whileTrue:[ self scanPast: #primitiveOrExternalCallStart. + self parsePragmaStatement].! - currentToken = 'primitive:' - ifTrue: [ - self addRangeType: #primitive. - self parsePrimitive] - ifFalse:[ - self isTokenExternalFunctionCallingConvention - ifTrue: [ - self addRangeType: #externalFunctionCallingConvention. - self parseExternalCall] - ifFalse:[ - self currentTokenType - caseOf: { - [ #name ] -> [ - self scanPast: #pragmaUnary. - self failUnless: currentToken = '>'. - self scanPast: #primitiveOrExternalCallEnd ]. - [ #binary ] -> [ self parsePragmaBinary ]. - [ #keyword ] -> [ self parsePragmaKeyword ] } - otherwise: [ self fail ": 'Invalid External Function Calling convention'" ] ] ] ]! Item was added: + ----- Method: SHParserST80>>parsePragmaStatement (in category 'parse pragma') ----- + parsePragmaStatement + + | parserSelector | + (currentToken last == $: + and: [(parserSelector := Symbol lookup: currentToken allButLast) notNil]) + ifFalse: ["Quick exit to not break one-word pragmas such as <primitive> and <foobar>; also avoid interning new symbols for made-up pragmas such as for <my: 1 new: 2 pragma: 3> not interning #my." + ^ self parsePragmaStatementKeywords]. + + self class methodDict + at: parserSelector + ifPresent: [:parserMethod | + (parserMethod pragmas + anySatisfy: [:pragma | pragma keyword == #pragmaParser]) + ifTrue: [^ self executeMethod: parserMethod]]. + + ^ self parsePragmaStatementKeywords! Item was added: + ----- Method: SHParserST80>>parsePragmaStatementKeywords (in category 'parse pragma') ----- + parsePragmaStatementKeywords + + self currentTokenType + caseOf: { + [ #name ] -> [ + self scanPast: #pragmaUnary. + self failUnless: currentToken = '>'. + self scanPast: #primitiveOrExternalCallEnd ]. + [ #binary ] -> [ self parsePragmaBinary ]. + [ #keyword ] -> [ self parsePragmaKeyword ] } + otherwise: [ self fail ": 'Invalid External Function Calling convention'" ]. ! Item was removed: - ----- Method: SHParserST80>>parsePrimitive (in category 'parse') ----- - parsePrimitive - - self scanNext. - currentTokenFirst isDigit - ifTrue: [ self scanPast: #integer ] - ifFalse: [ - self parseStringOrSymbol. - currentToken = 'module:' ifTrue: [ - self scanPast: #module. - self parseStringOrSymbol ] ]. - currentToken = 'error:' ifTrue: [ - self scanPast: #primitive. "there's no rangeType for error" - self currentTokenType == #name - ifTrue: [ self parseTemporary: #patternTempVar ] - ifFalse: [ self parseStringOrSymbol ] ]. - self failUnless: currentToken = '>'. - self scanPast: #primitiveOrExternalCallEnd! Item was added: + ----- Method: SHParserST80>>primitive (in category 'parse pragma') ----- + primitive + "Parse keywords and literals of primitive pragmas differently to emit different range tokens for different UI styling. This hook exists so that packages do not break primitive-pragma parsing by accident. Instead, this method needs to be replaced intentionally." + <pragmaParser> + + self addRangeType: #primitive. + + self scanNext. + currentTokenFirst isDigit + ifTrue: [ self scanPast: #integer ] + ifFalse: [ + self parseStringOrSymbol. + currentToken = 'module:' ifTrue: [ + self scanPast: #module. + self parseStringOrSymbol ] ]. + currentToken = 'error:' ifTrue: [ + self scanPast: #primitive. "there's no rangeType for error" + self currentTokenType == #name + ifTrue: [ self parseTemporary: #patternTempVar ] + ifFalse: [ self parseStringOrSymbol ] ]. + self failUnless: currentToken = '>'. + self scanPast: #primitiveOrExternalCallEnd! |
Free forum by Nabble | Edit this page |