ByteCodeCompiler.st
changeset 1046 8e5818442eb9
parent 1031 a6c0c0b7d355
child 1047 d0b95ceaffe3
equal deleted inserted replaced
1045:ee448a958d19 1046:8e5818442eb9
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
       
    13 "{ Package: 'stx:libcomp' }"
       
    14 
    13 Parser subclass:#ByteCodeCompiler
    15 Parser subclass:#ByteCodeCompiler
    14 	instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno extraLiteral
    16 	instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno extraLiteral
    15 		maxStackDepth relocList methodTempVars numTemp maxNumTemp'
    17 		maxStackDepth relocList methodTempVars numTemp maxNumTemp'
    16 	classVariableNames:'JumpToAbsJump SequenceNumber STCCompilationDefines
    18 	classVariableNames:'JumpToAbsJump SequenceNumber STCCompilationDefines
    17 		STCCompilationIncludes STCCompilationOptions STCCompilation
    19 		STCCompilationIncludes STCCompilationOptions STCCompilation
    18 		ShareCode STCKeepSTIntermediate STCKeepCIntermediate
    20 		ShareCode STCKeepSTIntermediate STCKeepCIntermediate
    19 		STCModulePath CCCompilationOptions CC STC ListCompiledMethods
    21 		STCModulePath CCCompilationOptions CC STC ListCompiledMethods
    20 		STCKeepOIntermediate Verbose'
    22 		STCKeepOIntermediate Verbose NewCodeSet'
    21 	poolDictionaries:''
    23 	poolDictionaries:''
    22 	category:'System-Compiler'
    24 	category:'System-Compiler'
    23 !
    25 !
    24 
    26 
    25 !ByteCodeCompiler class methodsFor:'documentation'!
    27 !ByteCodeCompiler class methodsFor:'documentation'!
   434 ! !
   436 ! !
   435 
   437 
   436 !ByteCodeCompiler class methodsFor:'initialization'!
   438 !ByteCodeCompiler class methodsFor:'initialization'!
   437 
   439 
   438 initialize
   440 initialize
       
   441     NewCodeSet := false.
   439     ShareCode := true.
   442     ShareCode := true.
   440     STCKeepCIntermediate := false.
   443     STCKeepCIntermediate := false.
   441     STCKeepOIntermediate := false.
   444     STCKeepOIntermediate := false.
   442     STCKeepSTIntermediate := false.
   445     STCKeepSTIntermediate := false.
   443     STCModulePath := './modules'.
   446     STCModulePath := './modules'.
   448     STCKeepOIntermediate := true.
   451     STCKeepOIntermediate := true.
   449     STCKeepSTIntermediate := true.
   452     STCKeepSTIntermediate := true.
   450    "
   453    "
   451 
   454 
   452     "Modified: / 21.10.1998 / 15:39:52 / cg"
   455     "Modified: / 21.10.1998 / 15:39:52 / cg"
       
   456 !
       
   457 
       
   458 newCodeSet
       
   459     ^ NewCodeSet 
       
   460 
       
   461 !
       
   462 
       
   463 newCodeSet:aBoolean
       
   464     NewCodeSet := aBoolean.
       
   465 
       
   466     "
       
   467      ByteCodeCompiler newCodeSet:true
       
   468     "
   453 ! !
   469 ! !
   454 
   470 
   455 !ByteCodeCompiler class methodsFor:'compiling methods'!
   471 !ByteCodeCompiler class methodsFor:'compiling methods'!
   456 
   472 
   457 compile:methodText forClass:classToCompileFor
   473 compile:methodText forClass:classToCompileFor
   681          freak-out support for inline C-code...
   697          freak-out support for inline C-code...
   682         "
   698         "
   683         ((compiler hasNonOptionalPrimitiveCode 
   699         ((compiler hasNonOptionalPrimitiveCode 
   684         or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode])
   700         or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode])
   685         or:[STCCompilation == #always and:[sel ~~ #doIt]]])
   701         or:[STCCompilation == #always and:[sel ~~ #doIt]]])
   686         and:[STCCompilation ~~ #never]) ifTrue:[
   702         and:[(STCCompilation ~~ #never)
       
   703         and:[NewCodeSet ~~ true]]) ifTrue:[
   687             newMethod := compiler 
   704             newMethod := compiler 
   688                             compileToMachineCode:aString 
   705                             compileToMachineCode:aString 
   689                             forClass:aClass 
   706                             forClass:aClass 
   690                             inCategory:cat 
   707                             inCategory:cat 
   691                             notifying:requestor
   708                             notifying:requestor
   752             ^ newMethod
   769             ^ newMethod
   753         ].
   770         ].
   754     ].
   771     ].
   755 
   772 
   756     compiler hasNonOptionalPrimitiveCode ifTrue:[
   773     compiler hasNonOptionalPrimitiveCode ifTrue:[
   757         newMethod := compiler trappingStubMethodFor:aString inCategory:cat.
   774         "/
   758         install ifTrue:[
   775         "/ generate a trapping method, if primitive code is present
   759             aClass addSelector:sel withMethod:newMethod.
   776         "/
   760         ].
   777         NewCodeSet ~~ true ifTrue:[
   761         Transcript show:'*** '.
   778             newMethod := compiler trappingStubMethodFor:aString inCategory:cat.
   762         sel notNil ifTrue:[
   779             install ifTrue:[
   763             Transcript show:(sel ,' ')
   780                 aClass addSelector:sel withMethod:newMethod.
   764         ].
   781             ].
   765         Transcript showCR:'not compiled to machine code - created a stub instead.'.
   782             Transcript show:'*** '.
   766         ^ newMethod
   783             sel notNil ifTrue:[
       
   784                 Transcript show:(sel ,' ')
       
   785             ].
       
   786             Transcript showCR:'not compiled to machine code - created a stub instead.'.
       
   787             ^ newMethod
       
   788         ].
   767     ].
   789     ].
   768 
   790 
   769     "
   791     "
   770      EXPERIMENTAL: quick loading
   792      EXPERIMENTAL: quick loading
   771      only create a lazyMethod, which has no byteCode and will 
   793      only create a lazyMethod, which has no byteCode and will 
  3643 ! !
  3665 ! !
  3644 
  3666 
  3645 !ByteCodeCompiler class methodsFor:'documentation'!
  3667 !ByteCodeCompiler class methodsFor:'documentation'!
  3646 
  3668 
  3647 version
  3669 version
  3648     ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.164 2000-02-05 13:35:26 cg Exp $'
  3670     ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.165 2000-06-19 12:02:38 cg Exp $'
  3649 ! !
  3671 ! !
  3650 ByteCodeCompiler initialize!
  3672 ByteCodeCompiler initialize!