-
Notifications
You must be signed in to change notification settings - Fork 68
/
CogPrimitiveDescriptor.class.st
73 lines (61 loc) · 1.81 KB
/
CogPrimitiveDescriptor.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Class {
#name : #CogPrimitiveDescriptor,
#superclass : #VMStructType,
#instVars : [
'primitiveGenerator',
'primNumArgs'
],
#category : #'VMMaker-JIT'
}
{ #category : #translation }
CogPrimitiveDescriptor class >> instVarNamesAndTypesForTranslationDo: aBinaryBlock [
"enumerate aBinaryBlock with the names and C type strings for the inst vars to include in a PrimitiveDescriptor struct."
self instVarNames do:
[:ivn|
aBinaryBlock
value: ivn
value: (ivn = 'primitiveGenerator'
ifTrue: [#('sqInt (*' ')(void)')]
ifFalse: [#sqInt])]
]
{ #category : #translation }
CogPrimitiveDescriptor class >> structTypeName [
^self name allButFirst: 3 "Drop initial Cog"
]
{ #category : #accessing }
CogPrimitiveDescriptor >> primNumArgs [
"Answer the value of primNumArgs"
^primNumArgs
]
{ #category : #accessing }
CogPrimitiveDescriptor >> primNumArgs: anObject [
"Set the value of primNumArgs"
^primNumArgs := anObject
]
{ #category : #accessing }
CogPrimitiveDescriptor >> primitiveGenerator [
"Answer the value of primitiveGenerator"
^primitiveGenerator
]
{ #category : #accessing }
CogPrimitiveDescriptor >> primitiveGenerator: anObject [
"Set the value of primitiveGenerator"
^primitiveGenerator := anObject
]
{ #category : #translation }
CogPrimitiveDescriptor >> printCInitializerOn: aStream in: aCCodeGenerator [
<doNotGenerate>
| first |
first := true.
aStream nextPut: ${; space.
self class instVarNamesAndTypesForTranslationDo:
[:ivn :type| | value |
first ifTrue: [first := false] ifFalse: [aStream nextPut: $,; space].
value := self instVarNamed: ivn.
aStream nextPutAll: (value
ifNotNil: [value isSymbol
ifTrue: [aCCodeGenerator cFunctionNameFor: value]
ifFalse: [aCCodeGenerator cLiteralFor: value]]
ifNil: ['0'])].
aStream space; nextPut: $}
]