|
@@ -81,35 +81,227 @@ referencedClasses: []
|
|
|
smalltalk.ChunkParser.klass);
|
|
|
|
|
|
|
|
|
-smalltalk.addClass('Exporter', smalltalk.Object, [], 'Importer-Exporter');
|
|
|
-smalltalk.Exporter.comment="I am responsible for outputting Amber code into a JavaScript string.\x0a\x0aThe generated output is enough to reconstruct the exported data, including Smalltalk source code and other metadata.\x0a\x0a## Use case\x0a\x0aI am typically used to save code outside of the Amber runtime (committing to disk, etc.).\x0a\x0a## API\x0a\x0aUse `#exportAll`, `#exportClass:` or `#exportPackage:` methods.";
|
|
|
+smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
|
|
|
+smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a Importer new import: aString";
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
|
-selector: "classNameFor:",
|
|
|
-category: 'private',
|
|
|
-fn: function (aClass){
|
|
|
+selector: "import:",
|
|
|
+category: 'fileIn',
|
|
|
+fn: function (aStream){
|
|
|
var self=this;
|
|
|
+var chunk,result,parser,lastEmpty;
|
|
|
+function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
|
|
|
+function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
|
|
|
return smalltalk.withContext(function($ctx1) {
|
|
|
-var $2,$3,$1;
|
|
|
-$2=_st(aClass)._isMetaclass();
|
|
|
-if(smalltalk.assert($2)){
|
|
|
-$1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
|
|
|
-} else {
|
|
|
-$3=_st(aClass)._isNil();
|
|
|
-if(smalltalk.assert($3)){
|
|
|
-$1="nil";
|
|
|
+var $1,$2;
|
|
|
+parser=_st($ChunkParser())._on_(aStream);
|
|
|
+lastEmpty=false;
|
|
|
+_st((function(){
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+chunk=_st(parser)._nextChunk();
|
|
|
+chunk;
|
|
|
+return _st(chunk)._isNil();
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+$1=_st(chunk)._isEmpty();
|
|
|
+if(smalltalk.assert($1)){
|
|
|
+lastEmpty=true;
|
|
|
+return lastEmpty;
|
|
|
} else {
|
|
|
-$1=_st(aClass)._name();
|
|
|
+result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
|
|
|
+result;
|
|
|
+$2=lastEmpty;
|
|
|
+if(smalltalk.assert($2)){
|
|
|
+lastEmpty=false;
|
|
|
+lastEmpty;
|
|
|
+return _st(result)._scanFrom_(parser);
|
|
|
};
|
|
|
};
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
|
|
|
+args: ["aStream"],
|
|
|
+source: "import: aStream\x0a\x09| chunk result parser lastEmpty |\x0a\x09parser := ChunkParser on: aStream.\x0a\x09lastEmpty := false.\x0a\x09[chunk := parser nextChunk.\x0a\x09chunk isNil] whileFalse: [\x0a\x09\x09chunk isEmpty\x0a\x09\x09\x09ifTrue: [lastEmpty := true]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09result := Compiler new evaluateExpression: chunk.\x0a\x09\x09\x09\x09lastEmpty\x0a\x09\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09lastEmpty := false.\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09result scanFrom: parser]]]",
|
|
|
+messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"],
|
|
|
+referencedClasses: ["ChunkParser", "Compiler"]
|
|
|
+}),
|
|
|
+smalltalk.Importer);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
|
|
|
+smalltalk.PackageHandler.comment="I am responsible for handling package loading and committing.\x0a\x0aI should not be used directly. Instead, use the corresponding `Package` methods.";
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "ajaxPutAt:data:",
|
|
|
+category: 'private',
|
|
|
+fn: function (aURL,aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+_st(jQuery)._ajax_options_(aURL,smalltalk.HashedCollection._from_(["type".__minus_gt("PUT"),"data".__minus_gt(aString),"contentType".__minus_gt("text/plain;charset=UTF-8"),"error".__minus_gt((function(xhr){
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
|
|
|
+args: ["aURL", "aString"],
|
|
|
+source: "ajaxPutAt: aURL data: aString\x0a\x09jQuery\x0a\x09\x09ajax: aURL \x0a\x09\x09options: #{ \x0a\x09\x09\x09'type' -> 'PUT'.\x0a\x09\x09\x09'data' -> aString.\x0a\x09\x09\x09'contentType' -> 'text/plain;charset=UTF-8'.\x0a\x09\x09\x09'error' -> [ :xhr | self error: 'Commiting ' , aURL , ' failed with reason: \x22' , (xhr responseText) , '\x22'] }",
|
|
|
+messageSends: ["ajax:options:", "->", "error:", ",", "responseText"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PackageHandler);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "commit:",
|
|
|
+category: 'committing',
|
|
|
+fn: function (aPackage){
|
|
|
+var self=this;
|
|
|
+function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
|
|
|
+function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
|
|
|
+function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
|
|
|
+function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+_st([_st($Exporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js")),_st($StrippedExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".deploy.js")),_st($ChunkExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathSt()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"))])._do_displayingProgress_((function(commitStrategy){
|
|
|
+var fileContents;
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+fileContents=_st($String())._streamContents_((function(stream){
|
|
|
+return smalltalk.withContext(function($ctx3) {
|
|
|
+return _st(_st(_st(commitStrategy)._key())._new())._exportPackage_on_(aPackage,stream);
|
|
|
+}, function($ctx3) {$ctx3.fillBlock({stream:stream},$ctx2)})}));
|
|
|
+fileContents;
|
|
|
+return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({commitStrategy:commitStrategy,fileContents:fileContents},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
|
|
|
+args: ["aPackage"],
|
|
|
+source: "commit: aPackage\x0a\x09{ \x0a\x09\x09Exporter -> (aPackage commitPathJs, '/', aPackage name, '.js').\x0a\x09\x09StrippedExporter -> (aPackage commitPathJs, '/', aPackage name, '.deploy.js').\x0a\x09\x09ChunkExporter -> (aPackage commitPathSt, '/', aPackage name, '.st')\x0a\x09} \x0a\x09\x09do: [ :commitStrategy|| fileContents |\x0a\x09\x09\x09fileContents := String streamContents: [ :stream |\x0a\x09\x09\x09\x09commitStrategy key new exportPackage: aPackage on: stream ].\x0a\x09\x09\x09self ajaxPutAt: commitStrategy value data: fileContents ]\x0a\x09\x09displayingProgress: 'Committing package ', aPackage name",
|
|
|
+messageSends: ["do:displayingProgress:", "streamContents:", "exportPackage:on:", "new", "key", "ajaxPutAt:data:", "value", ",", "name", "->", "commitPathJs", "commitPathSt"],
|
|
|
+referencedClasses: ["String", "Exporter", "StrippedExporter", "ChunkExporter"]
|
|
|
+}),
|
|
|
+smalltalk.PackageHandler);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "loadPackage:prefix:",
|
|
|
+category: 'loading',
|
|
|
+fn: function (packageName,aString){
|
|
|
+var self=this;
|
|
|
+var url;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
|
|
|
+_st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+$1=_st(_st(jqXHR)._readyState()).__eq((4));
|
|
|
+if(smalltalk.assert($1)){
|
|
|
+return self._setupPackageNamed_prefix_(packageName,aString);
|
|
|
+};
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+return _st(window)._alert_("Could not load package at: ".__comma(url));
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageHandler)})},
|
|
|
+args: ["packageName", "aString"],
|
|
|
+source: "loadPackage: packageName prefix: aString\x0a\x09| url |\x0a\x09url := '/', aString, '/js/', packageName, '.js'.\x0a\x09jQuery\x0a\x09\x09ajax: url\x0a\x09\x09options: #{\x0a\x09\x09\x09'type' -> 'GET'.\x0a\x09\x09\x09'dataType' -> 'script'.\x0a\x09\x09\x09'complete' -> [ :jqXHR :textStatus |\x0a\x09\x09\x09\x09jqXHR readyState = 4\x0a\x09\x09\x09\x09\x09ifTrue: [ self setupPackageNamed: packageName prefix: aString ] ].\x0a\x09\x09\x09'error' -> [ window alert: 'Could not load package at: ', url ]\x0a\x09\x09}",
|
|
|
+messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PackageHandler);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "loadPackages:prefix:",
|
|
|
+category: 'loading',
|
|
|
+fn: function (aCollection,aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+_st(aCollection)._do_((function(each){
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+return self._loadPackage_prefix_(each,aString);
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler)})},
|
|
|
+args: ["aCollection", "aString"],
|
|
|
+source: "loadPackages: aCollection prefix: aString\x0a\x09aCollection do: [ :each |\x0a\x09\x09self loadPackage: each prefix: aString ]",
|
|
|
+messageSends: ["do:", "loadPackage:prefix:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PackageHandler);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "setupPackageNamed:prefix:",
|
|
|
+category: 'private',
|
|
|
+fn: function (packageName,aString){
|
|
|
+var self=this;
|
|
|
+function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1,$2;
|
|
|
+$1=_st($Package())._named_(packageName);
|
|
|
+_st($1)._setupClasses();
|
|
|
+_st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
|
|
|
+$2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageHandler)})},
|
|
|
+args: ["packageName", "aString"],
|
|
|
+source: "setupPackageNamed: packageName prefix: aString\x0a\x0a\x09(Package named: packageName)\x0a\x09\x09setupClasses;\x0a\x09\x09commitPathJs: '/', aString, '/js';\x0a\x09\x09commitPathSt: '/', aString, '/st'",
|
|
|
+messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"],
|
|
|
+referencedClasses: ["Package"]
|
|
|
+}),
|
|
|
+smalltalk.PackageHandler);
|
|
|
+
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "loadPackages:prefix:",
|
|
|
+category: 'loading',
|
|
|
+fn: function (aCollection,aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
|
|
|
return $1;
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
|
|
|
-args: ["aClass"],
|
|
|
-source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [aClass instanceClass name, '.klass']\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: ['nil']\x0a\x09\x09\x09ifFalse: [aClass name]]",
|
|
|
-messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler.klass)})},
|
|
|
+args: ["aCollection", "aString"],
|
|
|
+source: "loadPackages: aCollection prefix: aString\x0a\x09^ self new loadPackages: aCollection prefix: aString",
|
|
|
+messageSends: ["loadPackages:prefix:", "new"],
|
|
|
referencedClasses: []
|
|
|
}),
|
|
|
-smalltalk.Exporter);
|
|
|
+smalltalk.PackageHandler.klass);
|
|
|
+
|
|
|
+
|
|
|
+smalltalk.addClass('PluggableExporter', smalltalk.Object, [], 'Importer-Exporter');
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "export:usingRecipe:on:",
|
|
|
+category: 'fileOut',
|
|
|
+fn: function (anObject,anArray,aStream){
|
|
|
+var self=this;
|
|
|
+var args;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+args=[anObject,aStream];
|
|
|
+_st(anArray)._do_((function(each){
|
|
|
+var val;
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+val=_st(each)._value();
|
|
|
+val;
|
|
|
+$1=_st(val).__eq_eq(each);
|
|
|
+if(smalltalk.assert($1)){
|
|
|
+var selection;
|
|
|
+selection=_st(_st(_st(each)._first())._key())._perform_withArguments_(_st(_st(each)._first())._value(),[anObject]);
|
|
|
+selection;
|
|
|
+return _st(selection)._do_((function(eachPart){
|
|
|
+return smalltalk.withContext(function($ctx3) {
|
|
|
+return self._export_usingRecipe_on_(eachPart,_st(each)._allButFirst(),aStream);
|
|
|
+}, function($ctx3) {$ctx3.fillBlock({eachPart:eachPart},$ctx2)})}));
|
|
|
+} else {
|
|
|
+return _st(_st(each)._key())._perform_withArguments_(val,args);
|
|
|
+};
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({each:each,val:val},$ctx1)})}));
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"export:usingRecipe:on:",{anObject:anObject,anArray:anArray,aStream:aStream,args:args},smalltalk.PluggableExporter)})},
|
|
|
+args: ["anObject", "anArray", "aStream"],
|
|
|
+source: "export: anObject usingRecipe: anArray on: aStream\x0a\x09| args |\x0a\x09args := { anObject. aStream }.\x0a\x09anArray do: [ :each | | val |\x0a\x09\x09val := each value.\x0a\x09\x09val == each\x0a\x09\x09\x09ifFalse: [ \x22association\x22\x0a\x09\x09\x09\x09each key perform: val withArguments: args ]\x0a\x09\x09\x09ifTrue: [ \x22sub-array\x22\x0a\x09\x09\x09\x09| selection |\x0a\x09\x09\x09\x09selection := each first key perform: each first value withArguments: { anObject }.\x0a\x09\x09\x09\x09selection do: [ :eachPart |\x09self export: eachPart usingRecipe: each allButFirst on: aStream ]]]",
|
|
|
+messageSends: ["do:", "value", "ifFalse:ifTrue:", "perform:withArguments:", "key", "first", "export:usingRecipe:on:", "allButFirst", "=="],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PluggableExporter);
|
|
|
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
@@ -129,35 +321,58 @@ return self._exportPackage_on_(pkg,stream);
|
|
|
}, function($ctx3) {$ctx3.fillBlock({pkg:pkg},$ctx2)})}));
|
|
|
}, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
|
|
|
return $1;
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.Exporter)})},
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.PluggableExporter)})},
|
|
|
args: [],
|
|
|
source: "exportAll\x0a\x09\x22Export all packages in the system.\x22\x0a\x0a\x09^String streamContents: [:stream |\x0a\x09\x09Smalltalk current packages do: [:pkg |\x0a\x09\x09self exportPackage: pkg on: stream]]",
|
|
|
messageSends: ["streamContents:", "do:", "exportPackage:on:", "packages", "current"],
|
|
|
referencedClasses: ["Smalltalk", "String"]
|
|
|
}),
|
|
|
-smalltalk.Exporter);
|
|
|
+smalltalk.PluggableExporter);
|
|
|
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
|
-selector: "exportClass:on:",
|
|
|
+selector: "exportPackage:on:",
|
|
|
category: 'fileOut',
|
|
|
-fn: function (aClass,aStream){
|
|
|
+fn: function (aPackage,aStream){
|
|
|
var self=this;
|
|
|
return smalltalk.withContext(function($ctx1) {
|
|
|
-self._exportDefinitionOf_on_(aClass,aStream);
|
|
|
-_st(self._ownMethodsOfClass_(aClass))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportMethod_on_(each,aStream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-self._exportMetaDefinitionOf_on_(aClass,aStream);
|
|
|
-_st(self._ownMethodsOfMetaClass_(aClass))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportMethod_on_(each,aStream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"exportClass:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
|
|
|
-args: ["aClass", "aStream"],
|
|
|
-source: "exportClass: aClass on: aStream\x0a\x09\x22Export a single class. Subclasses override these methods.\x22\x0a\x0a\x09self exportDefinitionOf: aClass on: aStream.\x0a\x09(self ownMethodsOfClass: aClass) do: [ :each |\x0a\x09\x09self exportMethod: each on: aStream\x0a\x09].\x0a\x09self exportMetaDefinitionOf: aClass on: aStream.\x0a\x09(self ownMethodsOfMetaClass: aClass) do: [ :each |\x0a\x09\x09self exportMethod: each on: aStream\x0a\x09].",
|
|
|
-messageSends: ["exportDefinitionOf:on:", "do:", "exportMethod:on:", "ownMethodsOfClass:", "exportMetaDefinitionOf:on:", "ownMethodsOfMetaClass:"],
|
|
|
+self._export_usingRecipe_on_(aPackage,self._recipe(),aStream);
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{aPackage:aPackage,aStream:aStream},smalltalk.PluggableExporter)})},
|
|
|
+args: ["aPackage", "aStream"],
|
|
|
+source: "exportPackage: aPackage on: aStream\x0a\x09self export: aPackage usingRecipe: self recipe on: aStream",
|
|
|
+messageSends: ["export:usingRecipe:on:", "recipe"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PluggableExporter);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+smalltalk.addClass('Exporter', smalltalk.PluggableExporter, [], 'Importer-Exporter');
|
|
|
+smalltalk.Exporter.comment="I am responsible for outputting Amber code into a JavaScript string.\x0a\x0aThe generated output is enough to reconstruct the exported data, including Smalltalk source code and other metadata.\x0a\x0a## Use case\x0a\x0aI am typically used to save code outside of the Amber runtime (committing to disk, etc.).\x0a\x0a## API\x0a\x0aUse `#exportAll`, `#exportClass:` or `#exportPackage:` methods.";
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "classNameFor:",
|
|
|
+category: 'private',
|
|
|
+fn: function (aClass){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $2,$3,$1;
|
|
|
+$2=_st(aClass)._isMetaclass();
|
|
|
+if(smalltalk.assert($2)){
|
|
|
+$1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
|
|
|
+} else {
|
|
|
+$3=_st(aClass)._isNil();
|
|
|
+if(smalltalk.assert($3)){
|
|
|
+$1="nil";
|
|
|
+} else {
|
|
|
+$1=_st(aClass)._name();
|
|
|
+};
|
|
|
+};
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
|
|
|
+args: ["aClass"],
|
|
|
+source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [aClass instanceClass name, '.klass']\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: ['nil']\x0a\x09\x09\x09ifFalse: [aClass name]]",
|
|
|
+messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
|
|
|
referencedClasses: []
|
|
|
}),
|
|
|
smalltalk.Exporter);
|
|
@@ -282,32 +497,6 @@ referencedClasses: []
|
|
|
}),
|
|
|
smalltalk.Exporter);
|
|
|
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "exportPackage:on:",
|
|
|
-category: 'fileOut',
|
|
|
-fn: function (package_,stream){
|
|
|
-var self=this;
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-self._exportPackagePrologueOf_on_(package_,stream);
|
|
|
-self._exportPackageDefinitionOf_on_(package_,stream);
|
|
|
-_st(self._ownClassesOfPackage_(package_))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportClass_on_(each,stream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-_st(self._extensionMethodsOfPackage_(package_))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportMethod_on_(each,stream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-self._exportPackageEpilogueOf_on_(package_,stream);
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{package_:package_,stream:stream},smalltalk.Exporter)})},
|
|
|
-args: ["package", "stream"],
|
|
|
-source: "exportPackage: package on: stream\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09self exportPackagePrologueOf: package on: stream.\x0a\x09self exportPackageDefinitionOf: package on: stream.\x0a\x0a\x09(self ownClassesOfPackage: package) do: [:each |\x0a\x09\x09self exportClass: each on: stream\x0a\x09].\x0a\x09(self extensionMethodsOfPackage: package) do: [ :each |\x0a\x09\x09self exportMethod: each on: stream\x0a\x09].\x0a\x09self exportPackageEpilogueOf: package on: stream",
|
|
|
-messageSends: ["exportPackagePrologueOf:on:", "exportPackageDefinitionOf:on:", "do:", "exportClass:on:", "ownClassesOfPackage:", "exportMethod:on:", "extensionMethodsOfPackage:", "exportPackageEpilogueOf:on:"],
|
|
|
-referencedClasses: []
|
|
|
-}),
|
|
|
-smalltalk.Exporter);
|
|
|
-
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
|
selector: "exportPackageDefinitionOf:on:",
|
|
@@ -463,6 +652,24 @@ referencedClasses: []
|
|
|
}),
|
|
|
smalltalk.Exporter);
|
|
|
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "recipe",
|
|
|
+category: 'fileOut',
|
|
|
+fn: function (){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=[self.__minus_gt("exportPackagePrologueOf:on:"),self.__minus_gt("exportPackageDefinitionOf:on:"),[self.__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfClass:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportMetaDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfMetaClass:"),self.__minus_gt("exportMethod:on:")]],[self.__minus_gt("extensionMethodsOfPackage:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportPackageEpilogueOf:on:")];
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"recipe",{},smalltalk.Exporter)})},
|
|
|
+args: [],
|
|
|
+source: "recipe\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09^{\x0a\x09\x09self -> #exportPackagePrologueOf:on:.\x0a\x09\x09self -> #exportPackageDefinitionOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09self -> #ownClassesOfPackage:.\x0a\x09\x09\x09self -> #exportDefinitionOf:on:.\x0a\x09\x09\x09{\x0a\x09\x09\x09\x09self -> #ownMethodsOfClass:.\x0a\x09\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09\x09self -> #exportMetaDefinitionOf:on:.\x0a\x09\x09\x09{\x0a\x09\x09\x09\x09self -> #ownMethodsOfMetaClass:.\x0a\x09\x09\x09\x09self -> #exportMethod:on: } }.\x0a\x09\x09{\x0a\x09\x09\x09self -> #extensionMethodsOfPackage:.\x0a\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09self -> #exportPackageEpilogueOf:on:\x0a\x09}",
|
|
|
+messageSends: ["->"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.Exporter);
|
|
|
+
|
|
|
|
|
|
|
|
|
smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
|
|
@@ -515,55 +722,39 @@ smalltalk.ChunkExporter);
|
|
|
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
|
-selector: "exportCategory:on:",
|
|
|
+selector: "exportCategoryEpilogueOf:on:",
|
|
|
category: 'private',
|
|
|
fn: function (category,aStream){
|
|
|
var self=this;
|
|
|
return smalltalk.withContext(function($ctx1) {
|
|
|
-var $1,$2,$3,$4;
|
|
|
+var $1,$2;
|
|
|
$1=aStream;
|
|
|
-_st($1)._nextPutAll_("!".__comma(self._classNameFor_(_st(category)._at_("class"))));
|
|
|
-$2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(_st(category)._at_("name"))).__comma("'!"));
|
|
|
-_st(_st(_st(category)._at_("methods"))._sorted_((function(a,b){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportMethod_on_(each,aStream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-$3=aStream;
|
|
|
-_st($3)._nextPutAll_(" !");
|
|
|
-_st($3)._lf();
|
|
|
-$4=_st($3)._lf();
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"exportCategory:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
|
|
|
+_st($1)._nextPutAll_(" !");
|
|
|
+_st($1)._lf();
|
|
|
+$2=_st($1)._lf();
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryEpilogueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
|
|
|
args: ["category", "aStream"],
|
|
|
-source: "exportCategory: category on: aStream\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: (category at: #class));\x0a\x09\x09nextPutAll: ' methodsFor: ''', (category at: #name), '''!'.\x0a\x09\x09((category at: #methods) sorted: [:a :b | a selector <= b selector]) do: [:each |\x0a\x09\x09\x09\x09self exportMethod: each on: aStream].\x0a\x09aStream nextPutAll: ' !'; lf; lf",
|
|
|
-messageSends: ["nextPutAll:", ",", "classNameFor:", "at:", "do:", "exportMethod:on:", "sorted:", "<=", "selector", "lf"],
|
|
|
+source: "exportCategoryEpilogueOf: category on: aStream\x0a\x09aStream nextPutAll: ' !'; lf; lf",
|
|
|
+messageSends: ["nextPutAll:", "lf"],
|
|
|
referencedClasses: []
|
|
|
}),
|
|
|
smalltalk.ChunkExporter);
|
|
|
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
|
-selector: "exportClass:on:",
|
|
|
-category: 'fileOut',
|
|
|
-fn: function (aClass,aStream){
|
|
|
+selector: "exportCategoryPrologueOf:on:",
|
|
|
+category: 'private',
|
|
|
+fn: function (category,aStream){
|
|
|
var self=this;
|
|
|
return smalltalk.withContext(function($ctx1) {
|
|
|
-self._exportDefinitionOf_on_(aClass,aStream);
|
|
|
-_st(self._ownCategoriesOfClass_(aClass))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportCategory_on_(each,aStream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-self._exportMetaDefinitionOf_on_(aClass,aStream);
|
|
|
-_st(self._ownCategoriesOfMetaClass_(aClass))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportCategory_on_(each,aStream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"exportClass:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
|
|
|
-args: ["aClass", "aStream"],
|
|
|
-source: "exportClass: aClass on: aStream\x0a\x09\x22Export a single class. Subclasses override these methods.\x22\x0a\x0a\x09self exportDefinitionOf: aClass on: aStream.\x0a\x09(self ownCategoriesOfClass: aClass) do: [ :each |\x0a\x09\x09self exportCategory: each on: aStream\x0a\x09].\x0a\x09self exportMetaDefinitionOf: aClass on: aStream.\x0a\x09(self ownCategoriesOfMetaClass: aClass) do: [ :each |\x0a\x09\x09self exportCategory: each on: aStream\x0a\x09].",
|
|
|
-messageSends: ["exportDefinitionOf:on:", "do:", "exportCategory:on:", "ownCategoriesOfClass:", "exportMetaDefinitionOf:on:", "ownCategoriesOfMetaClass:"],
|
|
|
+var $1,$2;
|
|
|
+$1=aStream;
|
|
|
+_st($1)._nextPutAll_("!".__comma(self._classNameFor_(_st(category)._at_("class"))));
|
|
|
+$2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(_st(category)._at_("name"))).__comma("'!"));
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryPrologueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
|
|
|
+args: ["category", "aStream"],
|
|
|
+source: "exportCategoryPrologueOf: category on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: (category at: #class));\x0a\x09\x09nextPutAll: ' methodsFor: ''', (category at: #name), '''!'",
|
|
|
+messageSends: ["nextPutAll:", ",", "classNameFor:", "at:"],
|
|
|
referencedClasses: []
|
|
|
}),
|
|
|
smalltalk.ChunkExporter);
|
|
@@ -670,30 +861,6 @@ referencedClasses: []
|
|
|
}),
|
|
|
smalltalk.ChunkExporter);
|
|
|
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "exportPackage:on:",
|
|
|
-category: 'fileOut',
|
|
|
-fn: function (package_,stream){
|
|
|
-var self=this;
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-self._exportPackageDefinitionOf_on_(package_,stream);
|
|
|
-_st(self._ownClassesOfPackage_(package_))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportClass_on_(each,stream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-_st(self._extensionCategoriesOfPackage_(package_))._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._exportCategory_on_(each,stream);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{package_:package_,stream:stream},smalltalk.ChunkExporter)})},
|
|
|
-args: ["package", "stream"],
|
|
|
-source: "exportPackage: package on: stream\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09self exportPackageDefinitionOf: package on: stream.\x0a\x0a\x09(self ownClassesOfPackage: package) do: [:each |\x0a\x09\x09self exportClass: each on: stream\x0a\x09].\x0a\x09(self extensionCategoriesOfPackage: package) do: [ :each |\x0a\x09\x09self exportCategory: each on: stream\x0a\x09]",
|
|
|
-messageSends: ["exportPackageDefinitionOf:on:", "do:", "exportClass:on:", "ownClassesOfPackage:", "exportCategory:on:", "extensionCategoriesOfPackage:"],
|
|
|
-referencedClasses: []
|
|
|
-}),
|
|
|
-smalltalk.ChunkExporter);
|
|
|
-
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
|
selector: "exportPackageDefinitionOf:on:",
|
|
@@ -760,6 +927,27 @@ referencedClasses: ["OrderedCollection", "Dictionary", "Smalltalk", "Package"]
|
|
|
}),
|
|
|
smalltalk.ChunkExporter);
|
|
|
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "methodsOfCategory:",
|
|
|
+category: 'private',
|
|
|
+fn: function (category){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st(_st(category)._at_("methods"))._sorted_((function(a,b){
|
|
|
+return smalltalk.withContext(function($ctx2) {
|
|
|
+return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}));
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"methodsOfCategory:",{category:category},smalltalk.ChunkExporter)})},
|
|
|
+args: ["category"],
|
|
|
+source: "methodsOfCategory: category\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^(category at: #methods) sorted: [:a :b | a selector <= b selector]",
|
|
|
+messageSends: ["sorted:", "<=", "selector", "at:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.ChunkExporter);
|
|
|
+
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
|
selector: "ownCategoriesOfClass:",
|
|
@@ -812,6 +1000,26 @@ referencedClasses: []
|
|
|
}),
|
|
|
smalltalk.ChunkExporter);
|
|
|
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "recipe",
|
|
|
+category: 'fileOut',
|
|
|
+fn: function (){
|
|
|
+var self=this;
|
|
|
+var exportCategoryRecipe;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+exportCategoryRecipe=[self.__minus_gt("exportCategoryPrologueOf:on:"),[self.__minus_gt("methodsOfCategory:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportCategoryEpilogueOf:on:")];
|
|
|
+$1=[self.__minus_gt("exportPackageDefinitionOf:on:"),[self.__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfClass:")]).__comma(exportCategoryRecipe),self.__minus_gt("exportMetaDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfMetaClass:")]).__comma(exportCategoryRecipe)],_st([self.__minus_gt("extensionCategoriesOfPackage:")]).__comma(exportCategoryRecipe)];
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"recipe",{exportCategoryRecipe:exportCategoryRecipe},smalltalk.ChunkExporter)})},
|
|
|
+args: [],
|
|
|
+source: "recipe\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09| exportCategoryRecipe |\x0a\x09exportCategoryRecipe := {\x0a\x09\x09self -> #exportCategoryPrologueOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09self -> #methodsOfCategory:.\x0a\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09self -> #exportCategoryEpilogueOf:on: }.\x0a\x0a\x09^{\x0a\x09\x09self -> #exportPackageDefinitionOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09self -> #ownClassesOfPackage:.\x0a\x09\x09\x09self -> #exportDefinitionOf:on:.\x0a\x09\x09\x09{ self -> #ownCategoriesOfClass: }, exportCategoryRecipe.\x0a\x09\x09\x09self -> #exportMetaDefinitionOf:on:.\x0a\x09\x09\x09{ self -> #ownCategoriesOfMetaClass: }, exportCategoryRecipe }.\x0a\x09\x09{ self -> #extensionCategoriesOfPackage: }, exportCategoryRecipe\x0a\x09}",
|
|
|
+messageSends: ["->", ","],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.ChunkExporter);
|
|
|
+
|
|
|
|
|
|
|
|
|
smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
|
|
@@ -883,191 +1091,6 @@ referencedClasses: []
|
|
|
smalltalk.StrippedExporter);
|
|
|
|
|
|
|
|
|
-
|
|
|
-smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
|
|
|
-smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a Importer new import: aString";
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "import:",
|
|
|
-category: 'fileIn',
|
|
|
-fn: function (aStream){
|
|
|
-var self=this;
|
|
|
-var chunk,result,parser,lastEmpty;
|
|
|
-function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
|
|
|
-function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-var $1,$2;
|
|
|
-parser=_st($ChunkParser())._on_(aStream);
|
|
|
-lastEmpty=false;
|
|
|
-_st((function(){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-chunk=_st(parser)._nextChunk();
|
|
|
-chunk;
|
|
|
-return _st(chunk)._isNil();
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-$1=_st(chunk)._isEmpty();
|
|
|
-if(smalltalk.assert($1)){
|
|
|
-lastEmpty=true;
|
|
|
-return lastEmpty;
|
|
|
-} else {
|
|
|
-result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
|
|
|
-result;
|
|
|
-$2=lastEmpty;
|
|
|
-if(smalltalk.assert($2)){
|
|
|
-lastEmpty=false;
|
|
|
-lastEmpty;
|
|
|
-return _st(result)._scanFrom_(parser);
|
|
|
-};
|
|
|
-};
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
|
|
|
-args: ["aStream"],
|
|
|
-source: "import: aStream\x0a\x09| chunk result parser lastEmpty |\x0a\x09parser := ChunkParser on: aStream.\x0a\x09lastEmpty := false.\x0a\x09[chunk := parser nextChunk.\x0a\x09chunk isNil] whileFalse: [\x0a\x09\x09chunk isEmpty\x0a\x09\x09\x09ifTrue: [lastEmpty := true]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09result := Compiler new evaluateExpression: chunk.\x0a\x09\x09\x09\x09lastEmpty\x0a\x09\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09lastEmpty := false.\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09result scanFrom: parser]]]",
|
|
|
-messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"],
|
|
|
-referencedClasses: ["ChunkParser", "Compiler"]
|
|
|
-}),
|
|
|
-smalltalk.Importer);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
|
|
|
-smalltalk.PackageHandler.comment="I am responsible for handling package loading and committing.\x0a\x0aI should not be used directly. Instead, use the corresponding `Package` methods.";
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "ajaxPutAt:data:",
|
|
|
-category: 'private',
|
|
|
-fn: function (aURL,aString){
|
|
|
-var self=this;
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-_st(jQuery)._ajax_options_(aURL,smalltalk.HashedCollection._from_(["type".__minus_gt("PUT"),"data".__minus_gt(aString),"contentType".__minus_gt("text/plain;charset=UTF-8"),"error".__minus_gt((function(xhr){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
|
|
|
-args: ["aURL", "aString"],
|
|
|
-source: "ajaxPutAt: aURL data: aString\x0a\x09jQuery\x0a\x09\x09ajax: aURL \x0a\x09\x09options: #{ \x0a\x09\x09\x09'type' -> 'PUT'.\x0a\x09\x09\x09'data' -> aString.\x0a\x09\x09\x09'contentType' -> 'text/plain;charset=UTF-8'.\x0a\x09\x09\x09'error' -> [ :xhr | self error: 'Commiting ' , aURL , ' failed with reason: \x22' , (xhr responseText) , '\x22'] }",
|
|
|
-messageSends: ["ajax:options:", "->", "error:", ",", "responseText"],
|
|
|
-referencedClasses: []
|
|
|
-}),
|
|
|
-smalltalk.PackageHandler);
|
|
|
-
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "commit:",
|
|
|
-category: 'committing',
|
|
|
-fn: function (aPackage){
|
|
|
-var self=this;
|
|
|
-function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
|
|
|
-function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
|
|
|
-function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
|
|
|
-function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-_st([_st($Exporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js")),_st($StrippedExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".deploy.js")),_st($ChunkExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathSt()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"))])._do_displayingProgress_((function(commitStrategy){
|
|
|
-var fileContents;
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-fileContents=_st($String())._streamContents_((function(stream){
|
|
|
-return smalltalk.withContext(function($ctx3) {
|
|
|
-return _st(_st(_st(commitStrategy)._key())._new())._exportPackage_on_(aPackage,stream);
|
|
|
-}, function($ctx3) {$ctx3.fillBlock({stream:stream},$ctx2)})}));
|
|
|
-fileContents;
|
|
|
-return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({commitStrategy:commitStrategy,fileContents:fileContents},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
|
|
|
-args: ["aPackage"],
|
|
|
-source: "commit: aPackage\x0a\x09{ \x0a\x09\x09Exporter -> (aPackage commitPathJs, '/', aPackage name, '.js').\x0a\x09\x09StrippedExporter -> (aPackage commitPathJs, '/', aPackage name, '.deploy.js').\x0a\x09\x09ChunkExporter -> (aPackage commitPathSt, '/', aPackage name, '.st')\x0a\x09} \x0a\x09\x09do: [ :commitStrategy|| fileContents |\x0a\x09\x09\x09fileContents := String streamContents: [ :stream |\x0a\x09\x09\x09\x09commitStrategy key new exportPackage: aPackage on: stream ].\x0a\x09\x09\x09self ajaxPutAt: commitStrategy value data: fileContents ]\x0a\x09\x09displayingProgress: 'Committing package ', aPackage name",
|
|
|
-messageSends: ["do:displayingProgress:", "streamContents:", "exportPackage:on:", "new", "key", "ajaxPutAt:data:", "value", ",", "name", "->", "commitPathJs", "commitPathSt"],
|
|
|
-referencedClasses: ["String", "Exporter", "StrippedExporter", "ChunkExporter"]
|
|
|
-}),
|
|
|
-smalltalk.PackageHandler);
|
|
|
-
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "loadPackage:prefix:",
|
|
|
-category: 'loading',
|
|
|
-fn: function (packageName,aString){
|
|
|
-var self=this;
|
|
|
-var url;
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-var $1;
|
|
|
-url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
|
|
|
-_st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-$1=_st(_st(jqXHR)._readyState()).__eq((4));
|
|
|
-if(smalltalk.assert($1)){
|
|
|
-return self._setupPackageNamed_prefix_(packageName,aString);
|
|
|
-};
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return _st(window)._alert_("Could not load package at: ".__comma(url));
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageHandler)})},
|
|
|
-args: ["packageName", "aString"],
|
|
|
-source: "loadPackage: packageName prefix: aString\x0a\x09| url |\x0a\x09url := '/', aString, '/js/', packageName, '.js'.\x0a\x09jQuery\x0a\x09\x09ajax: url\x0a\x09\x09options: #{\x0a\x09\x09\x09'type' -> 'GET'.\x0a\x09\x09\x09'dataType' -> 'script'.\x0a\x09\x09\x09'complete' -> [ :jqXHR :textStatus |\x0a\x09\x09\x09\x09jqXHR readyState = 4\x0a\x09\x09\x09\x09\x09ifTrue: [ self setupPackageNamed: packageName prefix: aString ] ].\x0a\x09\x09\x09'error' -> [ window alert: 'Could not load package at: ', url ]\x0a\x09\x09}",
|
|
|
-messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"],
|
|
|
-referencedClasses: []
|
|
|
-}),
|
|
|
-smalltalk.PackageHandler);
|
|
|
-
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "loadPackages:prefix:",
|
|
|
-category: 'loading',
|
|
|
-fn: function (aCollection,aString){
|
|
|
-var self=this;
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-_st(aCollection)._do_((function(each){
|
|
|
-return smalltalk.withContext(function($ctx2) {
|
|
|
-return self._loadPackage_prefix_(each,aString);
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler)})},
|
|
|
-args: ["aCollection", "aString"],
|
|
|
-source: "loadPackages: aCollection prefix: aString\x0a\x09aCollection do: [ :each |\x0a\x09\x09self loadPackage: each prefix: aString ]",
|
|
|
-messageSends: ["do:", "loadPackage:prefix:"],
|
|
|
-referencedClasses: []
|
|
|
-}),
|
|
|
-smalltalk.PackageHandler);
|
|
|
-
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "setupPackageNamed:prefix:",
|
|
|
-category: 'private',
|
|
|
-fn: function (packageName,aString){
|
|
|
-var self=this;
|
|
|
-function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-var $1,$2;
|
|
|
-$1=_st($Package())._named_(packageName);
|
|
|
-_st($1)._setupClasses();
|
|
|
-_st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
|
|
|
-$2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
|
|
|
-return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageHandler)})},
|
|
|
-args: ["packageName", "aString"],
|
|
|
-source: "setupPackageNamed: packageName prefix: aString\x0a\x0a\x09(Package named: packageName)\x0a\x09\x09setupClasses;\x0a\x09\x09commitPathJs: '/', aString, '/js';\x0a\x09\x09commitPathSt: '/', aString, '/st'",
|
|
|
-messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"],
|
|
|
-referencedClasses: ["Package"]
|
|
|
-}),
|
|
|
-smalltalk.PackageHandler);
|
|
|
-
|
|
|
-
|
|
|
-smalltalk.addMethod(
|
|
|
-smalltalk.method({
|
|
|
-selector: "loadPackages:prefix:",
|
|
|
-category: 'loading',
|
|
|
-fn: function (aCollection,aString){
|
|
|
-var self=this;
|
|
|
-return smalltalk.withContext(function($ctx1) {
|
|
|
-var $1;
|
|
|
-$1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
|
|
|
-return $1;
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler.klass)})},
|
|
|
-args: ["aCollection", "aString"],
|
|
|
-source: "loadPackages: aCollection prefix: aString\x0a\x09^ self new loadPackages: aCollection prefix: aString",
|
|
|
-messageSends: ["loadPackages:prefix:", "new"],
|
|
|
-referencedClasses: []
|
|
|
-}),
|
|
|
-smalltalk.PackageHandler.klass);
|
|
|
-
|
|
|
smalltalk.addMethod(
|
|
|
smalltalk.method({
|
|
|
selector: "commit",
|