3060 ]. |
3060 ]. |
3061 |
3061 |
3062 " |
3062 " |
3063 freak-out support for inline C-code... |
3063 freak-out support for inline C-code... |
3064 " |
3064 " |
3065 ((self hasNonOptionalPrimitiveCode |
3065 NewPrimitives ifFalse:[ |
3066 or:[(self hasPrimitiveCode and:[self class canCreateMachineCode]) |
3066 ((self hasNonOptionalPrimitiveCode |
3067 or:[ParserFlags stcCompilation == #always and:[selector ~~ #doIt]]]) |
3067 or:[(self hasPrimitiveCode and:[self class canCreateMachineCode]) |
3068 and:[(ParserFlags stcCompilation ~~ #never) |
3068 or:[ParserFlags stcCompilation == #always and:[selector ~~ #doIt]]]) |
3069 and:[NewPrimitives ~~ true]]) ifTrue:[ |
3069 and:[(ParserFlags stcCompilation ~~ #never)]) ifTrue:[ |
3070 Parser::ParseError handle:[:ex | |
3070 Parser::ParseError handle:[:ex | |
3071 ex lineNumber notNil ifTrue:[ |
3071 ex lineNumber notNil ifTrue:[ |
3072 self parseError:(ex description) line:ex lineNumber. |
3072 self parseError:(ex description) line:ex lineNumber. |
3073 ] ifFalse:[ |
3073 ] ifFalse:[ |
3074 self parseError:(ex description) position:1. |
3074 self parseError:(ex description) position:1. |
|
3075 ]. |
|
3076 newMethod := #Error. |
|
3077 ] do:[ |
|
3078 newMethod := |
|
3079 (STCCompilerInterface new |
|
3080 originator:self; |
|
3081 parserFlags:parserFlags) |
|
3082 compileToMachineCode:sourceCodeString |
|
3083 forClass:aClass |
|
3084 selector:selector |
|
3085 inCategory:cat |
|
3086 notifying:aRequestor |
|
3087 install:install |
|
3088 skipIfSame:skipIfSame |
|
3089 silent:silent. |
3075 ]. |
3090 ]. |
3076 newMethod := #Error. |
3091 |
3077 ] do:[ |
3092 newMethod == #Error ifTrue:[ |
3078 newMethod := |
3093 self showErrorMessageForClass:aClass. |
3079 (STCCompilerInterface new |
3094 "/^ failBlock value |
3080 originator:self; |
3095 ]. |
3081 parserFlags:parserFlags) |
3096 |
3082 compileToMachineCode:sourceCodeString |
3097 (newMethod == #CannotLoad or:[newMethod == #Error]) ifTrue:[ |
3083 forClass:aClass |
3098 failureReason := newMethod. |
3084 selector:selector |
3099 newMethod := self trappingStubMethodFor:sourceCodeString inCategory:newCategory. |
3085 inCategory:cat |
3100 newMethod setPackage:newPackage. |
3086 notifying:aRequestor |
3101 keptOldCode := false. |
3087 install:install |
3102 install ifTrue:[ |
3088 skipIfSame:skipIfSame |
3103 "/ |
3089 silent:silent. |
3104 "/ be very careful with existing methods |
3090 ]. |
3105 "/ (otherwise, you could easily make your system unusable in systems which cannot load) |
3091 |
3106 "/ |
3092 newMethod == #Error ifTrue:[ |
3107 (oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[ |
3093 self showErrorMessageForClass:aClass. |
3108 failureReason == #Error ifTrue:[ |
3094 "/ ^ failBlock value |
3109 dialogText := |
3095 ]. |
|
3096 |
|
3097 (newMethod == #CannotLoad or:[newMethod == #Error]) ifTrue:[ |
|
3098 failureReason := newMethod. |
|
3099 newMethod := self trappingStubMethodFor:sourceCodeString inCategory:newCategory. |
|
3100 newMethod setPackage:newPackage. |
|
3101 keptOldCode := false. |
|
3102 install ifTrue:[ |
|
3103 "/ |
|
3104 "/ be very careful with existing methods |
|
3105 "/ (otherwise, you could easily make your system unusable in systems which cannot load) |
|
3106 "/ |
|
3107 (oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[ |
|
3108 failureReason == #Error ifTrue:[ |
|
3109 dialogText := |
|
3110 'STC-compilation of ''%1>>%2'' |
3110 'STC-compilation of ''%1>>%2'' |
3111 to machine code failed . |
3111 to machine code failed . |
3112 |
3112 |
3113 Shall I use the old methods functionality |
3113 Shall I use the old methods functionality |
3114 or instead create a dummy trap method for it ? |
3114 or instead create a dummy trap method for it ? |
3117 if that method is needed by the system, you better leave the |
3117 if that method is needed by the system, you better leave the |
3118 original functionality in the system. |
3118 original functionality in the system. |
3119 |
3119 |
3120 Close this warnBox to abort the compilation. |
3120 Close this warnBox to abort the compilation. |
3121 ' |
3121 ' |
3122 ] ifFalse:[ |
3122 ] ifFalse:[ |
3123 dialogText := |
3123 dialogText := |
3124 'installation of binary code for ''%1>>%2'' |
3124 'installation of binary code for ''%1>>%2'' |
3125 is not possible or disabled. |
3125 is not possible or disabled. |
3126 |
3126 |
3127 Shall I use the old methods functionality |
3127 Shall I use the old methods functionality |
3128 or instead create a dummy trap method for it ? |
3128 or instead create a dummy trap method for it ? |
3131 if that method is needed by the system, you better leave the |
3131 if that method is needed by the system, you better leave the |
3132 original functionality in the system. |
3132 original functionality in the system. |
3133 |
3133 |
3134 Close this warnBox to abort the compilation. |
3134 Close this warnBox to abort the compilation. |
3135 ' |
3135 ' |
|
3136 ]. |
|
3137 answer := Dialog |
|
3138 confirmWithCancel:(dialogText bindWith:aClass name with:selector) |
|
3139 labels:#('cancel' 'keep old' 'trap code') |
|
3140 default:2. |
|
3141 answer isNil ifTrue:[ |
|
3142 ^ failBlock value |
|
3143 ]. |
|
3144 answer == false ifTrue:[ |
|
3145 newMethod code:(oldMethod code). |
|
3146 keptOldCode := true. |
|
3147 ]. |
3136 ]. |
3148 ]. |
3137 answer := Dialog |
3149 aClass addSelector:selector withMethod:newMethod |
3138 confirmWithCancel:(dialogText bindWith:aClass name with:selector) |
|
3139 labels:#('cancel' 'keep old' 'trap code') |
|
3140 default:2. |
|
3141 answer isNil ifTrue:[ |
|
3142 ^ failBlock value |
|
3143 ]. |
|
3144 answer == false ifTrue:[ |
|
3145 newMethod code:(oldMethod code). |
|
3146 keptOldCode := true. |
|
3147 ]. |
|
3148 ]. |
3150 ]. |
3149 aClass addSelector:selector withMethod:newMethod |
3151 self showErrorNotification:(keptOldCode |
|
3152 ifTrue:['not really compiled - method still shows previous behavior'] |
|
3153 ifFalse:['not compiled to machine code - created a stub instead.']) |
3150 ]. |
3154 ]. |
3151 self showErrorNotification:(keptOldCode |
3155 ^ newMethod |
3152 ifTrue:['not really compiled - method still shows previous behavior'] |
|
3153 ifFalse:['not compiled to machine code - created a stub instead.']) |
|
3154 ]. |
3156 ]. |
3155 ^ newMethod |
3157 |
3156 ]. |
3158 self hasNonOptionalPrimitiveCode ifTrue:[ |
3157 |
3159 "/ |
3158 self hasNonOptionalPrimitiveCode ifTrue:[ |
3160 "/ generate a trapping method, if primitive code is present |
3159 "/ |
3161 "/ |
3160 "/ generate a trapping method, if primitive code is present |
|
3161 "/ |
|
3162 NewPrimitives ifFalse:[ |
|
3163 newMethod := self trappingStubMethodFor:sourceCodeString inCategory:newCategory. |
3162 newMethod := self trappingStubMethodFor:sourceCodeString inCategory:newCategory. |
3164 install ifTrue:[ |
3163 install ifTrue:[ |
|
3164 self showErrorNotification:'not compiled to machine code - installed a stub instead.'. |
3165 aClass addSelector:selector withMethod:newMethod. |
3165 aClass addSelector:selector withMethod:newMethod. |
3166 ]. |
3166 ]. |
3167 self showErrorNotification:'not compiled to machine code - created a stub instead.'. |
|
3168 ^ newMethod |
3167 ^ newMethod |
3169 ]. |
3168 ]. |
3170 ]. |
3169 ]. |
3171 |
3170 |
3172 primNr := self primitiveNumber. |
3171 primNr := self primitiveNumber. |
3341 "Created: / 06-08-2006 / 03:26:27 / cg" |
3340 "Created: / 06-08-2006 / 03:26:27 / cg" |
3342 "Modified: / 06-08-2006 / 15:14:26 / cg" |
3341 "Modified: / 06-08-2006 / 15:14:26 / cg" |
3343 ! |
3342 ! |
3344 |
3343 |
3345 showErrorNotification:message |
3344 showErrorNotification:message |
3346 Transcript show:'***'. |
3345 Transcript show:'***'. |
3347 selector notNil ifTrue:[ |
3346 selector notNil ifTrue:[ |
3348 Transcript show:(selector ,' ') |
3347 Transcript show:(selector ,' ') |
3349 ]. |
3348 ]. |
3350 Transcript showCR:message. |
3349 Transcript showCR:message. |
3351 ! ! |
3350 ! ! |
3352 |
3351 |
3353 !ByteCodeCompiler methodsFor:'machine code generation'! |
3352 !ByteCodeCompiler methodsFor:'machine code generation'! |
3354 |
3353 |
3355 trappingStubMethodFor:aString inCategory:cat |
3354 trappingStubMethodFor:aString inCategory:cat |