[squeak-dev] The Inbox: Compiler-mt.437.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Jun 13 09:01:46 UTC 2020


A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.437.mcz

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

Name: Compiler-mt.437
Author: mt
Time: 13 June 2020, 11:01:44.448351 am
UUID: ca2e1da8-da26-a840-ae3e-1822ce8ba67d
Ancestors: Compiler-mt.436

Speed-up method-based hook for custom pragma-parsing methods. Like in ShoutCore-mt.79

=============== Diff against Compiler-mt.436 ===============

Item was changed:
  ----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
  pragmaStatement
  	"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 |
- 	| parserSelector parserMethod |
  	(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].
- 	(self class includesSelector: (parserSelector := here asSimpleGetter)) ifTrue: [
- 		((parserMethod := self class compiledMethodAt: parserSelector) pragmas
- 			anySatisfy: [:pragma | pragma keyword == #pragmaParser])
- 				ifTrue: [^ self executeMethod: parserMethod]].
  
+ 	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