98
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
657
|
13 |
WriteStream subclass:#CodeStream
|
|
14 |
instanceVariableNames:'class scope requestor'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'System-Compiler ST-80-compatibility'
|
98
|
18 |
!
|
|
19 |
|
|
20 |
!CodeStream class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
25 |
All Rights Reserved
|
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
documentation
|
|
37 |
"
|
|
38 |
This is a pure mimicri class.
|
|
39 |
It is not used by ST/X, but provided to support limited
|
|
40 |
compatibility for applications which build up codetrees,
|
|
41 |
knowing internals of ST-80's compiler class hierarchy.
|
|
42 |
This classes protocol is not (not meant to be) fully covering
|
|
43 |
the corresponding ST-80's classes protocol. It maps ST-80 messages
|
|
44 |
to corresponding ST/X messages (as far as possible).
|
|
45 |
|
|
46 |
NO WARRANTY and GUARANTEE; this class may be removed without notice.
|
|
47 |
"
|
|
48 |
! !
|
|
49 |
|
|
50 |
!CodeStream class methodsFor:'instance creation'!
|
|
51 |
|
|
52 |
new
|
|
53 |
^ super on:(OrderedCollection new:100)
|
|
54 |
! !
|
|
55 |
|
|
56 |
!CodeStream methodsFor:'accessing'!
|
|
57 |
|
|
58 |
class:aClass outerScope:aScope
|
|
59 |
class := aClass.
|
|
60 |
scope := aScope
|
|
61 |
!
|
|
62 |
|
|
63 |
requestor:someOne
|
|
64 |
requestor := someOne
|
|
65 |
! !
|
|
66 |
|
|
67 |
!CodeStream methodsFor:'code generation'!
|
|
68 |
|
|
69 |
makeMethod:aMethodNode
|
|
70 |
"mhmh - kludge-create a compiler and let it generate code"
|
|
71 |
|
|
72 |
|compiler symbolicCodeArray newMethod lits|
|
|
73 |
|
|
74 |
compiler := ByteCodeCompiler new.
|
|
75 |
compiler notifying:requestor.
|
|
76 |
compiler targetClass:class.
|
|
77 |
|
|
78 |
symbolicCodeArray := self contents.
|
|
79 |
(compiler genByteCodeFrom:symbolicCodeArray) == #Error ifTrue:[
|
657
|
80 |
self halt
|
98
|
81 |
].
|
|
82 |
|
|
83 |
newMethod := Method new.
|
|
84 |
newMethod byteCode:(compiler code).
|
|
85 |
lits := compiler literalArray.
|
|
86 |
lits notNil ifTrue:[
|
657
|
87 |
newMethod literals:lits
|
98
|
88 |
].
|
657
|
89 |
newMethod numberOfVars:(compiler numberOfMethodVars).
|
|
90 |
newMethod numberOfArgs:(compiler numberOfMethodArgs).
|
98
|
91 |
newMethod stackSize:(compiler maxStackDepth).
|
|
92 |
|
|
93 |
Project notNil ifTrue:[
|
657
|
94 |
newMethod package:(Project currentPackageName)
|
98
|
95 |
].
|
|
96 |
|
|
97 |
class addSelector:aMethodNode selector withMethod:newMethod.
|
|
98 |
^ newMethod
|
657
|
99 |
|
|
100 |
"Modified: / 4.3.1998 / 14:46:34 / stefan"
|
98
|
101 |
! !
|
657
|
102 |
|
|
103 |
!CodeStream class methodsFor:'documentation'!
|
|
104 |
|
|
105 |
version
|
|
106 |
^ '$Header: /cvs/stx/stx/libcomp/CodeStream.st,v 1.6 1998-03-06 15:38:37 stefan Exp $'
|
|
107 |
! !
|