Browse Source

Behavior>>compile: and Behavior>>compile:category: methods

Nicolas Petton 13 years ago
parent
commit
fa793126d9
3 changed files with 102 additions and 0 deletions
  1. 36 0
      js/Kernel.deploy.js
  2. 48 0
      js/Kernel.js
  3. 18 0
      st/Kernel.st

+ 36 - 0
js/Kernel.deploy.js

@@ -526,6 +526,17 @@ return self;}
 }),
 smalltalk.Object);
 
+smalltalk.addMethod(
+'_foo',
+smalltalk.method({
+selector: 'foo',
+fn: function (){
+var self=this;
+return self;
+return self;}
+}),
+smalltalk.Object);
+
 
 smalltalk.addMethod(
 '_initialize',
@@ -925,6 +936,31 @@ return self;}
 }),
 smalltalk.Behavior);
 
+smalltalk.addMethod(
+'_compile_',
+smalltalk.method({
+selector: 'compile:',
+fn: function (aString){
+var self=this;
+smalltalk.send(self, "_compile_category_", [aString, ""]);
+return self;}
+}),
+smalltalk.Behavior);
+
+smalltalk.addMethod(
+'_compile_category_',
+smalltalk.method({
+selector: 'compile:category:',
+fn: function (aString, anotherString){
+var self=this;
+var method=nil;
+method=smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_load_forClass_", [aString, self]);
+smalltalk.send(method, "_category_", [anotherString]);
+smalltalk.send(self, "_addCompiledMethod_", [method]);
+return self;}
+}),
+smalltalk.Behavior);
+
 
 
 smalltalk.addClass('Class', smalltalk.Behavior, [], 'Kernel');

+ 48 - 0
js/Kernel.js

@@ -710,6 +710,21 @@ referencedClasses: [smalltalk.Date]
 }),
 smalltalk.Object);
 
+smalltalk.addMethod(
+'_foo',
+smalltalk.method({
+selector: 'foo',
+category: '',
+fn: function (){
+var self=this;
+return self;
+return self;},
+source: unescape('foo%20%5E%20self'),
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Object);
+
 
 smalltalk.addMethod(
 '_initialize',
@@ -1237,6 +1252,39 @@ referencedClasses: []
 }),
 smalltalk.Behavior);
 
+smalltalk.addMethod(
+'_compile_',
+smalltalk.method({
+selector: 'compile:',
+category: 'compiling',
+fn: function (aString){
+var self=this;
+smalltalk.send(self, "_compile_category_", [aString, ""]);
+return self;},
+source: unescape('compile%3A%20aString%0A%09self%20compile%3A%20aString%20category%3A%20%27%27'),
+messageSends: ["compile:category:"],
+referencedClasses: []
+}),
+smalltalk.Behavior);
+
+smalltalk.addMethod(
+'_compile_category_',
+smalltalk.method({
+selector: 'compile:category:',
+category: 'compiling',
+fn: function (aString, anotherString){
+var self=this;
+var method=nil;
+method=smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_load_forClass_", [aString, self]);
+smalltalk.send(method, "_category_", [anotherString]);
+smalltalk.send(self, "_addCompiledMethod_", [method]);
+return self;},
+source: unescape('compile%3A%20aString%20category%3A%20anotherString%0A%09%7C%20method%20%7C%0A%09method%20%3A%3D%20Compiler%20new%20load%3A%20aString%20forClass%3A%20self.%0A%09method%20category%3A%20anotherString.%0A%09self%20addCompiledMethod%3A%20method'),
+messageSends: ["load:forClass:", "new", "category:", "addCompiledMethod:"],
+referencedClasses: [smalltalk.Compiler]
+}),
+smalltalk.Behavior);
+
 
 
 smalltalk.addClass('Class', smalltalk.Behavior, [], 'Kernel');

+ 18 - 0
st/Kernel.st

@@ -2,6 +2,11 @@ nil subclass: #Object
 	instanceVariableNames: ''
 	category: 'Kernel'!
 
+!Object methodsFor: ''!
+
+foo ^ self
+! !
+
 !Object methodsFor: 'accessing'!
 
 yourself
@@ -422,6 +427,19 @@ commentStamp: aStamp prior: prior
         ^self commentStamp
 ! !
 
+!Behavior methodsFor: 'compiling'!
+
+compile: aString
+	self compile: aString category: ''
+!
+
+compile: aString category: anotherString
+	| method |
+	method := Compiler new load: aString forClass: self.
+	method category: anotherString.
+	self addCompiledMethod: method
+! !
+
 !Behavior methodsFor: 'instance creation'!
 
 new