.
--- a/BCompiler.st Mon Oct 23 17:58:15 1995 +0100
+++ b/BCompiler.st Tue Oct 24 16:55:13 1995 +0100
@@ -27,7 +27,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.42 1995-10-23 16:57:48 cg Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.43 1995-10-24 15:54:48 cg Exp $
'!
!ByteCodeCompiler class methodsFor:'documentation'!
@@ -48,7 +48,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.42 1995-10-23 16:57:48 cg Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.43 1995-10-24 15:54:48 cg Exp $
"
!
@@ -304,8 +304,9 @@
"
freak-out support ...
"
- (compiler hasPrimitiveCode
- or:[STCCompilation == #always and:[sel ~~ #doIt]]) ifTrue:[
+ (compiler hasNonOptionalPrimitiveCode
+ or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode])
+ or:[STCCompilation == #always and:[sel ~~ #doIt]]]) ifTrue:[
newMethod := compiler
compileToMachineCode:aString
forClass:aClass
@@ -558,13 +559,7 @@
((f := '../../stc' asFilename construct:command)) isExecutable ifTrue:[
^ f pathName
].
- ((OperatingSystem getEnvironment:'PATH')
- asCollectionOfSubstringsSeparatedBy:$:) do:[:path |
- (f := (path asFilename construct:command)) isExecutable ifTrue:[
- ^ f pathName
- ].
- ].
- ^ nil
+ ^ OperatingSystem pathOfCommand:command
"
Compiler stcPathOf:'stc'
--- a/ByteCodeCompiler.st Mon Oct 23 17:58:15 1995 +0100
+++ b/ByteCodeCompiler.st Tue Oct 24 16:55:13 1995 +0100
@@ -27,7 +27,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.42 1995-10-23 16:57:48 cg Exp $
+$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.43 1995-10-24 15:54:48 cg Exp $
'!
!ByteCodeCompiler class methodsFor:'documentation'!
@@ -48,7 +48,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.42 1995-10-23 16:57:48 cg Exp $
+$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.43 1995-10-24 15:54:48 cg Exp $
"
!
@@ -304,8 +304,9 @@
"
freak-out support ...
"
- (compiler hasPrimitiveCode
- or:[STCCompilation == #always and:[sel ~~ #doIt]]) ifTrue:[
+ (compiler hasNonOptionalPrimitiveCode
+ or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode])
+ or:[STCCompilation == #always and:[sel ~~ #doIt]]]) ifTrue:[
newMethod := compiler
compileToMachineCode:aString
forClass:aClass
@@ -558,13 +559,7 @@
((f := '../../stc' asFilename construct:command)) isExecutable ifTrue:[
^ f pathName
].
- ((OperatingSystem getEnvironment:'PATH')
- asCollectionOfSubstringsSeparatedBy:$:) do:[:path |
- (f := (path asFilename construct:command)) isExecutable ifTrue:[
- ^ f pathName
- ].
- ].
- ^ nil
+ ^ OperatingSystem pathOfCommand:command
"
Compiler stcPathOf:'stc'
--- a/LazyMethod.st Mon Oct 23 17:58:15 1995 +0100
+++ b/LazyMethod.st Tue Oct 24 16:55:13 1995 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/LazyMethod.st,v 1.13 1995-08-11 16:03:08 claus Exp $
+$Header: /cvs/stx/stx/libcomp/LazyMethod.st,v 1.14 1995-10-24 15:54:57 cg Exp $
'!
!LazyMethod class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/LazyMethod.st,v 1.13 1995-08-11 16:03:08 claus Exp $
+$Header: /cvs/stx/stx/libcomp/LazyMethod.st,v 1.14 1995-10-24 15:54:57 cg Exp $
"
!
@@ -106,11 +106,11 @@
"
[
Access critical:[
- m := self asByteCodeMethod.
+ m := self asExecutableMethod.
].
] valueUninterruptably.
- (m isNil or:[(byteCode := m byteCode) isNil]) ifTrue:[
+ (m isNil or:[(byteCode := m byteCode) isNil and:[m code isNil]]) ifTrue:[
"
compilation failed
"
@@ -118,8 +118,12 @@
].
literals := m literals.
flags := m flags.
+ self code:(m code).
self changeClassToThatOf:m.
^ self
+
+ "Created: 24.10.1995 / 14:02:50 / cg"
+ "Modified: 24.10.1995 / 15:35:50 / cg"
! !
!LazyMethod methodsFor:'error handling'!
--- a/Parser.st Mon Oct 23 17:58:15 1995 +0100
+++ b/Parser.st Tue Oct 24 16:55:13 1995 +0100
@@ -26,7 +26,7 @@
localVarDefPosition
evalExitBlock
selfNode superNode
- hasPrimitiveCode primitiveNr primitiveResource
+ hasPrimitiveCode hasNonOptionalPrimitiveCode primitiveNr primitiveResource
logged
warnedUndefVars warnSTXHereExtensionUsed
correctedSource'
@@ -42,7 +42,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.51 1995-09-14 23:30:59 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.52 1995-10-24 15:55:09 cg Exp $
'!
!Parser class methodsFor:'documentation'!
@@ -63,7 +63,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.51 1995-09-14 23:30:59 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.52 1995-10-24 15:55:09 cg Exp $
"
!
@@ -142,6 +142,9 @@
superNode <Node> cached one-and-only 'super' node
hasPrimitiveCode <Boolean> true, if it contains ST/X style primitive code
+ hasNonOptionalPrimitiveCode
+ <Boolean> true, if it contains ST/X style primitive code
+ which is NOT flagged by the OPTIONAL directive.
primitiveNr <Integer> the parsed ST-80 type primitive number (or nil)
@@ -931,7 +934,7 @@
initialize
super initialize.
- hasPrimitiveCode := false.
+ hasPrimitiveCode := hasNonOptionalPrimitiveCode := false.
warnSTXHereExtensionUsed := WarnSTXSpecials.
usesSuper := false.
parseForCode := false.
@@ -1059,6 +1062,12 @@
^ hasPrimitiveCode
!
+hasNonOptionalPrimitiveCode
+ "return true if there was any ST/X style primitive code (valid after parsing)"
+
+ ^ hasNonOptionalPrimitiveCode
+!
+
instVarNames
"caching allInstVarNames for next compilation saves time ..."
@@ -1660,8 +1669,12 @@
].
(tokenType == #Primitive) ifTrue:[
self nextToken.
+ node := PrimitiveNode code:tokenValue.
+ node isOptional ifFalse:[
+ hasNonOptionalPrimitiveCode := true
+ ].
hasPrimitiveCode := true.
- ^ PrimitiveNode code:''
+ ^ node
].
(tokenType == #EOF) ifTrue:[
self syntaxError:'period after last statement'.
--- a/PrimNd.st Mon Oct 23 17:58:15 1995 +0100
+++ b/PrimNd.st Tue Oct 24 16:55:13 1995 +0100
@@ -11,7 +11,7 @@
"
StatementNode subclass:#PrimitiveNode
- instanceVariableNames:'code primNumber'
+ instanceVariableNames:'code primNumber optional'
classVariableNames:''
poolDictionaries:''
category:'System-Compiler-Support'
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Attic/PrimNd.st,v 1.9 1995-08-11 20:28:14 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/PrimNd.st,v 1.10 1995-10-24 15:55:13 cg Exp $
'!
!PrimitiveNode class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Attic/PrimNd.st,v 1.9 1995-08-11 20:28:14 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/PrimNd.st,v 1.10 1995-10-24 15:55:13 cg Exp $
"
!
@@ -50,14 +50,19 @@
"
node for parse-trees, representing primitive code
- Primitives are currently not supported by the compiler
+ Primitives are (currently) not always supported by the incremental compiler
- if you want a primitive, you must use the stc-compiler and
link a new smalltalk.
- In the future, methods with primitives will be passed to stc and
- the resulting binary be loaded into the image (also a limited set
- of numeric primitives could be implemented for more ST-80
- compatibility - if there is a need).
+ On system which support dynamic object loading, methods with primitives are passed
+ to stc and the resulting binary is loaded into the image
+ (also a limited set of numeric primitives could be implemented for more ST-80
+ compatibility - if there is a need).
+
+ To allow autoloaded/filedIn code to be written for best performance, an optional
+ primitive directive (in the primitives first lines comment) may specify an
+ optional primitive; these are compiled on systems which do support binary code
+ loading, and ignored completely on others.
"
! !
@@ -75,15 +80,36 @@
isConstant
^ false
+!
+
+isOptional
+ ^ optional
! !
!PrimitiveNode methodsFor:'accessing'!
code:aString
- code := aString
+ "set the primitives code - check for the 'OPTIONAL' directive"
+
+ |firstLine commentPos words|
+
+ code := aString.
+ optional := false.
+
+ firstLine := aString readStream nextLine.
+ commentPos := firstLine indexOfSubCollection:'/*'.
+ commentPos ~~ 0 ifTrue:[
+ words := (firstLine copyFrom:(commentPos + 2)) asCollectionOfWords.
+ (words includes:'OPTIONAL') ifTrue:[
+ optional := true
+ ]
+ ]
+
+ "Modified: 24.10.1995 / 11:29:51 / cg"
!
primitiveNumber:anInteger
+ optional := false.
primNumber := anInteger
! !
@@ -92,12 +118,14 @@
evaluateExpression
"catch evaluation"
+ optional ifTrue:[^ nil].
self error:'cannot evaluate primitives'
!
evaluate
"catch evaluation"
+ optional ifTrue:[^ nil].
self error:'cannot evaluate primitives'
! !
@@ -106,11 +134,13 @@
codeForSideEffectOn:aStream inBlock:b for:aCompiler
"catch code generation"
+ optional ifTrue:[^ self].
self error:'cannot compile primitives (as yet)'
!
codeOn:aStream inBlock:b for:aCompiler
"catch code generation"
+ optional ifTrue:[^ self].
self error:'cannot compile primitives (as yet)'
! !
--- a/PrimitiveNode.st Mon Oct 23 17:58:15 1995 +0100
+++ b/PrimitiveNode.st Tue Oct 24 16:55:13 1995 +0100
@@ -11,7 +11,7 @@
"
StatementNode subclass:#PrimitiveNode
- instanceVariableNames:'code primNumber'
+ instanceVariableNames:'code primNumber optional'
classVariableNames:''
poolDictionaries:''
category:'System-Compiler-Support'
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/PrimitiveNode.st,v 1.9 1995-08-11 20:28:14 claus Exp $
+$Header: /cvs/stx/stx/libcomp/PrimitiveNode.st,v 1.10 1995-10-24 15:55:13 cg Exp $
'!
!PrimitiveNode class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/PrimitiveNode.st,v 1.9 1995-08-11 20:28:14 claus Exp $
+$Header: /cvs/stx/stx/libcomp/PrimitiveNode.st,v 1.10 1995-10-24 15:55:13 cg Exp $
"
!
@@ -50,14 +50,19 @@
"
node for parse-trees, representing primitive code
- Primitives are currently not supported by the compiler
+ Primitives are (currently) not always supported by the incremental compiler
- if you want a primitive, you must use the stc-compiler and
link a new smalltalk.
- In the future, methods with primitives will be passed to stc and
- the resulting binary be loaded into the image (also a limited set
- of numeric primitives could be implemented for more ST-80
- compatibility - if there is a need).
+ On system which support dynamic object loading, methods with primitives are passed
+ to stc and the resulting binary is loaded into the image
+ (also a limited set of numeric primitives could be implemented for more ST-80
+ compatibility - if there is a need).
+
+ To allow autoloaded/filedIn code to be written for best performance, an optional
+ primitive directive (in the primitives first lines comment) may specify an
+ optional primitive; these are compiled on systems which do support binary code
+ loading, and ignored completely on others.
"
! !
@@ -75,15 +80,36 @@
isConstant
^ false
+!
+
+isOptional
+ ^ optional
! !
!PrimitiveNode methodsFor:'accessing'!
code:aString
- code := aString
+ "set the primitives code - check for the 'OPTIONAL' directive"
+
+ |firstLine commentPos words|
+
+ code := aString.
+ optional := false.
+
+ firstLine := aString readStream nextLine.
+ commentPos := firstLine indexOfSubCollection:'/*'.
+ commentPos ~~ 0 ifTrue:[
+ words := (firstLine copyFrom:(commentPos + 2)) asCollectionOfWords.
+ (words includes:'OPTIONAL') ifTrue:[
+ optional := true
+ ]
+ ]
+
+ "Modified: 24.10.1995 / 11:29:51 / cg"
!
primitiveNumber:anInteger
+ optional := false.
primNumber := anInteger
! !
@@ -92,12 +118,14 @@
evaluateExpression
"catch evaluation"
+ optional ifTrue:[^ nil].
self error:'cannot evaluate primitives'
!
evaluate
"catch evaluation"
+ optional ifTrue:[^ nil].
self error:'cannot evaluate primitives'
! !
@@ -106,11 +134,13 @@
codeForSideEffectOn:aStream inBlock:b for:aCompiler
"catch code generation"
+ optional ifTrue:[^ self].
self error:'cannot compile primitives (as yet)'
!
codeOn:aStream inBlock:b for:aCompiler
"catch code generation"
+ optional ifTrue:[^ self].
self error:'cannot compile primitives (as yet)'
! !