--- a/ByteCodeCompiler.st Mon Aug 07 13:00:44 2006 +0200
+++ b/ByteCodeCompiler.st Mon Aug 07 13:01:07 2006 +0200
@@ -2221,11 +2221,17 @@
self startCodeGenerationHookOn:codeStream.
self generateVariables:methodVars on:codeStream.
- thisStatement := tree.
- [thisStatement notNil] whileTrue:[
- lastStatement := thisStatement.
- thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self.
- thisStatement := thisStatement nextStatement
+ (tree isKindOf:MethodNode) ifTrue:[
+ "kludge for VW compat."
+ tree codeForSideEffectOn:codeStream inBlock:nil for:self.
+ lastStatement := tree statements last.
+ ] ifFalse:[
+ thisStatement := tree.
+ [thisStatement notNil] whileTrue:[
+ lastStatement := thisStatement.
+ thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self.
+ thisStatement := thisStatement nextStatement
+ ].
].
(lastStatement isNil or:[lastStatement isReturnNode not])
@@ -2248,7 +2254,8 @@
].
^ codeStream contents
- "Modified: 15.8.1996 / 17:35:02 / stefan"
+ "Modified: / 15-08-1996 / 17:35:02 / stefan"
+ "Modified: / 06-08-2006 / 15:03:14 / cg"
!
generateVariables:varCollection on:codeStream
@@ -2698,7 +2705,7 @@
The argument, silent controls if errors are to be reported.
Returns the method, #Error or nil."
- |newMethod tree symbolicCodeArray oldMethod lazy silencio
+ |newMethod tree symbolicCodeArray oldMethod silencio
sourceFile sourceStream newSource primNr pos keptOldCode answer
aClass sourceCodeString hasErrorInMethodHeader oldCategory newCategory oldPackage newPackage|
@@ -2710,11 +2717,6 @@
or:[Smalltalk silentLoading == true
or:[ListCompiledMethods == false]].
- "lazy compilation is EXPERIMENTAL"
- lazy := (LazyCompilation == true) and:[install].
- "/ no longer ...
- lazy := false.
-
RestartCompilationSignal handle:[:ex |
"/ class could have changed ...
aClass := self classToCompileFor.
@@ -2789,53 +2791,34 @@
newCategory := oldCategory ? '* As yet uncategorized *'.
].
- lazy ifTrue:[
- "/
- "/ that one method IS required
- "/
- (aClass isMeta and:[selector == #version]) ifTrue:[
- lazy := false
- ].
- "/
- "/ primitives also
- "/
- (self hasNonOptionalPrimitiveCode
- or:[self hasPrimitiveCode and:[self class canCreateMachineCode]])
- ifTrue:[
- lazy := false
- ].
- ].
-
- lazy ifFalse:[
- "check if same source"
- (skipIfSame and:[oldMethod notNil and:[oldMethod source = sourceCodeString]]) ifTrue:[
- oldMethod isInvalid ifFalse:[
+ "check if same source"
+ (skipIfSame and:[oldMethod notNil and:[oldMethod source = sourceCodeString]]) ifTrue:[
+ oldMethod isInvalid ifFalse:[
+ silencio ifFalse:[
+ Transcript showCR:(' unchanged: ',aClass name,' ',selector)
+ ].
+ "
+ same. however, category may be different
+ "
+ (newCategory ~= oldCategory) ifTrue:[
+ oldMethod category:newCategory.
+"/ aClass updateRevisionString.
+ aClass addChangeRecordForMethodCategory:oldMethod category:newCategory.
silencio ifFalse:[
- Transcript showCR:(' unchanged: ',aClass name,' ',selector)
+ Transcript showCR:(' (category change only)')
].
- "
- same. however, category may be different
- "
- (newCategory ~= oldCategory) ifTrue:[
- oldMethod category:newCategory.
-"/ aClass updateRevisionString.
- aClass addChangeRecordForMethodCategory:oldMethod category:newCategory.
- silencio ifFalse:[
- Transcript showCR:(' (category change only)')
- ].
+ ].
+ "
+ and package may be too.
+ "
+ (newPackage notNil and:[newPackage ~~ oldPackage]) ifTrue:[
+ oldMethod package:newPackage.
+ silencio ifFalse:[
+ Transcript showCR:(' (package-id change only)')
].
- "
- and package may be too.
- "
- (newPackage notNil and:[newPackage ~~ oldPackage]) ifTrue:[
- oldMethod package:newPackage.
- silencio ifFalse:[
- Transcript showCR:(' (package-id change only)')
- ].
- ].
- ^ oldMethod
- ]
- ].
+ ].
+ ^ oldMethod
+ ]
].
(self errorFlag or:[tree == #Error]) ifTrue:[
@@ -2938,35 +2921,6 @@
].
].
- "
- EXPERIMENTAL: quick loading
- only create a lazyMethod, which has no byteCode and will
- compile itself when first called.
- "
- lazy ifTrue:[
- newMethod := LazyMethod new.
- (ClassCategoryReader sourceMode == #sourceReference) ifTrue:[
- sourceFile := ObjectMemory nameForSources.
- sourceFile notNil ifTrue:[
- sourceStream := sourceFile asFilename appendingWriteStream.
- ]
- ].
- sourceStream isNil ifTrue:[
- newMethod source:sourceCodeString string.
- ] ifFalse:[
- sourceStream setToEnd.
- pos := sourceStream position1Based.
- sourceStream nextChunkPut:sourceCodeString.
- sourceStream close.
- newMethod sourceFilename:sourceFile position:pos.
- ].
- newMethod setCategory:newCategory.
- newMethod setPackage:newPackage.
- newMethod numberOfArgs:selector numArgs.
- aClass addSelector:selector withLazyMethod:newMethod.
- ^ newMethod
- ].
-
primNr := self primitiveNumber.
(NewPrimitives or:[primNr isNil]) ifTrue:[
"
@@ -3037,9 +2991,9 @@
^ newMethod
- "Created: / 29.10.1995 / 19:59:36 / cg"
- "Modified: / 19.3.1999 / 08:31:09 / stefan"
- "Modified: / 17.11.2001 / 21:27:08 / cg"
+ "Created: / 29-10-1995 / 19:59:36 / cg"
+ "Modified: / 19-03-1999 / 08:31:09 / stefan"
+ "Modified: / 03-08-2006 / 15:35:45 / cg"
!
compile:methodText forClass:aBehavior install:doInstall
@@ -3062,6 +3016,73 @@
"Created: / 17-07-2006 / 18:44:53 / cg"
!
+compileTree:aTree forClass:aClassArg
+ |newMethod symbolicCodeArray oldMethod silencio
+ sourceFile sourceStream newSource primNr pos keptOldCode answer
+ aClass sourceCodeString hasErrorInMethodHeader oldCategory newCategory oldPackage newPackage|
+
+ aClass := aClassArg.
+
+ self tree:aTree.
+
+ newMethod := self createMethod.
+ newMethod byteCode:(self code).
+
+ (self contextMustBeReturnable) ifTrue:[
+ newMethod contextMustBeReturnable:true
+ ].
+
+ ^ newMethod
+
+ "Modified: / 19-03-1999 / 08:31:09 / stefan"
+ "Created: / 06-08-2006 / 03:25:39 / cg"
+!
+
+compileTree:aMethodNode forClass:aClassArg ifFail:failBlock
+ |newMethod symbolicCodeArray aClass prev|
+
+ aClass := aClassArg.
+
+ self tree:aMethodNode.
+
+ selector := aMethodNode selector.
+ methodArgs := aMethodNode arguments ? #().
+ methodArgNames := methodArgs collect:[:eachVar | eachVar name].
+ methodVars := aMethodNode locals ? #().
+ methodVarNames := methodVars collect:[:eachVar | eachVar name].
+
+ "
+ produce symbolic code first
+ "
+ symbolicCodeArray := self genSymbolicCode.
+ (symbolicCodeArray == #Error) ifTrue:[
+ self showErrorNotification:'translation error'.
+ ^ failBlock value
+ ].
+
+ "
+ take this, producing bytecode
+ (someone willin' to make machine code :-)
+ "
+ ((self genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[
+ self showErrorNotification:'relocation error - code must be simplified'.
+ ^ failBlock value
+ ].
+
+ newMethod := self createMethod.
+ newMethod byteCode:(self code).
+
+ (self contextMustBeReturnable) ifTrue:[
+ newMethod contextMustBeReturnable:true
+ ].
+
+ ^ newMethod
+
+ "Modified: / 19-03-1999 / 08:31:09 / stefan"
+ "Created: / 06-08-2006 / 03:26:27 / cg"
+ "Modified: / 06-08-2006 / 15:14:26 / cg"
+!
+
showErrorNotification:message
Transcript show:'***'.
selector notNil ifTrue:[
@@ -3282,7 +3303,7 @@
!ByteCodeCompiler class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.237 2006-07-17 16:44:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.238 2006-08-07 11:01:07 cg Exp $'
! !
ByteCodeCompiler initialize!