ByteCodeCompiler.st
changeset 3681 4db107dbec8a
parent 3661 c16edf592f5d
child 3682 7225237d33a0
child 3709 e9d10d99ef0d
equal deleted inserted replaced
3679:c76366470cc9 3681:4db107dbec8a
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
   429 						except if you plan to modify the byteCodes.
   427 						except if you plan to modify the byteCodes.
   430 
   428 
   431     [author:]
   429     [author:]
   432 	Claus Gittinger
   430 	Claus Gittinger
   433 
   431 
       
   432 "
       
   433 !
       
   434 
       
   435 examples
       
   436 "
       
   437     a GNU-Smalltalk method:                                                                    
       
   438                                                                         [exBegin]
       
   439     Compiler 
       
   440         compile:'bla
       
   441     <category: ''tests''>
       
   442 
       
   443     ^ 123
       
   444 '
       
   445         forClass: Object
       
   446                                                                         [exEnd]
   434 "
   447 "
   435 ! !
   448 ! !
   436 
   449 
   437 !ByteCodeCompiler class methodsFor:'initialization'!
   450 !ByteCodeCompiler class methodsFor:'initialization'!
   438 
   451 
  3017      The argument, silent controls if errors are to be reported.
  3030      The argument, silent controls if errors are to be reported.
  3018      Returns the method, #Error or nil."
  3031      Returns the method, #Error or nil."
  3019 
  3032 
  3020     |newMethod tree symbolicCodeArray oldMethod silencio newSource primNr keptOldCode answer
  3033     |newMethod tree symbolicCodeArray oldMethod silencio newSource primNr keptOldCode answer
  3021      aClass sourceCodeString hasErrorInMethodHeader oldCategory newCategory oldPackage 
  3034      aClass sourceCodeString hasErrorInMethodHeader oldCategory newCategory oldPackage 
  3022      newPackage installSelector ns dialogText failureReason|
  3035      newPackage installSelector ns dialogText failureReason annotationCategory|
  3023 
  3036 
  3024     aClass := aClassArg.
  3037     aClass := aClassArg.
  3025     sourceCodeString := sourceCodeStringArg.
  3038     sourceCodeString := sourceCodeStringArg.
  3026 
  3039 
  3027     sourceCodeString isNil ifTrue:[^ nil].
  3040     sourceCodeString isNil ifTrue:[^ nil].
  3319     (newSource includes:Character return) ifTrue:[
  3332     (newSource includes:Character return) ifTrue:[
  3320         "/ see if it contains crlf's or only cr's
  3333         "/ see if it contains crlf's or only cr's
  3321         newSource := self class stringWithSimpleCRs:newSource
  3334         newSource := self class stringWithSimpleCRs:newSource
  3322     ].
  3335     ].
  3323     newMethod source:newSource string.
  3336     newMethod source:newSource string.
       
  3337     (newMethod hasAnnotation: #'category:') ifTrue:[
       
  3338         annotationCategory := (newMethod annotationAt:#'category:') argumentAt:1.
       
  3339         annotationCategory isString ifTrue:[
       
  3340             newCategory := annotationCategory
       
  3341         ].
       
  3342     ].
  3324     newMethod setCategory:newCategory.
  3343     newMethod setCategory:newCategory.
  3325     newMethod setPackage:newPackage.
  3344     newMethod setPackage:newPackage.
  3326 
  3345 
  3327     (self contextMustBeReturnable) ifTrue:[
  3346     (self contextMustBeReturnable) ifTrue:[
  3328         newMethod contextMustBeReturnable:true
  3347         newMethod contextMustBeReturnable:true