ソースを参照

Fixed Environment >> moveMethod:toClass:

Nicolas Petton 11 年 前
コミット
ec4b15f268
3 ファイル変更14 行追加11 行削除
  1. 4 4
      js/Kernel-Objects.deploy.js
  2. 5 5
      js/Kernel-Objects.js
  3. 5 2
      st/Kernel-Objects.st

+ 4 - 4
js/Kernel-Objects.deploy.js

@@ -1742,10 +1742,10 @@ if(smalltalk.assert($2)){
 $3=self;
 return $3;
 };
-_st(destinationClass)._adoptMethod_(aMethod);
-_st(_st(aMethod)._methodClass())._forsakeMethod_(aMethod);
-return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName,destinationClass:destinationClass},smalltalk.HLEnvironment)})},
-messageSends: ["at:", "asSymbol", "current", "ifNil:", "error:", "ifTrue:", "==", "methodClass", "adoptMethod:", "forsakeMethod:"]}),
+_st(destinationClass)._compile_category_(_st(aMethod)._source(),_st(aMethod)._protocol());
+_st(_st(aMethod)._methodClass())._removeCompiledMethod_(aMethod);
+return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName,destinationClass:destinationClass},smalltalk.Environment)})},
+messageSends: ["at:", "asSymbol", "current", "ifNil:", "error:", "ifTrue:", "==", "methodClass", "compile:category:", "source", "protocol", "removeCompiledMethod:"]}),
 smalltalk.Environment);
 
 smalltalk.addMethod(

+ 5 - 5
js/Kernel-Objects.js

@@ -2407,12 +2407,12 @@ if(smalltalk.assert($2)){
 $3=self;
 return $3;
 };
-_st(destinationClass)._adoptMethod_(aMethod);
-_st(_st(aMethod)._methodClass())._forsakeMethod_(aMethod);
-return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName,destinationClass:destinationClass},smalltalk.HLEnvironment)})},
+_st(destinationClass)._compile_category_(_st(aMethod)._source(),_st(aMethod)._protocol());
+_st(_st(aMethod)._methodClass())._removeCompiledMethod_(aMethod);
+return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName,destinationClass:destinationClass},smalltalk.Environment)})},
 args: ["aMethod", "aClassName"],
-source: "moveMethod: aMethod toClass: aClassName\x0a\x09| destinationClass |\x0a\x09\x0a\x09destinationClass := Smalltalk current at: aClassName asSymbol.\x0a\x09destinationClass ifNil: [ self error: 'Invalid class name' ].\x0a\x09destinationClass == aMethod methodClass ifTrue: [ ^ self ].\x0a\x09\x0a\x09destinationClass adoptMethod: aMethod.\x0a\x09aMethod methodClass forsakeMethod: aMethod.\x0a\x09",
-messageSends: ["at:", "asSymbol", "current", "ifNil:", "error:", "ifTrue:", "==", "methodClass", "adoptMethod:", "forsakeMethod:"],
+source: "moveMethod: aMethod toClass: aClassName\x0a\x09| destinationClass |\x0a\x09\x0a\x09destinationClass := Smalltalk current at: aClassName asSymbol.\x0a\x09destinationClass ifNil: [ self error: 'Invalid class name' ].\x0a\x09destinationClass == aMethod methodClass ifTrue: [ ^ self ].\x0a\x09\x0a\x09destinationClass \x0a\x09\x09compile: aMethod source\x0a\x09\x09category: aMethod protocol.\x0a\x09aMethod methodClass \x0a\x09\x09removeCompiledMethod: aMethod\x0a\x09",
+messageSends: ["at:", "asSymbol", "current", "ifNil:", "error:", "ifTrue:", "==", "methodClass", "compile:category:", "source", "protocol", "removeCompiledMethod:"],
 referencedClasses: ["Smalltalk"]
 }),
 smalltalk.Environment);

+ 5 - 2
st/Kernel-Objects.st

@@ -740,8 +740,11 @@ moveMethod: aMethod toClass: aClassName
 	destinationClass ifNil: [ self error: 'Invalid class name' ].
 	destinationClass == aMethod methodClass ifTrue: [ ^ self ].
 	
-	destinationClass adoptMethod: aMethod.
-	aMethod methodClass forsakeMethod: aMethod.
+	destinationClass 
+		compile: aMethod source
+		category: aMethod protocol.
+	aMethod methodClass 
+		removeCompiledMethod: aMethod
 !
 
 moveMethod: aMethod toProtocol: aProtocol