.
--- a/AssignNd.st Wed Aug 30 20:26:53 1995 +0200
+++ b/AssignNd.st Thu Sep 07 14:07:16 1995 +0200
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Attic/AssignNd.st,v 1.11 1995-08-11 20:27:30 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/AssignNd.st,v 1.12 1995-09-07 12:06:26 claus Exp $
'!
!AssignmentNode class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Attic/AssignNd.st,v 1.11 1995-08-11 20:27:30 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/AssignNd.st,v 1.12 1995-09-07 12:06:26 claus Exp $
"
!
@@ -88,26 +88,26 @@
!AssignmentNode methodsFor:'code generation'!
-codeForSideEffectOn:aStream inBlock:b for:aCompiler
- |sel arg|
+checkIncDecOn:aStream
+ |sel erec arg code|
(variable type == #MethodVariable) ifTrue:[
expression isBinaryMessage ifTrue:[
sel := expression selector.
+ erec := expression receiver.
((sel == #+) or:[sel == #-]) ifTrue:[
- (expression receiver type == #MethodVariable) ifTrue:[
- (expression receiver index == variable index) ifTrue:[
+ (erec type == #MethodVariable) ifTrue:[
+ (erec index == variable index) ifTrue:[
arg := expression arg1.
arg isConstant ifTrue:[
(arg value == 1) ifTrue:[
(sel == #+) ifTrue:[
- aStream nextPut:#incMethodVar
+ code := #incMethodVar
] ifFalse:[
- aStream nextPut:#decMethodVar
+ code := #decMethodVar
].
- aStream nextPut:(expression lineNumber).
- aStream nextPut:(variable index).
- ^ self
+ aStream nextPut:code; nextPut:(expression lineNumber); nextPut:(variable index).
+ ^ true
]
]
]
@@ -115,11 +115,22 @@
]
]
].
+ ^ false
+!
+
+codeForSideEffectOn:aStream inBlock:b for:aCompiler
+ (self checkIncDecOn:aStream) ifTrue:[^ self].
expression codeOn:aStream inBlock:b for:aCompiler.
variable codeStoreOn:aStream inBlock:b valueNeeded:false for:aCompiler
+
+ "Modified: 4.9.1995 / 14:38:10 / claus"
!
codeOn:aStream inBlock:b for:aCompiler
+ (self checkIncDecOn:aStream) ifTrue:[
+ expression receiver codeOn:aStream inBlock:b for:aCompiler.
+ ^ self
+ ].
expression codeOn:aStream inBlock:b for:aCompiler.
variable codeStoreOn:aStream inBlock:b valueNeeded:true for:aCompiler
! !
--- a/AssignmentNode.st Wed Aug 30 20:26:53 1995 +0200
+++ b/AssignmentNode.st Thu Sep 07 14:07:16 1995 +0200
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.11 1995-08-11 20:27:30 claus Exp $
+$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.12 1995-09-07 12:06:26 claus Exp $
'!
!AssignmentNode class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.11 1995-08-11 20:27:30 claus Exp $
+$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.12 1995-09-07 12:06:26 claus Exp $
"
!
@@ -88,26 +88,26 @@
!AssignmentNode methodsFor:'code generation'!
-codeForSideEffectOn:aStream inBlock:b for:aCompiler
- |sel arg|
+checkIncDecOn:aStream
+ |sel erec arg code|
(variable type == #MethodVariable) ifTrue:[
expression isBinaryMessage ifTrue:[
sel := expression selector.
+ erec := expression receiver.
((sel == #+) or:[sel == #-]) ifTrue:[
- (expression receiver type == #MethodVariable) ifTrue:[
- (expression receiver index == variable index) ifTrue:[
+ (erec type == #MethodVariable) ifTrue:[
+ (erec index == variable index) ifTrue:[
arg := expression arg1.
arg isConstant ifTrue:[
(arg value == 1) ifTrue:[
(sel == #+) ifTrue:[
- aStream nextPut:#incMethodVar
+ code := #incMethodVar
] ifFalse:[
- aStream nextPut:#decMethodVar
+ code := #decMethodVar
].
- aStream nextPut:(expression lineNumber).
- aStream nextPut:(variable index).
- ^ self
+ aStream nextPut:code; nextPut:(expression lineNumber); nextPut:(variable index).
+ ^ true
]
]
]
@@ -115,11 +115,22 @@
]
]
].
+ ^ false
+!
+
+codeForSideEffectOn:aStream inBlock:b for:aCompiler
+ (self checkIncDecOn:aStream) ifTrue:[^ self].
expression codeOn:aStream inBlock:b for:aCompiler.
variable codeStoreOn:aStream inBlock:b valueNeeded:false for:aCompiler
+
+ "Modified: 4.9.1995 / 14:38:10 / claus"
!
codeOn:aStream inBlock:b for:aCompiler
+ (self checkIncDecOn:aStream) ifTrue:[
+ expression receiver codeOn:aStream inBlock:b for:aCompiler.
+ ^ self
+ ].
expression codeOn:aStream inBlock:b for:aCompiler.
variable codeStoreOn:aStream inBlock:b valueNeeded:true for:aCompiler
! !
--- a/BCompiler.st Wed Aug 30 20:26:53 1995 +0200
+++ b/BCompiler.st Thu Sep 07 14:07:16 1995 +0200
@@ -26,7 +26,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.37 1995-08-23 17:53:21 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.38 1995-09-07 12:06:30 claus Exp $
'!
!ByteCodeCompiler class methodsFor:'documentation'!
@@ -47,7 +47,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.37 1995-08-23 17:53:21 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.38 1995-09-07 12:06:30 claus Exp $
"
!
@@ -736,6 +736,28 @@
self appendByte:0.
symIndex := symIndex + 5
].
+ (extra == #speciallitS) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 1.
+ self appendByte:index.
+ self appendByte:0. "space for inline-generation"
+ self appendByte:0. "space for inline-address"
+ self appendByte:0.
+ self appendByte:0.
+ self appendByte:0.
+ symIndex := symIndex + 5
+ ].
+ (extra == #speciallitL) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 2.
+ self appendWord:index.
+ self appendByte:0. "space for inline-generation"
+ self appendByte:0. "space for inline-address"
+ self appendByte:0.
+ self appendByte:0.
+ self appendByte:0.
+ symIndex := symIndex + 5
+ ].
(extra == #offset) ifTrue:[
relocInfo at:symIndex put:codeIndex.
self addReloc:symIndex.
@@ -784,73 +806,67 @@
symIndex := symIndex + 1.
self appendByte:level
].
- ].
- extra == #special ifTrue:[
- ((codeSymbol == #send)
- or:[codeSymbol == #superSend
- or:[codeSymbol == #hereSend]]) ifTrue:[
- index := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 1.
- nargs := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 1.
- self appendByte:nargs.
- self appendByte:index.
- (codeSymbol == #superSend) ifTrue:[
- symIndex := symIndex + 1.
- index := self addLiteral:(classToCompileFor superclass).
- self appendByte:index
- ].
- (codeSymbol == #hereSend) ifTrue:[
- symIndex := symIndex + 1.
- index := self addLiteral:classToCompileFor.
- self appendByte:index
- ].
- stackDelta := nargs negated
- ] ifFalse:[
- (codeSymbol == #sendDrop) ifTrue:[
+ extra == #special ifTrue:[
+ ((codeSymbol == #send)
+ or:[codeSymbol == #sendSelf
+ or:[codeSymbol == #superSend
+ or:[codeSymbol == #hereSend]]]) ifTrue:[
index := symbolicCodeArray at:symIndex.
symIndex := symIndex + 1.
nargs := symbolicCodeArray at:symIndex.
symIndex := symIndex + 1.
self appendByte:nargs.
self appendByte:index.
- stackDelta := (nargs + 1) negated
+
+ (codeSymbol == #superSend
+ or:[codeSymbol == #hereSend]) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 1.
+ self appendByte:index
+ ].
+ stackDelta := nargs negated.
+ codeSymbol == #sendSelf ifTrue:[
+ stackDelta := stackDelta + 1
+ ]
] ifFalse:[
- (codeSymbol == #sendDropL) ifTrue:[
+ (codeSymbol == #sendDrop) ifTrue:[
index := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 2.
+ symIndex := symIndex + 1.
nargs := symbolicCodeArray at:symIndex.
symIndex := symIndex + 1.
self appendByte:nargs.
- self appendWord:index.
+ self appendByte:index.
stackDelta := (nargs + 1) negated
- ] ifFalse:[
- ((codeSymbol == #sendL)
- or:[codeSymbol == #superSendL
- or:[codeSymbol == #hereSendL]]) ifTrue:[
- index := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 1.
- nargs := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 1.
- self appendByte:nargs.
- self appendWord:index.
- (codeSymbol == #superSendL) ifTrue:[
- symIndex := symIndex + 1.
- index := self addLiteral:(classToCompileFor superclass).
- self appendByte:index
- ].
- (codeSymbol == #hereSendL) ifTrue:[
- symIndex := symIndex + 1.
- index := self addLiteral:classToCompileFor.
- self appendByte:index
- ].
- stackDelta := nargs negated
- ]
+ ]
+ ]
+ ].
+
+ extra == #specialL ifTrue:[
+ ((codeSymbol == #sendL)
+ or:[codeSymbol == #sendSelfL
+ or:[codeSymbol == #superSendL
+ or:[codeSymbol == #hereSendL]]]) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 2.
+ nargs := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 1.
+ self appendByte:nargs.
+ self appendWord:index.
+ (codeSymbol == #superSendL
+ or:[codeSymbol == #hereSendL]) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 2.
+ self appendWord:index.
+ ].
+ stackDelta := nargs negated.
+ codeSymbol == #sendSelfL ifTrue:[
+ stackDelta := stackDelta + 1
]
]
].
].
+
stackDepth := stackDepth + stackDelta.
(stackDepth > maxStackDepth) ifTrue:[
maxStackDepth := stackDepth
@@ -880,6 +896,8 @@
].
"code printNL."
^ errorFlag
+
+ "Modified: 3.9.1995 / 12:59:43 / claus"
!
absJumpFromJump:code
@@ -1272,13 +1290,7 @@
(aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42].
(aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128].
- (aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37].
- (aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38].
- (aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39].
-
(aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0].
-"/ (aSymbol == #blockRetTop) ifTrue:[stackDelta := -1. ^ 6].
-
(aSymbol == #retSelf) ifTrue:[^5].
(aSymbol == #==) ifTrue:[stackDelta := -1. self addLiteral:aSymbol. ^ 45].
@@ -1300,20 +1312,25 @@
(aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19].
(aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20].
(aSymbol == #hereSend) ifTrue:[lineno := true. extra := #special. ^ 20].
+ (aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13].
(aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18].
(aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47].
- (aSymbol == #pushClassVar) ifTrue:[stackDelta := 1. extra := #speciallit. ^ 35].
- (aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176].
- (aSymbol == #pushGlobal) ifTrue:[stackDelta := 1. extra := #speciallit. ^ 36].
+ (aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37].
+ (aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38].
+ (aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39].
- (aSymbol == #storeClassVar) ifTrue:[extra := #speciallit.stackDelta := -1. ^ 40].
- (aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177].
- (aSymbol == #storeGlobal) ifTrue:[extra := #speciallit. stackDelta := -1. ^ 41].
+ (aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35].
+ (aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35].
+
+ (aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40].
+ (aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 40].
+
(aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129].
- (aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201].
+ (aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176].
+ (aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177].
"optimized bytecodes"
@@ -1468,6 +1485,7 @@
(aSymbol == #mkNilBlock) ifTrue:[^ 157].
(aSymbol == #gt0) ifTrue:[lineno := true. self addLiteral:#>. ^ 212].
+ (aSymbol == #pushgt0) ifTrue:[lineno := true. stackDelta := 1. self addLiteral:#>. ^ 208].
(aSymbol == #basicNew) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 211].
(aSymbol == #new) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 213].
(aSymbol == #basicNew:) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 214].
@@ -1492,13 +1510,22 @@
(aSymbol == #&) ifTrue:[lineno := true. ^ 216].
(aSymbol == #|) ifTrue:[lineno := true. ^ 217].
- (aSymbol == #sendL) ifTrue:[lineno := true. extra := #special. ^ 205].
- (aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #special. ^ 204].
- (aSymbol == #superSendL) ifTrue:[lineno := true. extra := #special. ^ 206].
- (aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #special. ^ 206].
+ (aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
+ (aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
+ (aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219].
+ (aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219].
+ (aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201].
+
+ (aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205].
+ (aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207].
+ (aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204].
+ (aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
+ (aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
self error:'invalid code symbol'.
errorFlag := #Error
+
+ "Modified: 3.9.1995 / 12:58:47 / claus"
! !
!ByteCodeCompiler methodsFor:'machine code generation'!
--- a/ByteCodeCompiler.st Wed Aug 30 20:26:53 1995 +0200
+++ b/ByteCodeCompiler.st Thu Sep 07 14:07:16 1995 +0200
@@ -26,7 +26,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.37 1995-08-23 17:53:21 claus Exp $
+$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.38 1995-09-07 12:06:30 claus Exp $
'!
!ByteCodeCompiler class methodsFor:'documentation'!
@@ -47,7 +47,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.37 1995-08-23 17:53:21 claus Exp $
+$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.38 1995-09-07 12:06:30 claus Exp $
"
!
@@ -736,6 +736,28 @@
self appendByte:0.
symIndex := symIndex + 5
].
+ (extra == #speciallitS) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 1.
+ self appendByte:index.
+ self appendByte:0. "space for inline-generation"
+ self appendByte:0. "space for inline-address"
+ self appendByte:0.
+ self appendByte:0.
+ self appendByte:0.
+ symIndex := symIndex + 5
+ ].
+ (extra == #speciallitL) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 2.
+ self appendWord:index.
+ self appendByte:0. "space for inline-generation"
+ self appendByte:0. "space for inline-address"
+ self appendByte:0.
+ self appendByte:0.
+ self appendByte:0.
+ symIndex := symIndex + 5
+ ].
(extra == #offset) ifTrue:[
relocInfo at:symIndex put:codeIndex.
self addReloc:symIndex.
@@ -784,73 +806,67 @@
symIndex := symIndex + 1.
self appendByte:level
].
- ].
- extra == #special ifTrue:[
- ((codeSymbol == #send)
- or:[codeSymbol == #superSend
- or:[codeSymbol == #hereSend]]) ifTrue:[
- index := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 1.
- nargs := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 1.
- self appendByte:nargs.
- self appendByte:index.
- (codeSymbol == #superSend) ifTrue:[
- symIndex := symIndex + 1.
- index := self addLiteral:(classToCompileFor superclass).
- self appendByte:index
- ].
- (codeSymbol == #hereSend) ifTrue:[
- symIndex := symIndex + 1.
- index := self addLiteral:classToCompileFor.
- self appendByte:index
- ].
- stackDelta := nargs negated
- ] ifFalse:[
- (codeSymbol == #sendDrop) ifTrue:[
+ extra == #special ifTrue:[
+ ((codeSymbol == #send)
+ or:[codeSymbol == #sendSelf
+ or:[codeSymbol == #superSend
+ or:[codeSymbol == #hereSend]]]) ifTrue:[
index := symbolicCodeArray at:symIndex.
symIndex := symIndex + 1.
nargs := symbolicCodeArray at:symIndex.
symIndex := symIndex + 1.
self appendByte:nargs.
self appendByte:index.
- stackDelta := (nargs + 1) negated
+
+ (codeSymbol == #superSend
+ or:[codeSymbol == #hereSend]) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 1.
+ self appendByte:index
+ ].
+ stackDelta := nargs negated.
+ codeSymbol == #sendSelf ifTrue:[
+ stackDelta := stackDelta + 1
+ ]
] ifFalse:[
- (codeSymbol == #sendDropL) ifTrue:[
+ (codeSymbol == #sendDrop) ifTrue:[
index := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 2.
+ symIndex := symIndex + 1.
nargs := symbolicCodeArray at:symIndex.
symIndex := symIndex + 1.
self appendByte:nargs.
- self appendWord:index.
+ self appendByte:index.
stackDelta := (nargs + 1) negated
- ] ifFalse:[
- ((codeSymbol == #sendL)
- or:[codeSymbol == #superSendL
- or:[codeSymbol == #hereSendL]]) ifTrue:[
- index := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 1.
- nargs := symbolicCodeArray at:symIndex.
- symIndex := symIndex + 1.
- self appendByte:nargs.
- self appendWord:index.
- (codeSymbol == #superSendL) ifTrue:[
- symIndex := symIndex + 1.
- index := self addLiteral:(classToCompileFor superclass).
- self appendByte:index
- ].
- (codeSymbol == #hereSendL) ifTrue:[
- symIndex := symIndex + 1.
- index := self addLiteral:classToCompileFor.
- self appendByte:index
- ].
- stackDelta := nargs negated
- ]
+ ]
+ ]
+ ].
+
+ extra == #specialL ifTrue:[
+ ((codeSymbol == #sendL)
+ or:[codeSymbol == #sendSelfL
+ or:[codeSymbol == #superSendL
+ or:[codeSymbol == #hereSendL]]]) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 2.
+ nargs := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 1.
+ self appendByte:nargs.
+ self appendWord:index.
+ (codeSymbol == #superSendL
+ or:[codeSymbol == #hereSendL]) ifTrue:[
+ index := symbolicCodeArray at:symIndex.
+ symIndex := symIndex + 2.
+ self appendWord:index.
+ ].
+ stackDelta := nargs negated.
+ codeSymbol == #sendSelfL ifTrue:[
+ stackDelta := stackDelta + 1
]
]
].
].
+
stackDepth := stackDepth + stackDelta.
(stackDepth > maxStackDepth) ifTrue:[
maxStackDepth := stackDepth
@@ -880,6 +896,8 @@
].
"code printNL."
^ errorFlag
+
+ "Modified: 3.9.1995 / 12:59:43 / claus"
!
absJumpFromJump:code
@@ -1272,13 +1290,7 @@
(aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42].
(aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128].
- (aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37].
- (aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38].
- (aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39].
-
(aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0].
-"/ (aSymbol == #blockRetTop) ifTrue:[stackDelta := -1. ^ 6].
-
(aSymbol == #retSelf) ifTrue:[^5].
(aSymbol == #==) ifTrue:[stackDelta := -1. self addLiteral:aSymbol. ^ 45].
@@ -1300,20 +1312,25 @@
(aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19].
(aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20].
(aSymbol == #hereSend) ifTrue:[lineno := true. extra := #special. ^ 20].
+ (aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13].
(aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18].
(aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47].
- (aSymbol == #pushClassVar) ifTrue:[stackDelta := 1. extra := #speciallit. ^ 35].
- (aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176].
- (aSymbol == #pushGlobal) ifTrue:[stackDelta := 1. extra := #speciallit. ^ 36].
+ (aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37].
+ (aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38].
+ (aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39].
- (aSymbol == #storeClassVar) ifTrue:[extra := #speciallit.stackDelta := -1. ^ 40].
- (aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177].
- (aSymbol == #storeGlobal) ifTrue:[extra := #speciallit. stackDelta := -1. ^ 41].
+ (aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35].
+ (aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35].
+
+ (aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40].
+ (aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 40].
+
(aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129].
- (aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201].
+ (aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176].
+ (aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177].
"optimized bytecodes"
@@ -1468,6 +1485,7 @@
(aSymbol == #mkNilBlock) ifTrue:[^ 157].
(aSymbol == #gt0) ifTrue:[lineno := true. self addLiteral:#>. ^ 212].
+ (aSymbol == #pushgt0) ifTrue:[lineno := true. stackDelta := 1. self addLiteral:#>. ^ 208].
(aSymbol == #basicNew) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 211].
(aSymbol == #new) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 213].
(aSymbol == #basicNew:) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 214].
@@ -1492,13 +1510,22 @@
(aSymbol == #&) ifTrue:[lineno := true. ^ 216].
(aSymbol == #|) ifTrue:[lineno := true. ^ 217].
- (aSymbol == #sendL) ifTrue:[lineno := true. extra := #special. ^ 205].
- (aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #special. ^ 204].
- (aSymbol == #superSendL) ifTrue:[lineno := true. extra := #special. ^ 206].
- (aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #special. ^ 206].
+ (aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
+ (aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
+ (aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219].
+ (aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219].
+ (aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201].
+
+ (aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205].
+ (aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207].
+ (aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204].
+ (aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
+ (aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
self error:'invalid code symbol'.
errorFlag := #Error
+
+ "Modified: 3.9.1995 / 12:58:47 / claus"
! !
!ByteCodeCompiler methodsFor:'machine code generation'!
--- a/MessageNd.st Wed Aug 30 20:26:53 1995 +0200
+++ b/MessageNd.st Thu Sep 07 14:07:16 1995 +0200
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Attic/MessageNd.st,v 1.29 1995-08-23 17:53:37 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/MessageNd.st,v 1.30 1995-09-07 12:06:43 claus Exp $
'!
!MessageNode class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Attic/MessageNd.st,v 1.29 1995-08-23 17:53:37 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/MessageNd.st,v 1.30 1995-09-07 12:06:43 claus Exp $
"
!
@@ -192,17 +192,26 @@
!
receiver:recNode selector:selectorString args:argArray fold:folding
+ |numArgs|
+
+ numArgs := argArray size.
folding ifTrue:[
- (argArray size == 1) ifTrue:[
+ (numArgs == 1) ifTrue:[
^ self receiver:recNode selector:selectorString arg:(argArray at:1) fold:true
].
"uncomment the follwoing for a nice array initializer optimization ..."
-"/ (argArray size == 2) ifTrue:[
+"/ (numArgs == 2) ifTrue:[
"/ ^ self receiver:recNode selector:selectorString arg1:(argArray at:1) arg2:(argArray at:2) fold:true
"/ ].
+ numArgs > Method maxNumberOfArguments ifTrue:[
+ ^ 'too many arguments for current VM implementation'.
+ ].
].
+
^ (self basicNew) receiver:recNode selector:selectorString args:argArray lineno:0
+
+ "Modified: 3.9.1995 / 16:41:39 / claus"
! !
!MessageNode methodsFor:'accessing'!
@@ -769,7 +778,8 @@
pos := aStream position.
"/ aStream nextPut:#dup; nextPut:#push0; nextPut:#>; nextPut:lineNr; nextPut:#falseJump.
- aStream nextPut:#dup; nextPut:#gt0; nextPut:lineNr; nextPut:#falseJump.
+"/ aStream nextPut:#dup; nextPut:#gt0; nextPut:lineNr; nextPut:#falseJump.
+ aStream nextPut:#pushgt0; nextPut:lineNr; nextPut:#falseJump.
pos2 := aStream position.
aStream nextPut:0.
@@ -1094,7 +1104,7 @@
!
codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
- |nargs isBuiltIn index code|
+ |recType nargs isBuiltIn litIndex cls clsLitIndex code|
argArray isNil ifTrue:[
nargs := 0
@@ -1103,9 +1113,10 @@
].
isBuiltIn := false.
+ recType := receiver type.
(nargs == 0) ifTrue:[
- (receiver type == #ThisContext) ifTrue:[
+ (recType == #ThisContext) ifTrue:[
valueNeeded ifFalse:[
"for now, only do it in methods"
b isNil ifTrue:[
@@ -1131,7 +1142,7 @@
].
(nargs == 1) ifTrue:[
- (receiver type == #ThisContext) ifTrue:[
+ (recType == #ThisContext) ifTrue:[
valueNeeded ifFalse:[
(selector == #return:) ifTrue:[
(argArray at:1) codeOn:aStream inBlock:b for:aCompiler. "^ value"
@@ -1217,25 +1228,33 @@
].
"no - generate a send"
- ((receiver type ~~ #Self)
- or:[nargs > 3]) ifTrue:[
- receiver codeOn:aStream inBlock:b for:aCompiler
- ].
- argArray notNil ifTrue:[
- argArray do:[:arg |
- arg codeOn:aStream inBlock:b for:aCompiler
- ]
+
+ receiver isSuper ifTrue:[
+ cls := aCompiler targetClass.
+ receiver isHere ifTrue:[
+ code := #hereSend.
+ ] ifFalse:[
+ code := #superSend.
+ cls := cls superclass.
+ ].
+ clsLitIndex := aCompiler addLiteral:cls.
+ ] ifFalse:[
+ clsLitIndex := 0.
].
- index := aCompiler addLiteral:selector.
- index <= 255 ifTrue:[
+ litIndex := aCompiler addLiteral:selector.
+ (litIndex <= 255 and:[clsLitIndex <= 255]) ifTrue:[
+ (recType ~~ #Self) ifTrue:[
+ receiver codeOn:aStream inBlock:b for:aCompiler
+ ].
+ argArray notNil ifTrue:[
+ argArray do:[:arg |
+ arg codeOn:aStream inBlock:b for:aCompiler
+ ]
+ ].
+
receiver isSuper ifTrue:[
- receiver isHere ifTrue:[
- code := #hereSend
- ] ifFalse:[
- code := #superSend.
- ].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs; nextPut:nil.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:clsLitIndex.
valueNeeded ifFalse:[
aStream nextPut:#drop
].
@@ -1258,45 +1277,71 @@
codes := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3)
]
].
- aStream nextPut:(codes at:nargs + 1); nextPut:lineNr; nextPut:index.
+ aStream nextPut:(codes at:(nargs + 1)); nextPut:lineNr; nextPut:litIndex.
^ self
].
- valueNeeded ifTrue:[
- code := #send
+ (recType == #Self) ifTrue:[
+ code := #sendSelf
] ifFalse:[
- code := #sendDrop
+ valueNeeded ifTrue:[
+ code := #send
+ ] ifFalse:[
+ code := #sendDrop
+ ]
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
+ valueNeeded ifFalse:[
+ (recType == #Self) ifTrue:[
+ aStream nextPut:#drop
+ ]
+ ].
^ self
].
"needs 16bit literal index"
+
receiver isSuper ifTrue:[
+ argArray notNil ifTrue:[
+ argArray do:[:arg |
+ arg codeOn:aStream inBlock:b for:aCompiler
+ ]
+ ].
receiver isHere ifTrue:[
code := #hereSendL
] ifFalse:[
code := #superSendL.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs; nextPut:nil.
- valueNeeded ifFalse:[
- aStream nextPut:#drop
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:clsLitIndex; nextPut:0.
+ ] ifFalse:[
+ recType ~~ #Self ifTrue:[
+ receiver codeOn:aStream inBlock:b for:aCompiler.
].
- ^ self
+ argArray notNil ifTrue:[
+ argArray do:[:arg |
+ arg codeOn:aStream inBlock:b for:aCompiler
+ ]
+ ].
+
+ recType == #Self ifTrue:[
+ code := #sendSelfL
+ ] ifFalse:[
+ code := #sendL
+ ].
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs.
].
- valueNeeded ifTrue:[
- code := #sendL
- ] ifFalse:[
- code := #sendDropL
+ valueNeeded ifFalse:[
+ aStream nextPut:#drop
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs
+
+ "Modified: 3.9.1995 / 12:55:42 / claus"
!
codeSendOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
"like code on, but assumes that receiver has already been
coded onto stack - needed for cascade"
- |nargs isBuiltIn code index|
+ |nargs isBuiltIn code litIndex|
argArray isNil ifTrue:[
nargs := 0
@@ -1343,21 +1388,21 @@
].
receiver isSuper ifTrue:[
- index := aCompiler addLiteral:selector.
- index <= 255 ifTrue:[
+ litIndex := aCompiler addLiteral:selector.
+ litIndex <= 255 ifTrue:[
receiver isHere ifTrue:[
code := #hereSend
] ifFalse:[
code := #superSend.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs; nextPut:nil.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:nil.
] ifFalse:[
receiver isHere ifTrue:[
code := #hereSendL
] ifFalse:[
code := #superSendL.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs; nextPut:nil.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:nil.
].
valueNeeded ifFalse:[
aStream nextPut:#drop
@@ -1376,15 +1421,15 @@
].
].
- index := aCompiler addLiteral:selector.
- index <= 255 ifTrue:[
+ litIndex := aCompiler addLiteral:selector.
+ litIndex <= 255 ifTrue:[
(nargs <= 3) ifTrue:[
valueNeeded ifTrue:[
code := #(send0 send1 send2 send3) at:(nargs+1).
] ifFalse:[
code := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3) at:(nargs+1).
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex.
^ self
].
@@ -1393,7 +1438,7 @@
] ifFalse:[
code := #sendDrop
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
^ self
].
@@ -1402,13 +1447,13 @@
] ifFalse:[
code := #sendDropL
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs
!
codeForCascadeOn:aStream inBlock:b for:aCompiler
"like codeOn, but always leave the receiver instead of the result"
- |nargs isBuiltIn code index|
+ |nargs isBuiltIn code litIndex|
argArray isNil ifTrue:[
nargs := 0
@@ -1455,24 +1500,24 @@
arg codeOn:aStream inBlock:b for:aCompiler
]
].
- index := aCompiler addLiteral:selector.
- index <= 255 ifTrue:[
+ litIndex := aCompiler addLiteral:selector.
+ litIndex <= 255 ifTrue:[
receiver isSuper ifTrue:[
receiver isHere ifTrue:[
code := #hereSend
] ifFalse:[
code := #superSend.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs; nextPut:nil; nextPut:#drop.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:nil; nextPut:#drop.
^ self
].
(nargs <= 3) ifTrue:[
code := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3) at:(nargs+1).
- aStream nextPut:code; nextPut:lineNr; nextPut:index.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex.
^ self
].
- aStream nextPut:#sendDrop; nextPut:lineNr; nextPut:index; nextPut:nargs.
+ aStream nextPut:#sendDrop; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
^ self
].
"need 16bit litIndex"
@@ -1482,8 +1527,8 @@
] ifFalse:[
code := #superSendL.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs; nextPut:nil; nextPut:#drop.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:nil; nextPut:#drop.
^ self
].
- aStream nextPut:#sendDropL; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs
+ aStream nextPut:#sendDropL; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs
! !
--- a/MessageNode.st Wed Aug 30 20:26:53 1995 +0200
+++ b/MessageNode.st Thu Sep 07 14:07:16 1995 +0200
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.29 1995-08-23 17:53:37 claus Exp $
+$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.30 1995-09-07 12:06:43 claus Exp $
'!
!MessageNode class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.29 1995-08-23 17:53:37 claus Exp $
+$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.30 1995-09-07 12:06:43 claus Exp $
"
!
@@ -192,17 +192,26 @@
!
receiver:recNode selector:selectorString args:argArray fold:folding
+ |numArgs|
+
+ numArgs := argArray size.
folding ifTrue:[
- (argArray size == 1) ifTrue:[
+ (numArgs == 1) ifTrue:[
^ self receiver:recNode selector:selectorString arg:(argArray at:1) fold:true
].
"uncomment the follwoing for a nice array initializer optimization ..."
-"/ (argArray size == 2) ifTrue:[
+"/ (numArgs == 2) ifTrue:[
"/ ^ self receiver:recNode selector:selectorString arg1:(argArray at:1) arg2:(argArray at:2) fold:true
"/ ].
+ numArgs > Method maxNumberOfArguments ifTrue:[
+ ^ 'too many arguments for current VM implementation'.
+ ].
].
+
^ (self basicNew) receiver:recNode selector:selectorString args:argArray lineno:0
+
+ "Modified: 3.9.1995 / 16:41:39 / claus"
! !
!MessageNode methodsFor:'accessing'!
@@ -769,7 +778,8 @@
pos := aStream position.
"/ aStream nextPut:#dup; nextPut:#push0; nextPut:#>; nextPut:lineNr; nextPut:#falseJump.
- aStream nextPut:#dup; nextPut:#gt0; nextPut:lineNr; nextPut:#falseJump.
+"/ aStream nextPut:#dup; nextPut:#gt0; nextPut:lineNr; nextPut:#falseJump.
+ aStream nextPut:#pushgt0; nextPut:lineNr; nextPut:#falseJump.
pos2 := aStream position.
aStream nextPut:0.
@@ -1094,7 +1104,7 @@
!
codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
- |nargs isBuiltIn index code|
+ |recType nargs isBuiltIn litIndex cls clsLitIndex code|
argArray isNil ifTrue:[
nargs := 0
@@ -1103,9 +1113,10 @@
].
isBuiltIn := false.
+ recType := receiver type.
(nargs == 0) ifTrue:[
- (receiver type == #ThisContext) ifTrue:[
+ (recType == #ThisContext) ifTrue:[
valueNeeded ifFalse:[
"for now, only do it in methods"
b isNil ifTrue:[
@@ -1131,7 +1142,7 @@
].
(nargs == 1) ifTrue:[
- (receiver type == #ThisContext) ifTrue:[
+ (recType == #ThisContext) ifTrue:[
valueNeeded ifFalse:[
(selector == #return:) ifTrue:[
(argArray at:1) codeOn:aStream inBlock:b for:aCompiler. "^ value"
@@ -1217,25 +1228,33 @@
].
"no - generate a send"
- ((receiver type ~~ #Self)
- or:[nargs > 3]) ifTrue:[
- receiver codeOn:aStream inBlock:b for:aCompiler
- ].
- argArray notNil ifTrue:[
- argArray do:[:arg |
- arg codeOn:aStream inBlock:b for:aCompiler
- ]
+
+ receiver isSuper ifTrue:[
+ cls := aCompiler targetClass.
+ receiver isHere ifTrue:[
+ code := #hereSend.
+ ] ifFalse:[
+ code := #superSend.
+ cls := cls superclass.
+ ].
+ clsLitIndex := aCompiler addLiteral:cls.
+ ] ifFalse:[
+ clsLitIndex := 0.
].
- index := aCompiler addLiteral:selector.
- index <= 255 ifTrue:[
+ litIndex := aCompiler addLiteral:selector.
+ (litIndex <= 255 and:[clsLitIndex <= 255]) ifTrue:[
+ (recType ~~ #Self) ifTrue:[
+ receiver codeOn:aStream inBlock:b for:aCompiler
+ ].
+ argArray notNil ifTrue:[
+ argArray do:[:arg |
+ arg codeOn:aStream inBlock:b for:aCompiler
+ ]
+ ].
+
receiver isSuper ifTrue:[
- receiver isHere ifTrue:[
- code := #hereSend
- ] ifFalse:[
- code := #superSend.
- ].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs; nextPut:nil.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:clsLitIndex.
valueNeeded ifFalse:[
aStream nextPut:#drop
].
@@ -1258,45 +1277,71 @@
codes := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3)
]
].
- aStream nextPut:(codes at:nargs + 1); nextPut:lineNr; nextPut:index.
+ aStream nextPut:(codes at:(nargs + 1)); nextPut:lineNr; nextPut:litIndex.
^ self
].
- valueNeeded ifTrue:[
- code := #send
+ (recType == #Self) ifTrue:[
+ code := #sendSelf
] ifFalse:[
- code := #sendDrop
+ valueNeeded ifTrue:[
+ code := #send
+ ] ifFalse:[
+ code := #sendDrop
+ ]
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
+ valueNeeded ifFalse:[
+ (recType == #Self) ifTrue:[
+ aStream nextPut:#drop
+ ]
+ ].
^ self
].
"needs 16bit literal index"
+
receiver isSuper ifTrue:[
+ argArray notNil ifTrue:[
+ argArray do:[:arg |
+ arg codeOn:aStream inBlock:b for:aCompiler
+ ]
+ ].
receiver isHere ifTrue:[
code := #hereSendL
] ifFalse:[
code := #superSendL.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs; nextPut:nil.
- valueNeeded ifFalse:[
- aStream nextPut:#drop
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:clsLitIndex; nextPut:0.
+ ] ifFalse:[
+ recType ~~ #Self ifTrue:[
+ receiver codeOn:aStream inBlock:b for:aCompiler.
].
- ^ self
+ argArray notNil ifTrue:[
+ argArray do:[:arg |
+ arg codeOn:aStream inBlock:b for:aCompiler
+ ]
+ ].
+
+ recType == #Self ifTrue:[
+ code := #sendSelfL
+ ] ifFalse:[
+ code := #sendL
+ ].
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs.
].
- valueNeeded ifTrue:[
- code := #sendL
- ] ifFalse:[
- code := #sendDropL
+ valueNeeded ifFalse:[
+ aStream nextPut:#drop
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs
+
+ "Modified: 3.9.1995 / 12:55:42 / claus"
!
codeSendOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
"like code on, but assumes that receiver has already been
coded onto stack - needed for cascade"
- |nargs isBuiltIn code index|
+ |nargs isBuiltIn code litIndex|
argArray isNil ifTrue:[
nargs := 0
@@ -1343,21 +1388,21 @@
].
receiver isSuper ifTrue:[
- index := aCompiler addLiteral:selector.
- index <= 255 ifTrue:[
+ litIndex := aCompiler addLiteral:selector.
+ litIndex <= 255 ifTrue:[
receiver isHere ifTrue:[
code := #hereSend
] ifFalse:[
code := #superSend.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs; nextPut:nil.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:nil.
] ifFalse:[
receiver isHere ifTrue:[
code := #hereSendL
] ifFalse:[
code := #superSendL.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs; nextPut:nil.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:nil.
].
valueNeeded ifFalse:[
aStream nextPut:#drop
@@ -1376,15 +1421,15 @@
].
].
- index := aCompiler addLiteral:selector.
- index <= 255 ifTrue:[
+ litIndex := aCompiler addLiteral:selector.
+ litIndex <= 255 ifTrue:[
(nargs <= 3) ifTrue:[
valueNeeded ifTrue:[
code := #(send0 send1 send2 send3) at:(nargs+1).
] ifFalse:[
code := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3) at:(nargs+1).
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex.
^ self
].
@@ -1393,7 +1438,7 @@
] ifFalse:[
code := #sendDrop
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
^ self
].
@@ -1402,13 +1447,13 @@
] ifFalse:[
code := #sendDropL
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs
!
codeForCascadeOn:aStream inBlock:b for:aCompiler
"like codeOn, but always leave the receiver instead of the result"
- |nargs isBuiltIn code index|
+ |nargs isBuiltIn code litIndex|
argArray isNil ifTrue:[
nargs := 0
@@ -1455,24 +1500,24 @@
arg codeOn:aStream inBlock:b for:aCompiler
]
].
- index := aCompiler addLiteral:selector.
- index <= 255 ifTrue:[
+ litIndex := aCompiler addLiteral:selector.
+ litIndex <= 255 ifTrue:[
receiver isSuper ifTrue:[
receiver isHere ifTrue:[
code := #hereSend
] ifFalse:[
code := #superSend.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:nargs; nextPut:nil; nextPut:#drop.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:nil; nextPut:#drop.
^ self
].
(nargs <= 3) ifTrue:[
code := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3) at:(nargs+1).
- aStream nextPut:code; nextPut:lineNr; nextPut:index.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex.
^ self
].
- aStream nextPut:#sendDrop; nextPut:lineNr; nextPut:index; nextPut:nargs.
+ aStream nextPut:#sendDrop; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
^ self
].
"need 16bit litIndex"
@@ -1482,8 +1527,8 @@
] ifFalse:[
code := #superSendL.
].
- aStream nextPut:code; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs; nextPut:nil; nextPut:#drop.
+ aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:nil; nextPut:#drop.
^ self
].
- aStream nextPut:#sendDropL; nextPut:lineNr; nextPut:index; nextPut:0; nextPut:nargs
+ aStream nextPut:#sendDropL; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs
! !
--- a/Parser.st Wed Aug 30 20:26:53 1995 +0200
+++ b/Parser.st Thu Sep 07 14:07:16 1995 +0200
@@ -42,7 +42,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.49 1995-08-11 16:03:35 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.50 1995-09-07 12:06:55 claus Exp $
'!
!Parser class methodsFor:'documentation'!
@@ -63,7 +63,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.49 1995-08-11 16:03:35 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.50 1995-09-07 12:06:55 claus Exp $
"
!
@@ -1153,7 +1153,11 @@
!
targetClass:aClass
- classToCompileFor := aClass
+ classToCompileFor := aClass
+!
+
+targetClass
+ ^ classToCompileFor
! !
!Parser methodsFor:'error handling'!
@@ -3047,49 +3051,55 @@
ok := receiver evaluate respondsTo:sym.
err := ' will not be understood here'.
] ifFalse:[
- "
- if the receiver is a global, we check it too ...
- "
- receiver type == #GlobalVariable ifTrue:[
- "dont check autoloaded classes - it may work after
- loading"
-
- rec := receiver evaluate.
- (rec notNil
- and:[rec isBehavior
- and:[rec isLoaded not]]) ifTrue:[^ aSelectorString].
-
- ok := rec respondsTo:sym.
- err := ' may not be understood here'.
+ receiver isBlock ifTrue:[
+ "/ this should help with typos, sending #ifTrue to blocks ...
+ ok := [] respondsTo:sym.
+ err := ' will not be understood here'.
] ifFalse:[
- "if its a super send, we can do more checking"
- receiver isSuper ifTrue:[
- receiver isHere ifFalse:[
- ((superCls := classToCompileFor superclass) notNil
- and:[(superCls whichClassIncludesSelector:sym) isNil]) ifTrue:[
- err := ' is currently not implemented in any superclass'.
- ok := false
- ]
- ] ifTrue:[
- (classToCompileFor whichClassIncludesSelector:sym) isNil ifTrue:[
- err := ' is currently not implemented in this class'.
- ok := false
+ "
+ if the receiver is a global, we check it too ...
+ "
+ receiver type == #GlobalVariable ifTrue:[
+ "dont check autoloaded classes - it may work after
+ loading"
+
+ rec := receiver evaluate.
+ (rec notNil
+ and:[rec isBehavior
+ and:[rec isLoaded not]]) ifTrue:[^ aSelectorString].
+
+ ok := rec respondsTo:sym.
+ err := ' may not be understood here'.
+ ] ifFalse:[
+ "if its a super send, we can do more checking"
+ receiver isSuper ifTrue:[
+ receiver isHere ifFalse:[
+ ((superCls := classToCompileFor superclass) notNil
+ and:[(superCls whichClassIncludesSelector:sym) isNil]) ifTrue:[
+ err := ' is currently not implemented in any superclass'.
+ ok := false
+ ]
+ ] ifTrue:[
+ (classToCompileFor whichClassIncludesSelector:sym) isNil ifTrue:[
+ err := ' is currently not implemented in this class'.
+ ok := false
+ ]
]
- ]
- ].
-
- (receiver isUnaryMessage
- and:[receiver selector == #class
- and:[receiver receiver type == #Self]]) ifTrue:[
- "its a message to self class - can check this too ..."
- (classToCompileFor class whichClassIncludesSelector:sym) isNil ifTrue:[
- ok := false.
- classToCompileFor allSubclasses do:[:subclass |
- (subclass class implements:sym) ifTrue:[
- ok := true
- ]
- ].
- err := ' is currently not implemented in the class'.
+ ].
+
+ (receiver isUnaryMessage
+ and:[receiver selector == #class
+ and:[receiver receiver type == #Self]]) ifTrue:[
+ "its a message to self class - can check this too ..."
+ (classToCompileFor class whichClassIncludesSelector:sym) isNil ifTrue:[
+ ok := false.
+ classToCompileFor allSubclasses do:[:subclass |
+ (subclass class implements:sym) ifTrue:[
+ ok := true
+ ]
+ ].
+ err := ' is currently not implemented in the class'.
+ ]
]
]
]
@@ -3111,4 +3121,6 @@
"
].
^ aSelectorString
+
+ "Modified: 5.9.1995 / 17:02:11 / claus"
! !
--- a/VarNode.st Wed Aug 30 20:26:53 1995 +0200
+++ b/VarNode.st Thu Sep 07 14:07:16 1995 +0200
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Attic/VarNode.st,v 1.10 1995-08-13 20:52:47 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/VarNode.st,v 1.11 1995-09-07 12:07:16 claus Exp $
'!
!VariableNode class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Attic/VarNode.st,v 1.10 1995-08-13 20:52:47 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/VarNode.st,v 1.11 1995-09-07 12:07:16 claus Exp $
"
!
@@ -257,7 +257,7 @@
!
codeOn:aStream inBlock:codeBlock for:aCompiler
- |theCode b deltaLevel|
+ |theCode b deltaLevel litIndex|
(type == #MethodArg) ifTrue:[
(index <= 4) ifTrue:[
@@ -328,15 +328,27 @@
^ self
].
(type == #GlobalVariable) ifTrue:[
- aStream nextPut:#pushGlobal; nextPut:name.
+"/ aStream nextPut:#pushGlobal; nextPut:name.
+ litIndex := aCompiler addLiteral:name asSymbol.
+ litIndex < 256 ifTrue:[
+ aStream nextPut:#pushGlobalS; nextPut:litIndex
+ ] ifFalse:[
+ aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0
+ ].
"slot for generation and cell address (4 byte)"
- aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
+ aStream next:5 put:0.
^ self
].
(type == #ClassVariable) ifTrue:[
- aStream nextPut:#pushClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
+"/ aStream nextPut:#pushClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
+ litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
+ litIndex < 256 ifTrue:[
+ aStream nextPut:#pushClassVarS; nextPut:litIndex
+ ] ifFalse:[
+ aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0
+ ].
"slot for generation and cell address (4 byte)"
- aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
+ aStream next:5 put:0.
^ self
].
(type == #BlockVariable) ifTrue:[
@@ -371,7 +383,7 @@
!
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
- |theCode b deltaLevel|
+ |theCode b deltaLevel litIndex|
valueNeeded ifTrue:[
aStream nextPut:#dup
@@ -400,12 +412,6 @@
aStream nextPut:#storeInstVar; nextPut:index.
^ self
].
- (type == #GlobalVariable) ifTrue:[
- aStream nextPut:#storeGlobal; nextPut:name.
- "slot for generation and cell address (4 byte)"
- aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
- ^ self
- ].
(type == #BlockVariable) ifTrue:[
"find deltaLevel to block, where variable was defined"
b := codeBlock.
@@ -425,8 +431,26 @@
aStream nextPut:index.
^ self
].
+ (type == #GlobalVariable) ifTrue:[
+"/ aStream nextPut:#storeGlobal; nextPut:name.
+ litIndex := aCompiler addLiteral:name asSymbol.
+ litIndex < 256 ifTrue:[
+ aStream nextPut:#storeGlobalS; nextPut:litIndex
+ ] ifFalse:[
+ aStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0
+ ].
+ "slot for generation and cell address (4 byte)"
+ aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
+ ^ self
+ ].
(type == #ClassVariable) ifTrue:[
- aStream nextPut:#storeClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
+"/ aStream nextPut:#storeClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
+ litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
+ litIndex < 256 ifTrue:[
+ aStream nextPut:#storeClassVarS; nextPut:litIndex
+ ] ifFalse:[
+ aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0
+ ].
"slot for generation and cell address (4 byte)"
aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
^ self
--- a/VariableNode.st Wed Aug 30 20:26:53 1995 +0200
+++ b/VariableNode.st Thu Sep 07 14:07:16 1995 +0200
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.10 1995-08-13 20:52:47 claus Exp $
+$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.11 1995-09-07 12:07:16 claus Exp $
'!
!VariableNode class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.10 1995-08-13 20:52:47 claus Exp $
+$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.11 1995-09-07 12:07:16 claus Exp $
"
!
@@ -257,7 +257,7 @@
!
codeOn:aStream inBlock:codeBlock for:aCompiler
- |theCode b deltaLevel|
+ |theCode b deltaLevel litIndex|
(type == #MethodArg) ifTrue:[
(index <= 4) ifTrue:[
@@ -328,15 +328,27 @@
^ self
].
(type == #GlobalVariable) ifTrue:[
- aStream nextPut:#pushGlobal; nextPut:name.
+"/ aStream nextPut:#pushGlobal; nextPut:name.
+ litIndex := aCompiler addLiteral:name asSymbol.
+ litIndex < 256 ifTrue:[
+ aStream nextPut:#pushGlobalS; nextPut:litIndex
+ ] ifFalse:[
+ aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0
+ ].
"slot for generation and cell address (4 byte)"
- aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
+ aStream next:5 put:0.
^ self
].
(type == #ClassVariable) ifTrue:[
- aStream nextPut:#pushClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
+"/ aStream nextPut:#pushClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
+ litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
+ litIndex < 256 ifTrue:[
+ aStream nextPut:#pushClassVarS; nextPut:litIndex
+ ] ifFalse:[
+ aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0
+ ].
"slot for generation and cell address (4 byte)"
- aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
+ aStream next:5 put:0.
^ self
].
(type == #BlockVariable) ifTrue:[
@@ -371,7 +383,7 @@
!
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
- |theCode b deltaLevel|
+ |theCode b deltaLevel litIndex|
valueNeeded ifTrue:[
aStream nextPut:#dup
@@ -400,12 +412,6 @@
aStream nextPut:#storeInstVar; nextPut:index.
^ self
].
- (type == #GlobalVariable) ifTrue:[
- aStream nextPut:#storeGlobal; nextPut:name.
- "slot for generation and cell address (4 byte)"
- aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
- ^ self
- ].
(type == #BlockVariable) ifTrue:[
"find deltaLevel to block, where variable was defined"
b := codeBlock.
@@ -425,8 +431,26 @@
aStream nextPut:index.
^ self
].
+ (type == #GlobalVariable) ifTrue:[
+"/ aStream nextPut:#storeGlobal; nextPut:name.
+ litIndex := aCompiler addLiteral:name asSymbol.
+ litIndex < 256 ifTrue:[
+ aStream nextPut:#storeGlobalS; nextPut:litIndex
+ ] ifFalse:[
+ aStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0
+ ].
+ "slot for generation and cell address (4 byte)"
+ aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
+ ^ self
+ ].
(type == #ClassVariable) ifTrue:[
- aStream nextPut:#storeClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
+"/ aStream nextPut:#storeClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
+ litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
+ litIndex < 256 ifTrue:[
+ aStream nextPut:#storeClassVarS; nextPut:litIndex
+ ] ifFalse:[
+ aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0
+ ].
"slot for generation and cell address (4 byte)"
aStream nextPut:0; nextPut:0; nextPut:0; nextPut:0; nextPut:0.
^ self