Browse Source

source is crlf sanitized

In method `source:` as well as in inline JS.
Herbert Vojčík 11 years ago
parent
commit
20845aeb6b
6 changed files with 147 additions and 108 deletions
  1. 52 52
      js/Compiler-IR.deploy.js
  2. 54 54
      js/Compiler-IR.js
  3. 15 0
      js/Kernel-Collections.deploy.js
  4. 20 0
      js/Kernel-Collections.js
  5. 2 2
      st/Compiler-IR.st
  6. 4 0
      st/Kernel-Collections.st

+ 52 - 52
js/Compiler-IR.deploy.js

@@ -362,66 +362,66 @@ smalltalk.addMethod(
 "_visitJSStatementNode_",
 smalltalk.method({
 selector: "visitJSStatementNode:",
-fn: function (aNode){
-var self=this;
-function $IRVerbatim(){return smalltalk.IRVerbatim||(typeof IRVerbatim=="undefined"?nil:IRVerbatim)}
-return smalltalk.withContext(function($ctx1) { 
-var $2,$3,$1;
-$2=_st($IRVerbatim())._new();
-_st($2)._source_(_st(aNode)._source());
-$3=_st($2)._yourself();
-$1=$3;
-return $1;
+fn: function (aNode){
+var self=this;
+function $IRVerbatim(){return smalltalk.IRVerbatim||(typeof IRVerbatim=="undefined"?nil:IRVerbatim)}
+return smalltalk.withContext(function($ctx1) { 
+var $2,$3,$1;
+$2=_st($IRVerbatim())._new();
+_st($2)._source_(_st(_st(aNode)._source())._crlfSanitized());
+$3=_st($2)._yourself();
+$1=$3;
+return $1;
 }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.IRASTTranslator)})},
-messageSends: ["source:", "source", "new", "yourself"]}),
+messageSends: ["source:", "crlfSanitized", "source", "new", "yourself"]}),
 smalltalk.IRASTTranslator);
 
 smalltalk.addMethod(
 "_visitMethodNode_",
 smalltalk.method({
 selector: "visitMethodNode:",
-fn: function (aNode){
-var self=this;
-function $IRMethod(){return smalltalk.IRMethod||(typeof IRMethod=="undefined"?nil:IRMethod)}
-function $IRTempDeclaration(){return smalltalk.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
-function $IRVariable(){return smalltalk.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
-function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2,$3,$4,$5,$6,$7,$8;
-$1=_st($IRMethod())._new();
-_st($1)._source_(_st(self)._source());
-_st($1)._theClass_(_st(self)._theClass());
-_st($1)._arguments_(_st(aNode)._arguments());
-_st($1)._selector_(_st(aNode)._selector());
-_st($1)._messageSends_(_st(aNode)._messageSends());
-_st($1)._superSends_(_st(aNode)._superSends());
-_st($1)._classReferences_(_st(aNode)._classReferences());
-_st($1)._scope_(_st(aNode)._scope());
-$2=_st($1)._yourself();
-_st(self)._method_($2);
-_st(_st(_st(aNode)._scope())._temps())._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-$3=_st($IRTempDeclaration())._new();
-_st($3)._name_(_st(each)._name());
-_st($3)._scope_(_st(aNode)._scope());
-$4=_st($3)._yourself();
-return _st(_st(self)._method())._add_($4);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-_st(_st(aNode)._nodes())._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return _st(_st(self)._method())._add_(_st(self)._visit_(each));
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-$5=_st(_st(aNode)._scope())._hasLocalReturn();
-if(! smalltalk.assert($5)){
-$6=_st($IRVariable())._new();
-_st($6)._variable_(_st(_st(_st(aNode)._scope())._pseudoVars())._at_("self"));
-$7=_st($6)._yourself();
-_st(_st(_st(self)._method())._add_(_st($IRReturn())._new()))._add_($7);
-};
-$8=_st(self)._method();
-return $8;
+fn: function (aNode){
+var self=this;
+function $IRMethod(){return smalltalk.IRMethod||(typeof IRMethod=="undefined"?nil:IRMethod)}
+function $IRTempDeclaration(){return smalltalk.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
+function $IRVariable(){return smalltalk.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
+function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2,$3,$4,$5,$6,$7,$8;
+$1=_st($IRMethod())._new();
+_st($1)._source_(_st(_st(self)._source())._crlfSanitized());
+_st($1)._theClass_(_st(self)._theClass());
+_st($1)._arguments_(_st(aNode)._arguments());
+_st($1)._selector_(_st(aNode)._selector());
+_st($1)._messageSends_(_st(aNode)._messageSends());
+_st($1)._superSends_(_st(aNode)._superSends());
+_st($1)._classReferences_(_st(aNode)._classReferences());
+_st($1)._scope_(_st(aNode)._scope());
+$2=_st($1)._yourself();
+_st(self)._method_($2);
+_st(_st(_st(aNode)._scope())._temps())._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
+$3=_st($IRTempDeclaration())._new();
+_st($3)._name_(_st(each)._name());
+_st($3)._scope_(_st(aNode)._scope());
+$4=_st($3)._yourself();
+return _st(_st(self)._method())._add_($4);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+_st(_st(aNode)._nodes())._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
+return _st(_st(self)._method())._add_(_st(self)._visit_(each));
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+$5=_st(_st(aNode)._scope())._hasLocalReturn();
+if(! smalltalk.assert($5)){
+$6=_st($IRVariable())._new();
+_st($6)._variable_(_st(_st(_st(aNode)._scope())._pseudoVars())._at_("self"));
+$7=_st($6)._yourself();
+_st(_st(_st(self)._method())._add_(_st($IRReturn())._new()))._add_($7);
+};
+$8=_st(self)._method();
+return $8;
 }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},smalltalk.IRASTTranslator)})},
-messageSends: ["method:", "source:", "source", "new", "theClass:", "theClass", "arguments:", "arguments", "selector:", "selector", "messageSends:", "messageSends", "superSends:", "superSends", "classReferences:", "classReferences", "scope:", "scope", "yourself", "do:", "add:", "name:", "name", "method", "temps", "visit:", "nodes", "ifFalse:", "variable:", "at:", "pseudoVars", "hasLocalReturn"]}),
+messageSends: ["method:", "source:", "crlfSanitized", "source", "new", "theClass:", "theClass", "arguments:", "arguments", "selector:", "selector", "messageSends:", "messageSends", "superSends:", "superSends", "classReferences:", "classReferences", "scope:", "scope", "yourself", "do:", "add:", "name:", "name", "method", "temps", "visit:", "nodes", "ifFalse:", "variable:", "at:", "pseudoVars", "hasLocalReturn"]}),
 smalltalk.IRASTTranslator);
 
 smalltalk.addMethod(

+ 54 - 54
js/Compiler-IR.js

@@ -449,20 +449,20 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "visitJSStatementNode:",
 category: 'visiting',
-fn: function (aNode){
-var self=this;
-function $IRVerbatim(){return smalltalk.IRVerbatim||(typeof IRVerbatim=="undefined"?nil:IRVerbatim)}
-return smalltalk.withContext(function($ctx1) { 
-var $2,$3,$1;
-$2=_st($IRVerbatim())._new();
-_st($2)._source_(_st(aNode)._source());
-$3=_st($2)._yourself();
-$1=$3;
-return $1;
+fn: function (aNode){
+var self=this;
+function $IRVerbatim(){return smalltalk.IRVerbatim||(typeof IRVerbatim=="undefined"?nil:IRVerbatim)}
+return smalltalk.withContext(function($ctx1) { 
+var $2,$3,$1;
+$2=_st($IRVerbatim())._new();
+_st($2)._source_(_st(_st(aNode)._source())._crlfSanitized());
+$3=_st($2)._yourself();
+$1=$3;
+return $1;
 }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.IRASTTranslator)})},
 args: ["aNode"],
-source: "visitJSStatementNode: aNode\x0a\x09^ IRVerbatim new\x0a\x09\x09source: aNode source;\x0a\x09\x09yourself",
-messageSends: ["source:", "source", "new", "yourself"],
+source: "visitJSStatementNode: aNode\x0a\x09^ IRVerbatim new\x0a\x09\x09source: aNode source crlfSanitized;\x0a\x09\x09yourself",
+messageSends: ["source:", "crlfSanitized", "source", "new", "yourself"],
 referencedClasses: ["IRVerbatim"]
 }),
 smalltalk.IRASTTranslator);
@@ -472,50 +472,50 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "visitMethodNode:",
 category: 'visiting',
-fn: function (aNode){
-var self=this;
-function $IRMethod(){return smalltalk.IRMethod||(typeof IRMethod=="undefined"?nil:IRMethod)}
-function $IRTempDeclaration(){return smalltalk.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
-function $IRVariable(){return smalltalk.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
-function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2,$3,$4,$5,$6,$7,$8;
-$1=_st($IRMethod())._new();
-_st($1)._source_(_st(self)._source());
-_st($1)._theClass_(_st(self)._theClass());
-_st($1)._arguments_(_st(aNode)._arguments());
-_st($1)._selector_(_st(aNode)._selector());
-_st($1)._messageSends_(_st(aNode)._messageSends());
-_st($1)._superSends_(_st(aNode)._superSends());
-_st($1)._classReferences_(_st(aNode)._classReferences());
-_st($1)._scope_(_st(aNode)._scope());
-$2=_st($1)._yourself();
-_st(self)._method_($2);
-_st(_st(_st(aNode)._scope())._temps())._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-$3=_st($IRTempDeclaration())._new();
-_st($3)._name_(_st(each)._name());
-_st($3)._scope_(_st(aNode)._scope());
-$4=_st($3)._yourself();
-return _st(_st(self)._method())._add_($4);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-_st(_st(aNode)._nodes())._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return _st(_st(self)._method())._add_(_st(self)._visit_(each));
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-$5=_st(_st(aNode)._scope())._hasLocalReturn();
-if(! smalltalk.assert($5)){
-$6=_st($IRVariable())._new();
-_st($6)._variable_(_st(_st(_st(aNode)._scope())._pseudoVars())._at_("self"));
-$7=_st($6)._yourself();
-_st(_st(_st(self)._method())._add_(_st($IRReturn())._new()))._add_($7);
-};
-$8=_st(self)._method();
-return $8;
+fn: function (aNode){
+var self=this;
+function $IRMethod(){return smalltalk.IRMethod||(typeof IRMethod=="undefined"?nil:IRMethod)}
+function $IRTempDeclaration(){return smalltalk.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
+function $IRVariable(){return smalltalk.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
+function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2,$3,$4,$5,$6,$7,$8;
+$1=_st($IRMethod())._new();
+_st($1)._source_(_st(_st(self)._source())._crlfSanitized());
+_st($1)._theClass_(_st(self)._theClass());
+_st($1)._arguments_(_st(aNode)._arguments());
+_st($1)._selector_(_st(aNode)._selector());
+_st($1)._messageSends_(_st(aNode)._messageSends());
+_st($1)._superSends_(_st(aNode)._superSends());
+_st($1)._classReferences_(_st(aNode)._classReferences());
+_st($1)._scope_(_st(aNode)._scope());
+$2=_st($1)._yourself();
+_st(self)._method_($2);
+_st(_st(_st(aNode)._scope())._temps())._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
+$3=_st($IRTempDeclaration())._new();
+_st($3)._name_(_st(each)._name());
+_st($3)._scope_(_st(aNode)._scope());
+$4=_st($3)._yourself();
+return _st(_st(self)._method())._add_($4);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+_st(_st(aNode)._nodes())._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
+return _st(_st(self)._method())._add_(_st(self)._visit_(each));
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+$5=_st(_st(aNode)._scope())._hasLocalReturn();
+if(! smalltalk.assert($5)){
+$6=_st($IRVariable())._new();
+_st($6)._variable_(_st(_st(_st(aNode)._scope())._pseudoVars())._at_("self"));
+$7=_st($6)._yourself();
+_st(_st(_st(self)._method())._add_(_st($IRReturn())._new()))._add_($7);
+};
+$8=_st(self)._method();
+return $8;
 }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},smalltalk.IRASTTranslator)})},
 args: ["aNode"],
-source: "visitMethodNode: aNode\x0a\x0a\x09self method: (IRMethod new\x0a\x09\x09source: self source;\x0a\x09\x09theClass: self theClass;\x0a\x09\x09arguments: aNode arguments;\x0a\x09\x09selector: aNode selector;\x0a\x09\x09messageSends: aNode messageSends;\x0a\x09\x09superSends: aNode superSends;\x0a\x09\x09classReferences: aNode classReferences;\x0a\x09\x09scope: aNode scope;\x0a\x09\x09yourself).\x0a\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09self method add: (IRTempDeclaration new\x0a\x09\x09\x09name: each name;\x0a\x09\x09\x09scope: aNode scope;\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09aNode nodes do: [ :each | self method add: (self visit: each) ].\x0a\x0a\x09aNode scope hasLocalReturn ifFalse: [\x0a\x09\x09(self method add: IRReturn new) add: (IRVariable new\x0a\x09\x09\x09variable: (aNode scope pseudoVars at: 'self');\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09^ self method",
-messageSends: ["method:", "source:", "source", "new", "theClass:", "theClass", "arguments:", "arguments", "selector:", "selector", "messageSends:", "messageSends", "superSends:", "superSends", "classReferences:", "classReferences", "scope:", "scope", "yourself", "do:", "add:", "name:", "name", "method", "temps", "visit:", "nodes", "ifFalse:", "variable:", "at:", "pseudoVars", "hasLocalReturn"],
+source: "visitMethodNode: aNode\x0a\x0a\x09self method: (IRMethod new\x0a\x09\x09source: self source crlfSanitized;\x0a\x09\x09theClass: self theClass;\x0a\x09\x09arguments: aNode arguments;\x0a\x09\x09selector: aNode selector;\x0a\x09\x09messageSends: aNode messageSends;\x0a\x09\x09superSends: aNode superSends;\x0a\x09\x09classReferences: aNode classReferences;\x0a\x09\x09scope: aNode scope;\x0a\x09\x09yourself).\x0a\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09self method add: (IRTempDeclaration new\x0a\x09\x09\x09name: each name;\x0a\x09\x09\x09scope: aNode scope;\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09aNode nodes do: [ :each | self method add: (self visit: each) ].\x0a\x0a\x09aNode scope hasLocalReturn ifFalse: [\x0a\x09\x09(self method add: IRReturn new) add: (IRVariable new\x0a\x09\x09\x09variable: (aNode scope pseudoVars at: 'self');\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09^ self method",
+messageSends: ["method:", "source:", "crlfSanitized", "source", "new", "theClass:", "theClass", "arguments:", "arguments", "selector:", "selector", "messageSends:", "messageSends", "superSends:", "superSends", "classReferences:", "classReferences", "scope:", "scope", "yourself", "do:", "add:", "name:", "name", "method", "temps", "visit:", "nodes", "ifFalse:", "variable:", "at:", "pseudoVars", "hasLocalReturn"],
 referencedClasses: ["IRMethod", "IRTempDeclaration", "IRVariable", "IRReturn"]
 }),
 smalltalk.IRASTTranslator);

+ 15 - 0
js/Kernel-Collections.deploy.js

@@ -2588,6 +2588,21 @@ return self}, function($ctx1) {$ctx1.fill(self,"copyFrom:to:",{anIndex:anIndex,a
 messageSends: []}),
 smalltalk.String);
 
+smalltalk.addMethod(
+"_crlfSanitized",
+smalltalk.method({
+selector: "crlfSanitized",
+fn: function (){
+var self=this;
+function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(self)._lines())._join_(_st($String())._lf());
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"crlfSanitized",{},smalltalk.String)})},
+messageSends: ["join:", "lf", "lines"]}),
+smalltalk.String);
+
 smalltalk.addMethod(
 "_deepCopy",
 smalltalk.method({

+ 20 - 0
js/Kernel-Collections.js

@@ -3502,6 +3502,26 @@ referencedClasses: []
 }),
 smalltalk.String);
 
+smalltalk.addMethod(
+"_crlfSanitized",
+smalltalk.method({
+selector: "crlfSanitized",
+category: 'converting',
+fn: function (){
+var self=this;
+function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(self)._lines())._join_(_st($String())._lf());
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"crlfSanitized",{},smalltalk.String)})},
+args: [],
+source: "crlfSanitized\x0a\x09^self lines join: String lf",
+messageSends: ["join:", "lf", "lines"],
+referencedClasses: ["String"]
+}),
+smalltalk.String);
+
 smalltalk.addMethod(
 "_deepCopy",
 smalltalk.method({

+ 2 - 2
st/Compiler-IR.st

@@ -167,14 +167,14 @@ visitDynamicDictionaryNode: aNode
 
 visitJSStatementNode: aNode
 	^ IRVerbatim new
-		source: aNode source;
+		source: aNode source crlfSanitized;
 		yourself
 !
 
 visitMethodNode: aNode
 
 	self method: (IRMethod new
-		source: self source;
+		source: self source crlfSanitized;
 		theClass: self theClass;
 		arguments: aNode arguments;
 		selector: aNode selector;

+ 4 - 0
st/Kernel-Collections.st

@@ -1195,6 +1195,10 @@ asUppercase
 	<return self.toUpperCase()>
 !
 
+crlfSanitized
+	^self lines join: String lf
+!
+
 reversed
 	<return self.split("").reverse().join("")>
 !