[squeak-dev] The Trunk: Compiler-mt.438.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Jun 15 14:41:52 UTC 2020

Marcel Taeumel uploaded a new version of Compiler to project The Trunk:

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

Name: Compiler-mt.438
Author: mt
Time: 15 June 2020, 4:41:51.696209 pm
UUID: 40254d1d-a07c-c444-a87d-c1600f6e3f9d
Ancestors: Compiler-mt.437

Avoid breaking new hook for <pragmaParser> when subclassing Parser. That is, re-use all existing pragma parsers automatically in subclasses. Note that #methodDict was chosen over #lookupSelector: for performance reasons.

=============== Diff against Compiler-mt.437 ===============

Item was changed:
  ----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
  	"Read a single pragma statement. Dispatch to the first available pragma parser using the current token as a simple getter to be called on self. If no pragma parser can be found, parse it as usual in the keywords form.
  	Note that custom pragma parsers need to fulfill two requirements:
  		(1) method selector must match the current token as simple getter,
  				e.g., <apicall: ...> matches #apicall or <primitive: ...> matches #primitive
  		(2) method must declare <pragmaParser> to be called.
  	This is for the protection of the parser's (message) namespace."
  	| parserSelector |
  	(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
  		ifFalse: [  ^ self expected: 'pragma declaration' ].
  	(here last == $:
  		and: [(parserSelector := Symbol lookup: here 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 pragmaStatementKeywords].
+ 	Parser methodDict
- 	self class methodDict
  		at: parserSelector
  		ifPresent: [:parserMethod |
  			(parserMethod pragmas
  				anySatisfy: [:pragma | pragma keyword == #pragmaParser])
  					ifTrue: [^ self executeMethod: parserMethod]].
  	^ self pragmaStatementKeywords!

More information about the Squeak-dev mailing list