[squeak-dev] The Trunk: Compiler-mha.76.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Sep 3 12:42:51 UTC 2009
Michael Haupt uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-mha.76.mcz
==================== Summary ====================
Name: Compiler-mha.76
Author: mha
Time: 1 September 2009, 4:35:49 am
UUID: 1218194f-4a88-44df-9d79-e80638a53aa7
Ancestors: Compiler-tfel.75
inserted an extension originally contributed by Eliot Miranda (to make Alien support possible in the trunk)
=============== Diff against Compiler-tfel.75 ===============
Item was changed:
----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
pragmaStatement
"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 |
(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
ifFalse: [ ^ self expected: 'pragma declaration' ].
" This is a ugly hack into the compiler of the FFI package. FFI should be changed to use propre pragmas that can be parsed with the code here. "
(here = #apicall: or: [ here = #cdecl: ])
ifTrue: [ ^ self externalFunctionDeclaration ].
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) ] ].
- ifTrue: [ arguments add: self pragmaLiteral ] ].
selector numArgs ~= arguments size
ifTrue: [ ^ self expected: 'pragma argument' ].
(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!
Item was added:
+ ----- Method: Parser>>pragmaLiteral: (in category 'pragmas') -----
+ pragmaLiteral: selectorSoFar
+ "Read a pragma literal."
+
+ (hereType == #string or: [ hereType == #literal or: [ hereType == #number ] ])
+ ifTrue: [ ^ self advance ].
+ (here == $# and: [ tokenType == #word ])
+ ifTrue: [ ^ self advance ].
+ (here == #- and: [ tokenType == #number ])
+ ifTrue: [ ^ (self advance; advance) negated ].
+ (here = 'true' or: [ here = 'false' or: [ here = 'nil' ] ])
+ ifTrue: [ ^ Compiler evaluate: self advance ].
+ "This nicety allows one to supply a primitive error temp as a
+ variable name, rather than a string."
+ ((selectorSoFar beginsWith: 'primitive:')
+ and: [ (selectorSoFar endsWith: 'error:')
+ and: [ hereType == #word ] ]) ifTrue: [ ^ self advance ].
+ ^ self expected: 'Literal constant'!
More information about the Squeak-dev
mailing list
|