'From Squeak4.1 of 17 April 2010 [latest update: #9957] on 7 September 2010 at 10:31:07 pm'! !ContextPart methodsFor: 'private' stamp: 'DmitryMatveev 8/20/2010 11:31'! doPrimitive: t1 method: t2 receiver: t3 args: t4 | t5 | "primitiveFail" t1 = 19 ifTrue: [ToolSet debugContext: self label: 'Code simulation error' contents: nil]. (t1 = 80 and: [t3 isKindOf: ContextPart]) ifTrue: [^ self push: ((BlockContext newForMethod: t3 method) home: t3 home startpc: pc + 2 nargs: (t4 at: 1))]. (t1 = 81 and: [t3 isMemberOf: BlockContext]) ifTrue: [^ t3 pushArgs: t4 from: self]. (t1 = 82 and: [t3 isMemberOf: BlockContext]) ifTrue: [^ t3 pushArgs: t4 first from: self]. t1 = 83 ifTrue: [^ self send: t4 first to: t3 with: t4 allButFirst super: false]. t1 = 84 ifTrue: [^ self send: t4 first to: t3 with: (t4 at: 2) super: false]. t1 = 188 ifTrue: [^ MethodContext sender: self receiver: t3 method: (t4 at: 2) arguments: (t4 at: 1)]. (t1 = 200 and: [t3 == self]) ifTrue: [^ self push: (BlockClosure outerContext: t3 startpc: pc + 2 numArgs: t4 first copiedValues: t4 last)]. ((t1 between: 201 and: 205) or: [t1 between: 221 and: 222]) ifTrue: [^ t3 simulateValueWithArguments: t4 caller: self]. t1 = 206 ifTrue: [^ t3 simulateValueWithArguments: t4 first caller: self]. t1 = 127 "CObject" ifTrue: [t5 := t2 literals first call: t4]. t1 = 120 ifTrue: [t5 := t2 literals first tryInvokeWithArguments: t4] ifFalse: [t4 size > 6 ifTrue: [^ PrimitiveFailToken]. t5 := t1 = 117 ifTrue: [self tryNamedPrimitiveIn: t2 for: t3 withArgs: t4] ifFalse: [t3 tryPrimitive: t1 withArgs: t4]]. ^ t5 == PrimitiveFailToken ifTrue: [PrimitiveFailToken] ifFalse: [self push: t5]! ! !Integer methodsFor: 'converting' stamp: 'DmitryMatveev 8/3/2010 01:39'! alignTo: anInteger "Answer the receiver, truncated to the first higher or equal multiple of anInteger (which must be a power of two)" ^ self + anInteger - 1 bitClear: anInteger - 1! ! !Parser methodsFor: 'pragmas' stamp: 'DmitryMatveev 8/6/2010 00:22'! pragmaStatement | t1 t2 t3 t4 t5 | (hereType = #keyword or: [hereType = #word or: [hereType = #binary]]) ifFalse: [^ self expected: 'pragma declaration']. (here = #apicall: or: [here = #cdecl:]) ifTrue: [^ self externalFunctionDeclaration]. here = #cCall: ifTrue: [^ self CFunctionDeclaration]. t1 := String new. t2 := OrderedCollection new. t3 := OrderedCollection new. [hereType = #keyword or: [(hereType = #word or: [hereType = #binary]) and: [t1 isEmpty]]] whileTrue: [t4 := self startOfNextToken + requestorOffset. t1 := t1 , self advance. t3 add: (t4 to: self endOfLastToken + requestorOffset). (t1 last = $: or: [t1 first isLetter not]) ifTrue: [t2 add: (self pragmaLiteral: t1)]]. t1 numArgs ~= t2 size ifTrue: [^ self expected: 'pragma argument']. (Symbol hasInterned: t1 ifTrue: [:t7 | t5 := t7]) ifFalse: [t5 := self correctSelector: t1 wordIntervals: t3 exprInterval: (t3 first first to: t3 last last) ifAbort: [^ self fail]]. self addPragma: (Pragma keyword: t5 arguments: t2 asArray). ^ true! ! !Parser methodsFor: 'primitives' stamp: 'DmitryMatveev 8/20/2010 11:29'! CFunctionDeclaration | returnType prototype funcName funcModule | self advance. funcName := here. self advance. (self matchToken: 'returning:') ifTrue: [returnType := here] ifFalse: [self expected: 'return type']. self advance. (self matchToken: 'args:') ifTrue: [prototype := here] ifFalse: [self expected: 'prototype']. self advance. (self matchToken: 'module:') ifTrue: [funcModule := here] ifFalse: [self expected: 'module']. self advance. Smalltalk at: #CFunction ifPresent: [:funcClass || literal | literal := funcClass returning: returnType prototype: prototype name: funcName module: funcModule. self allocateLiteral: literal]. self addPragma: (Pragma keyword: #primitive: arguments: #(127)). ^ true! !