BCompiler.st
changeset 117 3736a828cb50
parent 111 c94471645c21
child 118 c9f4955e6cfd
--- 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'!