The Trunk: Compiler-nice.420.mcz

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

The Trunk: Compiler-nice.420.mcz

commits-2
Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-nice.420.mcz

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

Name: Compiler-nice.420
Author: nice
Time: 14 March 2020, 2:13:55.100268 am
UUID: 8eac5555-d3f5-4e7f-95f6-7ca20d5f90e1
Ancestors: Compiler-eem.419

Fixup compilation of external function: #litIndex: is a message to be sent to the encoder now.

=============== Diff against Compiler-eem.419 ===============

Item was changed:
  ----- Method: Parser>>externalFunctionDeclaration (in category 'primitives') -----
  externalFunctionDeclaration
  "Parse the function declaration for a call to an external library."
  | descriptorClass callType modifier retType externalName args argType module fn |
  descriptorClass := cue environment
  valueOf: #ExternalFunction
  ifAbsent: [^ false].
  callType := descriptorClass callingConventionFor: here.
  callType == nil ifTrue:[^false].
  [modifier := descriptorClass callingConventionModifierFor: token.
  modifier notNil] whileTrue:
  [self advance.
  callType := callType bitOr: modifier].
  "Parse return type"
  self advance.
  retType := self externalType: descriptorClass.
  retType == nil ifTrue:[^self expected:'return type'].
  "Parse function name or index"
  externalName := here.
  (self match: #string)
  ifTrue:[externalName := externalName asSymbol]
  ifFalse:[(self match:#number) ifFalse:[^self expected:'function name or index']].
  (self match: #leftParenthesis) ifFalse:[^self expected:'argument list'].
  args := WriteStream on: Array new.
  [self match: #rightParenthesis] whileFalse:[
  argType := self externalType: descriptorClass.
  argType == nil ifTrue:[^self expected:'argument'].
  argType isVoid & argType isPointerType not ifFalse:[args nextPut: argType]].
  (self matchToken: 'module:') ifTrue:[
  module := here.
  (self match: #string) ifFalse:[^self expected: 'String'].
  module := module asSymbol].
  Smalltalk at: #ExternalLibraryFunction ifPresent:[:xfn|
  fn := xfn name: externalName
  module: module
  callType: callType
  returnType: retType
  argumentTypes: args contents.
+ encoder litIndex: fn.
- self litIndex: fn.
  fn beWritableObject. "Undo the read-only setting in litIndex:"].
  (self matchToken: 'error:')
  ifTrue:
  [| errorCodeVariable |
  errorCodeVariable := here.
  (hereType == #string
  or: [hereType == #word]) ifFalse:[^self expected: 'error code (a variable or string)'].
  self advance.
  self addPragma: (Pragma keyword: #primitive:error: arguments: (Array with: 120 with: errorCodeVariable)).
  fn ifNotNil: [fn setErrorCodeName: errorCodeVariable]]
  ifFalse:
  [self addPragma: (Pragma keyword: #primitive: arguments: #(120))].
  ^true!