-
Notifications
You must be signed in to change notification settings - Fork 64
/
Object.extension.st
95 lines (76 loc) · 3.02 KB
/
Object.extension.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
Extension { #name : #Object }
{ #category : #'*SlangBrowser-VMMaker-Translation to C' }
Object class >> asCString [
"Answer the translated C source for this class."
"Interpreter asCString"
"ObjectMemory asCString"
"FilePlugin asCString"
| vmm cg stream |
(Smalltalk hasClassNamed: 'VMMaker')
ifTrue: [vmm := Smalltalk at: #VMMaker]
ifFalse: [^ self notify: 'VMMaker not in this image'].
cg := vmm codeGenerator: #cCode forClass: self.
stream := ReadWriteStream on: String new.
cg emitCCodeOn: stream doAssertions: true.
^ stream contents
]
{ #category : #'*SlangBrowser-VMMaker-Translation to C' }
Object class >> asCString: aSelector [
"Answer the translated C source for a method."
"Interpreter asCString: #bytecodePrimBlockCopy"
"ObjectMemory asCString: #lastPointerOf:"
| vmm cg method stream |
(Smalltalk hasClassNamed: 'VMMaker')
ifTrue: [vmm := Smalltalk at: #VMMaker]
ifFalse: [^ self notify: 'VMMaker not in this image'].
cg := vmm codeGenerator: #cCode forClass: self.
cg isString ifTrue:
[^ '/* ', self name, ' can not be translated. */',
String cr, '/* ', cg, ' */'].
method := cg methodNamed: aSelector.
method ifNil: [^ self methodNotTranslatedMessage: aSelector].
stream := ReadWriteStream on: String new.
method emitCCodeOn: stream generator: cg.
^ stream contents
]
{ #category : #'*SlangBrowser-VMMaker-Translation to C' }
Object class >> asInlinedCString [
"Answer the translated C source for this class."
"Interpreter asInlinedCString"
"ObjectMemory asInlinedCString"
"FilePlugin asInlinedCString"
| vmm cg stream |
(Smalltalk hasClassNamed: 'VMMaker')
ifTrue: [vmm := Smalltalk at: #VMMaker]
ifFalse: [^ self notify: 'VMMaker not in this image'].
cg := vmm codeGenerator: #inlinedCCode forClass: self.
stream := ReadWriteStream on: String new.
cg emitCCodeOn: stream doAssertions: true.
^ stream contents
]
{ #category : #'*SlangBrowser-VMMaker-Translation to C' }
Object class >> asInlinedCString: aSelector [
"Answer the translated Inlined C source for a method."
"Interpreter asCString: #bytecodePrimBlockCopy"
"ObjectMemory asCString: #lastPointerOf:"
| vmm cg method stream |
(Smalltalk hasClassNamed: 'VMMaker')
ifTrue: [vmm := Smalltalk at: #VMMaker]
ifFalse: [^ self notify: 'VMMaker not in this image'].
cg := vmm codeGenerator: #inlinedCCode forClass: self.
cg isString ifTrue:
[^ '/* ', self name, ' can not be translated. */',
String cr, '/* ', cg, ' */'].
method := cg methodNamed: aSelector.
method ifNil: [^ ObjectMemory methodNotTranslatedMessage: aSelector].
stream := ReadWriteStream on: String new.
method emitCCodeOn: stream generator: cg.
^ stream contents
]
{ #category : #'*SlangBrowser-VMMaker-Translation to C' }
Object class >> methodNotTranslatedMessage: aSelector [
"For browser support with VMMaker"
^ '/* No source has been generated for #', aSelector asString, ' */', String cr,
'/* Method may have been fully inlined, or is not exported and */' translated,
String cr, '/* has no senders. See senders of #' translated, aSelector asString, ' */'
]