The Inbox: Compiler-mt.454.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Compiler-mt.454.mcz

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

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

Name: Compiler-mt.454
Author: mt
Time: 27 January 2021, 10:31:47.057422 am
UUID: 6e01e1e3-e3b2-41a4-9749-37f1dab71fba
Ancestors: Compiler-eem.453

Adds <noContextSwitch> pragma, which maps to <primitive: 123>. For this, allow parser extensions to be non-keyword (i.e. unary) pragmas. Might have a tiny performance impact when parsing methods with lots of non-keyword pragmas.

=============== Diff against Compiler-eem.453 ===============

Item was added:
+ ----- Method: Parser>>noContextSwitch (in category 'pragmas - code evaluation') -----
+ noContextSwitch
+ "By adding this pragma to a method, it will not be preempt the current process on method activation if a higher-priority process is runnable. Any numbered primitive without side effects will do here."
+ <pragmaParser>
+
+ "Note that primitive 123 once was primitiveValueUninteruptibly but is no longer in use."
+ self addPragma: (Pragma keyword: #primitive: arguments: #(123)).
+
+ self advance.
+ ^ true!

Item was changed:
  ----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
  pragmaStatement
  "Parse a pragma statement. The leading '<' has already been consumed. The 'here' token is the first one in the pragma. Use that token to dispatch to a custom pragma-parsing method if one can be found with a selector that matches it.
 
  Note that custom pragma parsers need to fulfill two requirements:
  - method selector must match the current token as simple getter,
  e.g., <apicall: ...> matches #apicall or <primitive: ...> matches #primitive
  - method must have pragma <pragmaParser> to be called."
 
  "0) Early exit"
  (hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
  ifFalse: [  ^ self expected: 'pragma declaration' ].
 
+ "1) Avoid interning new symbols for made-up pragmas such as #my for <my: 1 pragma: 2>."
+ (Symbol lookup: (here last == $: ifTrue: [here allButLast] ifFalse: [here])) ifNotNil: [:parserSelector |
+ Parser methodDict at: parserSelector ifPresent: [:parserMethod |
+ "2) Only call methods that claim to be a custom pragma parser via <pragmaParser>."
+ (parserMethod hasPragma: #pragmaParser)
+ ifTrue: [^ self executeMethod: parserMethod]]].
- "1) Do not consider one-word pragmas such as <primitive> and <foobar>. Only keyword pragmas."
- here last == $: ifTrue: [
- "2) Avoid interning new symbols for made-up pragmas such as #my for <my: 1 pragma: 2>."
- (Symbol lookup: here allButLast) ifNotNil: [:parserSelector |
- Parser methodDict at: parserSelector ifPresent: [:parserMethod |
- "3) Only call methods that claim to be a custom pragma parser via <pragmaParser>."
- (parserMethod hasPragma: #pragmaParser)
- ifTrue: [^ self executeMethod: parserMethod]]]].
 
  "X) No custom pragma parser found. Use the default one."
  ^ self pragmaStatementKeywords!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Compiler-mt.454.mcz

marcel.taeumel
Hi Eliot,

please review. :-) It connects to this discussion: http://forum.world.st/Transcript-error-when-forceUpdate-false-tp5126397p5126559.html

Best,
Marcel

Am 27.01.2021 10:31:57 schrieb [hidden email] <[hidden email]>:

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

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

Name: Compiler-mt.454
Author: mt
Time: 27 January 2021, 10:31:47.057422 am
UUID: 6e01e1e3-e3b2-41a4-9749-37f1dab71fba
Ancestors: Compiler-eem.453

Adds pragma, which maps to . For this, allow parser extensions to be non-keyword (i.e. unary) pragmas. Might have a tiny performance impact when parsing methods with lots of non-keyword pragmas.

=============== Diff against Compiler-eem.453 ===============

Item was added:
+ ----- Method: Parser>>noContextSwitch (in category 'pragmas - code evaluation') -----
+ noContextSwitch
+ "By adding this pragma to a method, it will not be preempt the current process on method activation if a higher-priority process is runnable. Any numbered primitive without side effects will do here."
+
+
+ "Note that primitive 123 once was primitiveValueUninteruptibly but is no longer in use."
+ self addPragma: (Pragma keyword: #primitive: arguments: #(123)).
+
+ self advance.
+ ^ true!

Item was changed:
----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
pragmaStatement
"Parse a pragma statement. The leading '<' has already been consumed. The 'here' token is the first one in the pragma. Use that token to dispatch to a custom pragma-parsing method if one can be found with a selector that matches it.

Note that custom pragma parsers need to fulfill two requirements:
- method selector must match the current token as simple getter,
e.g., matches #apicall or matches #primitive
- method must have pragma to be called."

"0) Early exit"
(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
ifFalse: [ ^ self expected: 'pragma declaration' ].

+ "1) Avoid interning new symbols for made-up pragmas such as #my for ."
+ (Symbol lookup: (here last == $: ifTrue: [here allButLast] ifFalse: [here])) ifNotNil: [:parserSelector |
+ Parser methodDict at: parserSelector ifPresent: [:parserMethod |
+ "2) Only call methods that claim to be a custom pragma parser via ."
+ (parserMethod hasPragma: #pragmaParser)
+ ifTrue: [^ self executeMethod: parserMethod]]].
- "1) Do not consider one-word pragmas such as and . Only keyword pragmas."
- here last == $: ifTrue: [
- "2) Avoid interning new symbols for made-up pragmas such as #my for ."
- (Symbol lookup: here allButLast) ifNotNil: [:parserSelector |
- Parser methodDict at: parserSelector ifPresent: [:parserMethod |
- "3) Only call methods that claim to be a custom pragma parser via ."
- (parserMethod hasPragma: #pragmaParser)
- ifTrue: [^ self executeMethod: parserMethod]]]].

"X) No custom pragma parser found. Use the default one."
^ self pragmaStatementKeywords!