VM Maker: VMMaker.oscog-eem.2859.mcz

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

VM Maker: VMMaker.oscog-eem.2859.mcz

commits-2
 
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2859.mcz

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

Name: VMMaker.oscog-eem.2859
Author: eem
Time: 28 October 2020, 5:16:02.046216 pm
UUID: cf8dc817-56ad-44b6-a593-7ec5a163df5f
Ancestors: VMMaker.oscog-eem.2858

Allow processor predefined macros to include expressions (i.e. __ARM_ARCH >= 8).

=============== Diff against VMMaker.oscog-eem.2858 ===============

Item was changed:
  ----- Method: Cogit class>>generateCodeStringForCogitDotC (in category 'translation') -----
  generateCodeStringForCogitDotC
  "Generate a skeletal cogit.c that includes the relevant cogitFOO.c
  for the appropriate subclasses of CogAbstractInstruction.
  self generateCodeStringForCogitDotC"
 
  | string insertPosition abis defaultDef |
  abis := OrderedCollection new.
  string := String streamContents:
  [:s|
  s nextPutAll: '/* Automatically generated by\ ' withCRs.
  s nextPutAll: (CCodeGenerator monticelloDescriptionFor: self).
  s cr; nextPutAll: ' */'.
  s cr; cr; nextPut: $#.
  insertPosition := s position.
  self translateableInstructionSubclassesAndInstalledOptionsDo:
  [:class | | abi |
  s nextPutAll: 'if '.
  (abi := InitializationOptions at: #ABI ifAbsent: []) ifNotNil:
  [s nextPutAll: (abis addLast: abi); nextPutAll: ' && ('].
  class identifyingPredefinedMacros
+ do: [:predefinedMacro|
+ (predefinedMacro includes: Character space) "not a macr name but an expression"
+ ifTrue: [s nextPut: $(; nextPutAll: predefinedMacro]
+ ifFalse: [s nextPutAll: 'defined('; nextPutAll: predefinedMacro].
+ s nextPut: $)]
- do: [:predefinedMacro| s nextPutAll: 'defined('; nextPutAll: predefinedMacro; nextPut: $)]
  separatedBy: [s nextPutAll: ' || '].
  abi ifNotNil: [s nextPut: $)].
  s cr; cr; nextPutAll: '# include "'; nextPutAll: class moduleName; nextPutAll: '.c"'.
  s cr; cr; nextPutAll: '#el'].
  s nextPutAll: 'se'.
  #( 'As yet no Cogit implementation appears to exist for your platform.'
  'Consider implementing it, starting by adding a subclass of CogAbstractInstruction.') do:
  [:msg| s cr; nextPutAll: '# error '; nextPutAll: msg].
  s cr; nextPutAll: '#endif'; cr].
  abis isEmpty ifTrue:
  [^string].
  defaultDef := String streamContents:
  [:s|
  s nextPutAll: '#if !!'.
  abis do: [:abi| s nextPutAll: abi] separatedBy: [s nextPutAll: ' && !!'].
  s cr; nextPutAll: '# define '; nextPutAll: abis first; nextPutAll: ' 1'; cr.
  s nextPutAll: '#endif'; cr; cr].
  ^string copyReplaceFrom: insertPosition to: insertPosition - 1 with: defaultDef!