code cleanup & comments
authorClaus Gittinger <cg@exept.de>
Wed, 04 Jun 1997 12:37:27 +0200
changeset 530 1736f549e86d
parent 529 039322479f26
child 531 1d037c37e5a2
code cleanup & comments
BCompiler.st
ByteCodeCompiler.st
--- a/BCompiler.st	Wed May 28 17:11:03 1997 +0200
+++ b/BCompiler.st	Wed Jun 04 12:37:27 1997 +0200
@@ -1915,23 +1915,23 @@
     "return true, if selector sel is built-in.
      (i.e. there is a single bytecode for it)"
 
-    (sel == #at:) ifTrue:[^ true].
-    (sel == #value:) ifTrue:[^ true].
+    (sel == #at:)     ifTrue:[^ true].
+    (sel == #value:)  ifTrue:[^ true].
     (sel == #bitAnd:) ifTrue:[^ true].
-    (sel == #bitOr:) ifTrue:[^ true].
-    (sel == #new:) ifTrue:[^ true].
+    (sel == #bitOr:)  ifTrue:[^ true].
+    (sel == #new:)    ifTrue:[^ true].
     (sel == #basicNew:) ifTrue:[
-	"/ this one is critical - some redefine it
-	receiver isGlobal ifTrue:[
-	    (#('String' 'ByteArray' 'Array'
-	      'Point' 'Rectangle' 'Object')
-	    includes:receiver name) ifTrue:[^ true].
-	].
+        "/ this one is critical - some redefine it
+        receiver isGlobal ifTrue:[
+            (#('String' 'ByteArray' 'Array'
+              'Point' 'Rectangle' 'Object')
+            includes:receiver name) ifTrue:[^ true].
+        ].
     ].
     ^ false
 
     "Created: 17.4.1996 / 22:33:13 / cg"
-    "Modified: 17.4.1996 / 22:38:08 / cg"
+    "Modified: 4.6.1997 / 12:24:18 / cg"
 !
 
 isBuiltIn2ArgSelector:sel forReceiver:receiver
@@ -1945,70 +1945,52 @@
 !
 
 isBuiltInBinarySelector:sel forReceiver:receiver
+    "return true, if binary selector sel is built-in. 
+     (i.e. there is a single bytecode for it)"
+
     sel == #== ifTrue:[^ true].
     sel == #~~ ifTrue:[^ true].
-    sel == #= ifTrue:[^ true].
+    sel == #=  ifTrue:[^ true].
     sel == #~= ifTrue:[^ true].
-    sel == #+ ifTrue:[^ true].
-    sel == #- ifTrue:[^ true].
-    sel == #< ifTrue:[^ true].
+    sel == #+  ifTrue:[^ true].
+    sel == #-  ifTrue:[^ true].
+    sel == #<  ifTrue:[^ true].
     sel == #<= ifTrue:[^ true].
-    sel == #> ifTrue:[^ true].
+    sel == #>  ifTrue:[^ true].
     sel == #>= ifTrue:[^ true].
-    sel == #* ifTrue:[^ true].
-    sel == #& ifTrue:[^ true].
-    sel == #| ifTrue:[^ true].
+    sel == #*  ifTrue:[^ true].
+    sel == #&  ifTrue:[^ true].
+    sel == #|  ifTrue:[^ true].
     ^ false
 
     "Created: 17.4.1996 / 22:34:27 / cg"
+    "Modified: 4.6.1997 / 12:24:00 / cg"
 !
 
 isBuiltInUnarySelector:sel forReceiver:receiver
     "return true, if unary selector sel is built-in. 
      (i.e. there is a single bytecode for it)"
 
-    (sel == #value) ifTrue:[^ true].
-    (sel == #class) ifTrue:[^ true].
-    (sel == #size) ifTrue:[^ true].
-    (sel == #isNil) ifTrue:[^ true].
+    (sel == #value)  ifTrue:[^ true].
+    (sel == #class)  ifTrue:[^ true].
+    (sel == #size)   ifTrue:[^ true].
+    (sel == #isNil)  ifTrue:[^ true].
     (sel == #notNil) ifTrue:[^ true].
-    (sel == #not) ifTrue:[^ true].
-
-    (sel == #new) ifTrue:[^ true].
+    (sel == #not)    ifTrue:[^ true].
+
+    (sel == #new)    ifTrue:[^ true].
     (sel == #basicNew) ifTrue:[
-	"/ this one is critical - some redefine it
-	receiver isGlobal ifTrue:[
-	    (#('String' 'ByteArray' 'Array'
-	      'Point' 'Rectangle' 'Object')
-	    includes:receiver name) ifTrue:[^ true].
-	].
+        "/ this one is critical - some redefine it
+        receiver isGlobal ifTrue:[
+            (#('String' 'ByteArray' 'Array'
+               'Point' 'Rectangle' 'Object')
+            includes:receiver name) ifTrue:[^ true].
+        ].
     ].
     ^ false
 
     "Created: 17.4.1996 / 22:32:16 / cg"
-    "Modified: 17.4.1996 / 22:38:14 / cg"
-!
-
-isSpecialGlobalSymbol:nm
-    "return true, if unary selector sel is a special selector"
-
-    ^ #(Array String FloatArray DoubleArray
-	Point Symbol Smalltalk Processor
-	SmallInteger Character Float 
-	Process 
-	Set IdentitySet Dictionary IdentityDictionary 
-	Sempahore 
-	OrderedCollection 
-       ) includesIdentical:nm
-
-    "Created: 13.4.1996 / 20:15:35 / cg"
-    "Modified: 5.8.1996 / 16:56:58 / cg"
-!
-
-isSpecialSendSelector:sel
-    "return true, if unary selector sel is a special selector"
-
-    ^ (self specialSendCodeFor:sel) notNil
+    "Modified: 4.6.1997 / 12:23:30 / cg"
 !
 
 moveGlobalsToFront
@@ -2221,49 +2203,83 @@
 !
 
 specialGlobalCodeFor:aSymbol
-    aSymbol == #Array ifTrue:[^ 0].
-    aSymbol == #String ifTrue:[^ 1].
-    aSymbol == #FloatArray ifTrue:[^ 2].
-    aSymbol == #DoubleArray ifTrue:[^ 3].
-    aSymbol == #Point ifTrue:[^ 4].
-    aSymbol == #Symbol ifTrue:[^ 5].
-    aSymbol == #Smalltalk ifTrue:[^ 6].
-    aSymbol == #Processor ifTrue:[^ 7].
-    aSymbol == #SmallInteger ifTrue:[^ 8].
-    aSymbol == #Character ifTrue:[^ 9].
-    aSymbol == #Float ifTrue:[^ 10].
-    aSymbol == #Process ifTrue:[^ 11].
-    aSymbol == #Set ifTrue:[^ 12].
-    aSymbol == #IdentitySet ifTrue:[^ 13].
-    aSymbol == #Dictionary ifTrue:[^ 14].
-    aSymbol == #IdentityDictionary ifTrue:[^ 15].
-    aSymbol == #Sempahore ifTrue:[^ 16].
-    aSymbol == #OrderedCollection ifTrue:[^ 17].
-
-    self error:'invalid special global symbol'.
-    errorFlag := #Error
-
-    "Modified: 5.8.1996 / 16:51:45 / cg"
+    "codeExtension for globals,
+     which can be accessed by specialGlobal opCode"
+
+    |idx|
+
+    idx := self specialGlobals identityIndexOf:aSymbol ifAbsent:nil.
+    idx isNil ifTrue:[^ idx].
+    ^ idx - 1.
+
+    "Modified: 4.6.1997 / 12:31:22 / cg"
+!
+
+specialGlobals
+    "list of globals which can be accessed by specialGlobal opCode; 
+     adding any here requires a new VM (i.e. you cannot change it)"
+
+    ^ #(
+        #Array                  "/ 0
+        #String                 "/ 1
+        #FloatArray             "/ 2
+        #DoubleArray            "/ 3
+        #Point                  "/ 4
+        #Symbol                 "/ 5
+        #Smalltalk              "/ 6
+        #Processor              "/ 7
+        #SmallInteger           "/ 8
+        #Character              "/ 9
+        #Float                  "/ 10
+        #Process                "/ 11
+        #Set                    "/ 12
+        #IdentitySet            "/ 13
+        #Dictionary             "/ 14
+        #IdentityDictionary     "/ 15
+        #Sempahore              "/ 16
+        #OrderedCollection      "/ 17
+       )
+
+    "Created: 4.6.1997 / 12:17:47 / cg"
+    "Modified: 4.6.1997 / 12:31:35 / cg"
 !
 
 specialSendCodeFor:sel
-    sel == #top    ifTrue:[^ 0].
-    sel == #bottom ifTrue:[^ 1].
-    sel == #left   ifTrue:[^ 2].
-    sel == #right  ifTrue:[^ 3].
-
-    sel == #x      ifTrue:[^ 4].
-    sel == #y      ifTrue:[^ 5].
-    sel == #width  ifTrue:[^ 6].
-    sel == #height ifTrue:[^ 7].
-    sel == #origin ifTrue:[^ 8].
-    sel == #extent ifTrue:[^ 9].
-    sel == #asInteger ifTrue:[^ 10].
-    sel == #rounded   ifTrue:[^ 11].
-    sel == #next   ifTrue:[^ 12].
-    sel == #peek   ifTrue:[^ 13].
-
-    ^ nil
+    "return the codeExtension for sends,
+     which can be performed by specialSend opCode"
+
+    |idx|
+
+    idx := self specialSends identityIndexOf:sel ifAbsent:nil.
+    idx isNil ifTrue:[^ idx].
+    ^ idx - 1.
+
+    "Modified: 4.6.1997 / 12:31:08 / cg"
+!
+
+specialSends
+    "list of selectors which can be sent by specialSend opCode; 
+     adding any here requires a new VM (i.e. you cannot change it)"
+
+    ^ #(
+        #top                    "/ 0
+        #bottom                 "/ 1
+        #left                   "/ 2
+        #right                  "/ 3
+        #x                      "/ 4
+        #y                      "/ 5
+        #width                  "/ 6
+        #height                 "/ 7
+        #origin                 "/ 8
+        #extent                 "/ 9
+        #asInteger              "/ 10
+        #rounded                "/ 11
+        #next                   "/ 12
+        #peek                   "/ 13
+       )
+
+    "Created: 4.6.1997 / 12:20:28 / cg"
+    "Modified: 4.6.1997 / 12:31:56 / cg"
 ! !
 
 !ByteCodeCompiler methodsFor:'machine code generation'!
@@ -2753,6 +2769,6 @@
 !ByteCodeCompiler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.113 1997-04-20 10:20:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.114 1997-06-04 10:37:27 cg Exp $'
 ! !
 ByteCodeCompiler initialize!
--- a/ByteCodeCompiler.st	Wed May 28 17:11:03 1997 +0200
+++ b/ByteCodeCompiler.st	Wed Jun 04 12:37:27 1997 +0200
@@ -1915,23 +1915,23 @@
     "return true, if selector sel is built-in.
      (i.e. there is a single bytecode for it)"
 
-    (sel == #at:) ifTrue:[^ true].
-    (sel == #value:) ifTrue:[^ true].
+    (sel == #at:)     ifTrue:[^ true].
+    (sel == #value:)  ifTrue:[^ true].
     (sel == #bitAnd:) ifTrue:[^ true].
-    (sel == #bitOr:) ifTrue:[^ true].
-    (sel == #new:) ifTrue:[^ true].
+    (sel == #bitOr:)  ifTrue:[^ true].
+    (sel == #new:)    ifTrue:[^ true].
     (sel == #basicNew:) ifTrue:[
-	"/ this one is critical - some redefine it
-	receiver isGlobal ifTrue:[
-	    (#('String' 'ByteArray' 'Array'
-	      'Point' 'Rectangle' 'Object')
-	    includes:receiver name) ifTrue:[^ true].
-	].
+        "/ this one is critical - some redefine it
+        receiver isGlobal ifTrue:[
+            (#('String' 'ByteArray' 'Array'
+              'Point' 'Rectangle' 'Object')
+            includes:receiver name) ifTrue:[^ true].
+        ].
     ].
     ^ false
 
     "Created: 17.4.1996 / 22:33:13 / cg"
-    "Modified: 17.4.1996 / 22:38:08 / cg"
+    "Modified: 4.6.1997 / 12:24:18 / cg"
 !
 
 isBuiltIn2ArgSelector:sel forReceiver:receiver
@@ -1945,70 +1945,52 @@
 !
 
 isBuiltInBinarySelector:sel forReceiver:receiver
+    "return true, if binary selector sel is built-in. 
+     (i.e. there is a single bytecode for it)"
+
     sel == #== ifTrue:[^ true].
     sel == #~~ ifTrue:[^ true].
-    sel == #= ifTrue:[^ true].
+    sel == #=  ifTrue:[^ true].
     sel == #~= ifTrue:[^ true].
-    sel == #+ ifTrue:[^ true].
-    sel == #- ifTrue:[^ true].
-    sel == #< ifTrue:[^ true].
+    sel == #+  ifTrue:[^ true].
+    sel == #-  ifTrue:[^ true].
+    sel == #<  ifTrue:[^ true].
     sel == #<= ifTrue:[^ true].
-    sel == #> ifTrue:[^ true].
+    sel == #>  ifTrue:[^ true].
     sel == #>= ifTrue:[^ true].
-    sel == #* ifTrue:[^ true].
-    sel == #& ifTrue:[^ true].
-    sel == #| ifTrue:[^ true].
+    sel == #*  ifTrue:[^ true].
+    sel == #&  ifTrue:[^ true].
+    sel == #|  ifTrue:[^ true].
     ^ false
 
     "Created: 17.4.1996 / 22:34:27 / cg"
+    "Modified: 4.6.1997 / 12:24:00 / cg"
 !
 
 isBuiltInUnarySelector:sel forReceiver:receiver
     "return true, if unary selector sel is built-in. 
      (i.e. there is a single bytecode for it)"
 
-    (sel == #value) ifTrue:[^ true].
-    (sel == #class) ifTrue:[^ true].
-    (sel == #size) ifTrue:[^ true].
-    (sel == #isNil) ifTrue:[^ true].
+    (sel == #value)  ifTrue:[^ true].
+    (sel == #class)  ifTrue:[^ true].
+    (sel == #size)   ifTrue:[^ true].
+    (sel == #isNil)  ifTrue:[^ true].
     (sel == #notNil) ifTrue:[^ true].
-    (sel == #not) ifTrue:[^ true].
-
-    (sel == #new) ifTrue:[^ true].
+    (sel == #not)    ifTrue:[^ true].
+
+    (sel == #new)    ifTrue:[^ true].
     (sel == #basicNew) ifTrue:[
-	"/ this one is critical - some redefine it
-	receiver isGlobal ifTrue:[
-	    (#('String' 'ByteArray' 'Array'
-	      'Point' 'Rectangle' 'Object')
-	    includes:receiver name) ifTrue:[^ true].
-	].
+        "/ this one is critical - some redefine it
+        receiver isGlobal ifTrue:[
+            (#('String' 'ByteArray' 'Array'
+               'Point' 'Rectangle' 'Object')
+            includes:receiver name) ifTrue:[^ true].
+        ].
     ].
     ^ false
 
     "Created: 17.4.1996 / 22:32:16 / cg"
-    "Modified: 17.4.1996 / 22:38:14 / cg"
-!
-
-isSpecialGlobalSymbol:nm
-    "return true, if unary selector sel is a special selector"
-
-    ^ #(Array String FloatArray DoubleArray
-	Point Symbol Smalltalk Processor
-	SmallInteger Character Float 
-	Process 
-	Set IdentitySet Dictionary IdentityDictionary 
-	Sempahore 
-	OrderedCollection 
-       ) includesIdentical:nm
-
-    "Created: 13.4.1996 / 20:15:35 / cg"
-    "Modified: 5.8.1996 / 16:56:58 / cg"
-!
-
-isSpecialSendSelector:sel
-    "return true, if unary selector sel is a special selector"
-
-    ^ (self specialSendCodeFor:sel) notNil
+    "Modified: 4.6.1997 / 12:23:30 / cg"
 !
 
 moveGlobalsToFront
@@ -2221,49 +2203,83 @@
 !
 
 specialGlobalCodeFor:aSymbol
-    aSymbol == #Array ifTrue:[^ 0].
-    aSymbol == #String ifTrue:[^ 1].
-    aSymbol == #FloatArray ifTrue:[^ 2].
-    aSymbol == #DoubleArray ifTrue:[^ 3].
-    aSymbol == #Point ifTrue:[^ 4].
-    aSymbol == #Symbol ifTrue:[^ 5].
-    aSymbol == #Smalltalk ifTrue:[^ 6].
-    aSymbol == #Processor ifTrue:[^ 7].
-    aSymbol == #SmallInteger ifTrue:[^ 8].
-    aSymbol == #Character ifTrue:[^ 9].
-    aSymbol == #Float ifTrue:[^ 10].
-    aSymbol == #Process ifTrue:[^ 11].
-    aSymbol == #Set ifTrue:[^ 12].
-    aSymbol == #IdentitySet ifTrue:[^ 13].
-    aSymbol == #Dictionary ifTrue:[^ 14].
-    aSymbol == #IdentityDictionary ifTrue:[^ 15].
-    aSymbol == #Sempahore ifTrue:[^ 16].
-    aSymbol == #OrderedCollection ifTrue:[^ 17].
-
-    self error:'invalid special global symbol'.
-    errorFlag := #Error
-
-    "Modified: 5.8.1996 / 16:51:45 / cg"
+    "codeExtension for globals,
+     which can be accessed by specialGlobal opCode"
+
+    |idx|
+
+    idx := self specialGlobals identityIndexOf:aSymbol ifAbsent:nil.
+    idx isNil ifTrue:[^ idx].
+    ^ idx - 1.
+
+    "Modified: 4.6.1997 / 12:31:22 / cg"
+!
+
+specialGlobals
+    "list of globals which can be accessed by specialGlobal opCode; 
+     adding any here requires a new VM (i.e. you cannot change it)"
+
+    ^ #(
+        #Array                  "/ 0
+        #String                 "/ 1
+        #FloatArray             "/ 2
+        #DoubleArray            "/ 3
+        #Point                  "/ 4
+        #Symbol                 "/ 5
+        #Smalltalk              "/ 6
+        #Processor              "/ 7
+        #SmallInteger           "/ 8
+        #Character              "/ 9
+        #Float                  "/ 10
+        #Process                "/ 11
+        #Set                    "/ 12
+        #IdentitySet            "/ 13
+        #Dictionary             "/ 14
+        #IdentityDictionary     "/ 15
+        #Sempahore              "/ 16
+        #OrderedCollection      "/ 17
+       )
+
+    "Created: 4.6.1997 / 12:17:47 / cg"
+    "Modified: 4.6.1997 / 12:31:35 / cg"
 !
 
 specialSendCodeFor:sel
-    sel == #top    ifTrue:[^ 0].
-    sel == #bottom ifTrue:[^ 1].
-    sel == #left   ifTrue:[^ 2].
-    sel == #right  ifTrue:[^ 3].
-
-    sel == #x      ifTrue:[^ 4].
-    sel == #y      ifTrue:[^ 5].
-    sel == #width  ifTrue:[^ 6].
-    sel == #height ifTrue:[^ 7].
-    sel == #origin ifTrue:[^ 8].
-    sel == #extent ifTrue:[^ 9].
-    sel == #asInteger ifTrue:[^ 10].
-    sel == #rounded   ifTrue:[^ 11].
-    sel == #next   ifTrue:[^ 12].
-    sel == #peek   ifTrue:[^ 13].
-
-    ^ nil
+    "return the codeExtension for sends,
+     which can be performed by specialSend opCode"
+
+    |idx|
+
+    idx := self specialSends identityIndexOf:sel ifAbsent:nil.
+    idx isNil ifTrue:[^ idx].
+    ^ idx - 1.
+
+    "Modified: 4.6.1997 / 12:31:08 / cg"
+!
+
+specialSends
+    "list of selectors which can be sent by specialSend opCode; 
+     adding any here requires a new VM (i.e. you cannot change it)"
+
+    ^ #(
+        #top                    "/ 0
+        #bottom                 "/ 1
+        #left                   "/ 2
+        #right                  "/ 3
+        #x                      "/ 4
+        #y                      "/ 5
+        #width                  "/ 6
+        #height                 "/ 7
+        #origin                 "/ 8
+        #extent                 "/ 9
+        #asInteger              "/ 10
+        #rounded                "/ 11
+        #next                   "/ 12
+        #peek                   "/ 13
+       )
+
+    "Created: 4.6.1997 / 12:20:28 / cg"
+    "Modified: 4.6.1997 / 12:31:56 / cg"
 ! !
 
 !ByteCodeCompiler methodsFor:'machine code generation'!
@@ -2753,6 +2769,6 @@
 !ByteCodeCompiler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.113 1997-04-20 10:20:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.114 1997-06-04 10:37:27 cg Exp $'
 ! !
 ByteCodeCompiler initialize!