2876 The argument, silent controls if errors are to be reported. |
2876 The argument, silent controls if errors are to be reported. |
2877 Returns the method, #Error or nil." |
2877 Returns the method, #Error or nil." |
2878 |
2878 |
2879 |newMethod tree symbolicCodeArray oldMethod silencio newSource primNr keptOldCode answer |
2879 |newMethod tree symbolicCodeArray oldMethod silencio newSource primNr keptOldCode answer |
2880 aClass sourceCodeString hasErrorInMethodHeader oldCategory newCategory oldPackage |
2880 aClass sourceCodeString hasErrorInMethodHeader oldCategory newCategory oldPackage |
2881 newPackage installSelector ns| |
2881 newPackage installSelector ns dialogText failureReason| |
2882 |
2882 |
2883 aClass := aClassArg. |
2883 aClass := aClassArg. |
2884 sourceCodeString := sourceCodeStringArg. |
2884 sourceCodeString := sourceCodeStringArg. |
2885 |
2885 |
2886 sourceCodeString isNil ifTrue:[^ nil]. |
2886 sourceCodeString isNil ifTrue:[^ nil]. |
3011 or:[(self hasPrimitiveCode and:[self class canCreateMachineCode]) |
3011 or:[(self hasPrimitiveCode and:[self class canCreateMachineCode]) |
3012 or:[ParserFlags stcCompilation == #always and:[selector ~~ #doIt]]]) |
3012 or:[ParserFlags stcCompilation == #always and:[selector ~~ #doIt]]]) |
3013 and:[(ParserFlags stcCompilation ~~ #never) |
3013 and:[(ParserFlags stcCompilation ~~ #never) |
3014 and:[NewPrimitives ~~ true]]) ifTrue:[ |
3014 and:[NewPrimitives ~~ true]]) ifTrue:[ |
3015 Parser::ParseError handle:[:ex | |
3015 Parser::ParseError handle:[:ex | |
3016 self parseError:(ex description) position:1. |
3016 ex lineNumber notNil ifTrue:[ |
|
3017 self parseError:(ex description) line:ex lineNumber. |
|
3018 ] ifFalse:[ |
|
3019 self parseError:(ex description) position:1. |
|
3020 ]. |
3017 newMethod := #Error. |
3021 newMethod := #Error. |
3018 ] do:[ |
3022 ] do:[ |
3019 newMethod := |
3023 newMethod := |
3020 (STCCompilerInterface new |
3024 (STCCompilerInterface new |
3021 originator:self; |
3025 originator:self; |
3030 silent:silent. |
3034 silent:silent. |
3031 ]. |
3035 ]. |
3032 |
3036 |
3033 newMethod == #Error ifTrue:[ |
3037 newMethod == #Error ifTrue:[ |
3034 self showErrorMessageForClass:aClass. |
3038 self showErrorMessageForClass:aClass. |
3035 ^ failBlock value |
3039 "/ ^ failBlock value |
3036 ]. |
3040 ]. |
3037 |
3041 |
3038 (newMethod == #CannotLoad) ifTrue:[ |
3042 (newMethod == #CannotLoad or:[newMethod == #Error]) ifTrue:[ |
|
3043 failureReason := newMethod. |
3039 newMethod := self trappingStubMethodFor:sourceCodeString inCategory:newCategory. |
3044 newMethod := self trappingStubMethodFor:sourceCodeString inCategory:newCategory. |
3040 newMethod setPackage:newPackage. |
3045 newMethod setPackage:newPackage. |
3041 keptOldCode := false. |
3046 keptOldCode := false. |
3042 install ifTrue:[ |
3047 install ifTrue:[ |
3043 "/ |
3048 "/ |
3044 "/ be very careful with existing methods |
3049 "/ be very careful with existing methods |
3045 "/ (otherwise, you could easily make your system unusable in systems which cannot load) |
3050 "/ (otherwise, you could easily make your system unusable in systems which cannot load) |
3046 "/ |
3051 "/ |
3047 (oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[ |
3052 (oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[ |
3048 answer := Dialog |
3053 failureReason == #Error ifTrue:[ |
3049 confirm: |
3054 dialogText := |
3050 'installation of binary code for ''' , aClass name , '>>' , selector , ''' |
3055 'STC-compilation of ''%1>>%2'' |
3051 is not possible or disabled. |
3056 to machine code failed . |
3052 |
3057 |
3053 Shall I use the old methods functionality |
3058 Shall I use the old methods functionality |
3054 or instead create a dummy trap method for it ? |
3059 or instead create a dummy trap method for it ? |
3055 |
3060 |
3056 Hint: |
3061 Hint: |
3057 if that method is needed by the system, you better leave the |
3062 if that method is needed by the system, you better leave the |
3058 original functionality in the system. |
3063 original functionality in the system. |
3059 |
3064 |
3060 Close this warnBox to abort the compilation. |
3065 Close this warnBox to abort the compilation. |
3061 ' |
3066 ' |
3062 yesLabel:'trap code' |
3067 ] ifFalse:[ |
3063 noLabel:'keep old'. |
3068 dialogText := |
|
3069 'installation of binary code for ''%1>>%2'' |
|
3070 is not possible or disabled. |
|
3071 |
|
3072 Shall I use the old methods functionality |
|
3073 or instead create a dummy trap method for it ? |
|
3074 |
|
3075 Hint: |
|
3076 if that method is needed by the system, you better leave the |
|
3077 original functionality in the system. |
|
3078 |
|
3079 Close this warnBox to abort the compilation. |
|
3080 ' |
|
3081 ]. |
|
3082 answer := Dialog |
|
3083 confirmWithCancel:(dialogText bindWith:aClass name with:selector) |
|
3084 labels:#('cancel' 'keep old' 'trap code') |
|
3085 default:2. |
3064 answer isNil ifTrue:[ |
3086 answer isNil ifTrue:[ |
3065 ^ failBlock value |
3087 ^ failBlock value |
3066 ]. |
3088 ]. |
3067 answer == false ifTrue:[ |
3089 answer == false ifTrue:[ |
3068 newMethod code:(oldMethod code). |
3090 newMethod code:(oldMethod code). |