-
Notifications
You must be signed in to change notification settings - Fork 65
/
SmartSyntaxInterpreterPlugin.class.st
113 lines (97 loc) · 3.66 KB
/
SmartSyntaxInterpreterPlugin.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
"
Subclass of InterpreterPlugin, used in connection with TestCodeGenerator for named primitives with type coercion specifications
"
Class {
#name : #SmartSyntaxInterpreterPlugin,
#superclass : #InterpreterPlugin,
#instVars : [
'simulator'
],
#category : #'VMMaker-SmartSyntaxPlugins'
}
{ #category : #private }
SmartSyntaxInterpreterPlugin class >> codeGeneratorClass [
"return the appropriate class of code generator for this kind ofplugin"
^SmartSyntaxPluginCodeGenerator
]
{ #category : #'instance creation' }
SmartSyntaxInterpreterPlugin class >> doPrimitive: primitiveName withArguments: argArray [
| proxy plugin |
proxy := InterpreterProxy new.
proxy loadStackFrom: thisContext sender.
plugin := (self simulatorClass ifNil: [self]) new.
plugin setInterpreter: proxy.
^plugin perform: primitiveName asSymbol withArguments: argArray
]
{ #category : #translation }
SmartSyntaxInterpreterPlugin class >> implicitReturnTypeFor: aSelector [
"Answer the return type for methods that don't have an explicit return."
^#void
]
{ #category : #translation }
SmartSyntaxInterpreterPlugin class >> shouldBeTranslated [
"SmartSyntaxInterpreterPlugin should not be translated but its subclasses should"
^self ~= SmartSyntaxInterpreterPlugin
]
{ #category : #simulation }
SmartSyntaxInterpreterPlugin class >> simulatorClass [
"For running from Smalltalk - answer a class that can be used to simulate the receiver, or nil if you want the primitives in this module to always fail, causing simulation to fall through to the Smalltalk code."
^SmartSyntaxPluginSimulator
]
{ #category : #simulation }
SmartSyntaxInterpreterPlugin class >> simulatorForInterpreterInterface: objectMemoryOrInterpreterProxy [
"Answer an uninitialized (in the sense that the plugin has been sent initialize, but not initialiseModule)
simulator for the receiver, or nil, if the receiver answers nil to simulatorClass. In this case, answer an
instance of SmartSyntaxPluginSimulator wrapped around an uniniialized simulator for the receiver."
^self simulatorClass ifNotNil: "Maybe specific, or the general SmartSyntaxPluginSimulator"
[:simClass| | actualPluginSimClass |
actualPluginSimClass := simClass == SmartSyntaxPluginSimulator
ifTrue: [self subclasses
detect: [:sc| sc name endsWith: 'Simulator']
ifNone: [self]]
ifFalse: [simClass].
SmartSyntaxPluginSimulator new
actualPlugin: actualPluginSimClass new signatureClass: self;
setInterpreter: objectMemoryOrInterpreterProxy;
yourself]
]
{ #category : #translation }
SmartSyntaxInterpreterPlugin class >> translateDoInlining: inlineFlag locally: localFlag debug: debugFlag [
^ self
translate: self moduleName , '.c'
doInlining: inlineFlag
locally: localFlag
debug: debugFlag
]
{ #category : #simulation }
SmartSyntaxInterpreterPlugin >> primitive: primName [
<doNotGenerate>
^simulator primitive: primName
]
{ #category : #simulation }
SmartSyntaxInterpreterPlugin >> primitive: primName parameters: parms [
<doNotGenerate>
^simulator primitive: primName parameters: parms
]
{ #category : #simulation }
SmartSyntaxInterpreterPlugin >> primitive: primName parameters: anArray receiver: aClassSymbol [
<doNotGenerate>
^simulator primitive: primName parameters: anArray receiver: aClassSymbol
]
{ #category : #accessing }
SmartSyntaxInterpreterPlugin >> simulator [
<doNotGenerate>
^simulator
]
{ #category : #accessing }
SmartSyntaxInterpreterPlugin >> simulator: aSmartSyntaxPluginSimulator [
<doNotGenerate>
simulator := aSmartSyntaxPluginSimulator
]
{ #category : #debugging }
SmartSyntaxInterpreterPlugin >> sqAssert: aBool [
self debugCode:
[aBool ifFalse:
[self error: 'Assertion failed!']].
^aBool
]