Преглед изворни кода

Merge branch 'upstream' into gh-630

Conflicts:
	Gruntfile.js
	bin/amber-cli.js
Herbert Vojčík пре 10 година
родитељ
комит
71d5222b5b
7 измењених фајлова са 1084 додато и 490 уклоњено
  1. 2 1
      Gruntfile.js
  2. 1039 433
      bin/amber-cli.js
  3. 18 5
      cli/index.html
  4. 8 5
      cli/js/AmberCli.js
  5. 17 17
      cli/st/AmberCli.st
  6. 0 23
      js/Compiler-IR.js
  7. 0 6
      st/Compiler-IR.st

+ 2 - 1
Gruntfile.js

@@ -98,7 +98,8 @@ module.exports = function(grunt) {
             'Compiler-IR', 'Compiler-Inlining', 'Compiler-Semantic', 'Compiler-Interpreter', '@parser'
             'Compiler-IR', 'Compiler-Inlining', 'Compiler-Semantic', 'Compiler-Interpreter', '@parser'
         ],
         ],
         main_class: 'AmberCli',
         main_class: 'AmberCli',
-        output_name: '../../bin/amber-cli'
+        output_name: '../../bin/amber-cli',
+        amd_namespace: 'amber_cli'
       }
       }
     },
     },
 
 

Разлика између датотеке није приказан због своје велике величине
+ 1039 - 433
bin/amber-cli.js


+ 18 - 5
cli/index.html

@@ -5,15 +5,28 @@
     <title>Amber Smalltalk</title> 
     <title>Amber Smalltalk</title> 
     <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
     <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
     <meta name="author" content="Nicolas Petton" /> 
     <meta name="author" content="Nicolas Petton" /> 
-    <script type='text/javascript' src='../support/amber.js'></script>
+    <script type='text/javascript' src='../support/requirejs/require.min.js'></script>
+    <script src='../support/amber.js'></script>
+
   </head> 
   </head> 
 
 
   <body> 
   <body> 
     <script type='text/javascript'>
     <script type='text/javascript'>
-      loadAmber({
-        files: ['AmberCli.js'],
-        prefix: 'cli/js',
-        ready: function() {smalltalk.Browser._open()}})
+    require.config({
+        paths: {
+            'amber_cli': 'js',
+            'amber_cli/_source': 'st'
+        }
+    });
+    require(
+        ["amber/devel",
+            "amber_cli/AmberCli" ],
+        function (smalltalk) {
+            smalltalk.defaultAMDNamespace = 'amber_cli';
+            smalltalk.initialize();
+            smalltalk.Browser._openOn_(smalltalk.AmberCli);
+        }
+    );
     </script> 
     </script> 
   </body> 
   </body> 
 </html> 
 </html> 

+ 8 - 5
cli/js/AmberCli.js

@@ -1,4 +1,7 @@
+define("amber_cli/AmberCli", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
 smalltalk.addPackage('AmberCli');
 smalltalk.addPackage('AmberCli');
+smalltalk.packages["AmberCli"].transport = {"type":"amd","amdNamespace":"amber_cli"};
+
 smalltalk.addClass('AmberCli', smalltalk.Object, [], 'AmberCli');
 smalltalk.addClass('AmberCli', smalltalk.Object, [], 'AmberCli');
 smalltalk.AmberCli.comment="I am the Amber CLI (CommandLine Interface) tool which runs on Node.js.\x0a\x0aMy responsibility is to start different Amber programs like the FileServer or the Repl.\x0aWhich program to start is determined by the first commandline parameters passed to the AmberCli executable.\x0aUse `help` to get a list of all available options.\x0aAny further commandline parameters are passed to the specific program.\x0a\x0a## Commands\x0a\x0aNew commands can be added by creating a class side method in the `commands` protocol which takes one parameter.\x0aThis parameter is an array of all commandline options + values passed on to the program.\x0aAny `camelCaseCommand` is transformed into a commandline parameter of the form `camel-case-command` and vice versa.";
 smalltalk.AmberCli.comment="I am the Amber CLI (CommandLine Interface) tool which runs on Node.js.\x0a\x0aMy responsibility is to start different Amber programs like the FileServer or the Repl.\x0aWhich program to start is determined by the first commandline parameters passed to the AmberCli executable.\x0aUse `help` to get a list of all available options.\x0aAny further commandline parameters are passed to the specific program.\x0a\x0a## Commands\x0a\x0aNew commands can be added by creating a class side method in the `commands` protocol which takes one parameter.\x0aThis parameter is an array of all commandline options + values passed on to the program.\x0aAny `camelCaseCommand` is transformed into a commandline parameter of the form `camel-case-command` and vice versa.";
 
 
@@ -90,7 +93,7 @@ _st(console)._log_("Required is at least Node.js v0.8.x or greater.");
 return (-1);
 return (-1);
 };
 };
 args=_st(process)._argv();
 args=_st(process)._argv();
-_st(args)._removeFrom_to_((1),(3));
+_st(args)._removeFrom_to_((1),(2));
 $2=_st(args)._isEmpty();
 $2=_st(args)._isEmpty();
 if(smalltalk.assert($2)){
 if(smalltalk.assert($2)){
 self._help_(nil);
 self._help_(nil);
@@ -100,7 +103,7 @@ return $3;
 };
 };
 return self}, function($ctx1) {$ctx1.fill(self,"main",{args:args,nodeMinorVersion:nodeMinorVersion},smalltalk.AmberCli.klass)})},
 return self}, function($ctx1) {$ctx1.fill(self,"main",{args:args,nodeMinorVersion:nodeMinorVersion},smalltalk.AmberCli.klass)})},
 args: [],
 args: [],
-source: "main\x0a\x09\x22Main entry point for Amber applications.\x0a\x09Parses commandline arguments and starts the according subprogram.\x22\x0a\x09| args nodeMinorVersion |\x0a\x0a\x09nodeMinorVersion := ((process version) tokenize: '.') second asNumber.\x0a\x09nodeMinorVersion < 8 ifTrue: [\x0a\x09\x09console log: 'You are currently using Node.js ', (process version).\x0a\x09\x09console log: 'Required is at least Node.js v0.8.x or greater.'.\x0a\x09\x09^ -1.\x0a\x09].\x0a\x0a\x09args := process argv.\x0a\x09\x22Remove the first args which contain the path to the node executable and the script file.\x22\x0a\x09args removeFrom: 1 to: 3.\x0a\x09\x0a\x09(args isEmpty)\x0a\x09\x09ifTrue: [self help: nil]\x0a\x09\x09ifFalse: [^self handleArguments: args]",
+source: "main\x0a\x09\x22Main entry point for Amber applications.\x0a\x09Parses commandline arguments and starts the according subprogram.\x22\x0a\x09| args nodeMinorVersion |\x0a\x0a\x09nodeMinorVersion := ((process version) tokenize: '.') second asNumber.\x0a\x09nodeMinorVersion < 8 ifTrue: [\x0a\x09\x09console log: 'You are currently using Node.js ', (process version).\x0a\x09\x09console log: 'Required is at least Node.js v0.8.x or greater.'.\x0a\x09\x09^ -1.\x0a\x09].\x0a\x0a\x09args := process argv.\x0a\x09\x22Remove the first args which contain the path to the node executable and the script file.\x22\x0a\x09args removeFrom: 1 to: 2.\x0a\x09\x0a\x09(args isEmpty)\x0a\x09\x09ifTrue: [self help: nil]\x0a\x09\x09ifFalse: [^self handleArguments: args]",
 messageSends: ["asNumber", "second", "tokenize:", "version", "ifTrue:", "log:", ",", "<", "argv", "removeFrom:to:", "ifTrue:ifFalse:", "help:", "handleArguments:", "isEmpty"],
 messageSends: ["asNumber", "second", "tokenize:", "version", "ifTrue:", "log:", ",", "<", "argv", "removeFrom:to:", "ifTrue:ifFalse:", "help:", "handleArguments:", "isEmpty"],
 referencedClasses: []
 referencedClasses: []
 }),
 }),
@@ -455,7 +458,7 @@ category: 'initialization',
 fn: function (){
 fn: function (){
 var self=this;
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 return smalltalk.withContext(function($ctx1) { 
-smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
+smalltalk.FileServer.superclass.fn.prototype._initialize.apply(_st(self), []);
 self["@path"]=self._require_("path");
 self["@path"]=self._require_("path");
 self["@http"]=self._require_("http");
 self["@http"]=self._require_("http");
 self["@fs"]=self._require_("fs");
 self["@fs"]=self._require_("fs");
@@ -1381,7 +1384,7 @@ fn: function (){
 var self=this;
 var self=this;
 function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
 function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
 return smalltalk.withContext(function($ctx1) { 
 return smalltalk.withContext(function($ctx1) { 
-smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
+smalltalk.Repl.superclass.fn.prototype._initialize.apply(_st(self), []);
 self["@session"]=_st($DoIt())._new();
 self["@session"]=_st($DoIt())._new();
 self["@readline"]=_st(require)._value_("readline");
 self["@readline"]=_st(require)._value_("readline");
 self["@util"]=_st(require)._value_("util");
 self["@util"]=_st(require)._value_("util");
@@ -1765,4 +1768,4 @@ referencedClasses: []
 }),
 }),
 smalltalk.Repl.klass);
 smalltalk.Repl.klass);
 
 
-
+});

+ 17 - 17
cli/st/AmberCli.st

@@ -84,7 +84,7 @@ main
 
 
 	args := process argv.
 	args := process argv.
 	"Remove the first args which contain the path to the node executable and the script file."
 	"Remove the first args which contain the path to the node executable and the script file."
-	args removeFrom: 1 to: 3.
+	args removeFrom: 1 to: 2.
 	
 	
 	(args isEmpty)
 	(args isEmpty)
 		ifTrue: [self help: nil]
 		ifTrue: [self help: nil]
@@ -903,12 +903,12 @@ My runtime requirement is a functional Node.js executable with working Readline
 
 
 !Repl methodsFor: 'accessing'!
 !Repl methodsFor: 'accessing'!
 
 
-prompt
-	^'amber >> '
-!
-
 commands
 commands
 	^ commands
 	^ commands
+!
+
+prompt
+	^'amber >> '
 ! !
 ! !
 
 
 !Repl methodsFor: 'actions'!
 !Repl methodsFor: 'actions'!
@@ -955,14 +955,14 @@ initialize
 	self setupCommands
 	self setupCommands
 !
 !
 
 
-setupHotkeys
-	process stdin on: 'keypress' do: [:s :key | key ifNotNil: [self onKeyPress: key]].
-!
-
 setupCommands
 setupCommands
 	commands := Dictionary from: {
 	commands := Dictionary from: {
 		{':q'} -> [process exit].
 		{':q'} -> [process exit].
 		{''} -> [interface prompt]}
 		{''} -> [interface prompt]}
+!
+
+setupHotkeys
+	process stdin on: 'keypress' do: [:s :key | key ifNotNil: [self onKeyPress: key]].
 ! !
 ! !
 
 
 !Repl methodsFor: 'private'!
 !Repl methodsFor: 'private'!
@@ -987,6 +987,14 @@ assignNewVariable: buffer do: aBlock
 		aBlock value: varName value: value]
 		aBlock value: varName value: value]
 !
 !
 
 
+clearScreen
+	| esc cls |
+	esc := String fromCharCode: 27.
+	cls := esc, '[2J', esc, '[0;0f'.
+	process stdout write: cls.
+	interface prompt
+!
+
 encapsulateVariable: aString withValue: anObject in: aClass
 encapsulateVariable: aString withValue: anObject in: aClass
 	"Add getter and setter for given variable to session."
 	"Add getter and setter for given variable to session."
 	| compiler |
 	| compiler |
@@ -1033,14 +1041,6 @@ onKeyPress: key
 		ifTrue: [self clearScreen]
 		ifTrue: [self clearScreen]
 !
 !
 
 
-clearScreen
-	| esc cls |
-	esc := String fromCharCode: 27.
-	cls := esc, '[2J', esc, '[0;0f'.
-	process stdout write: cls.
-	interface prompt
-!
-
 parseAssignment: aString do: aBlock
 parseAssignment: aString do: aBlock
 	"Assigns a new variable if the given string is an assignment expression. Calls the given block with name and value.
 	"Assigns a new variable if the given string is an assignment expression. Calls the given block with name and value.
 	 If the string is not one no variable will be assigned and the block will be called with nil for both arguments."
 	 If the string is not one no variable will be assigned and the block will be called with nil for both arguments."

+ 0 - 23
js/Compiler-IR.js

@@ -3563,29 +3563,6 @@ referencedClasses: []
 }),
 }),
 smalltalk.JSStream);
 smalltalk.JSStream);
 
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "nextPutStatement:with:",
-category: 'streaming',
-fn: function (anInteger,aBlock){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2,$3,$4;
-$1=self["@stream"];
-_st($1)._nextPutAll_(_st("case ".__comma(_st(anInteger)._asString())).__comma(":"));
-$2=_st($1)._lf();
-self._nextPutStatementWith_(aBlock);
-$3=self["@stream"];
-_st($3)._nextPutAll_(_st("smalltalk.thisContext.pc=".__comma(_st(_st(anInteger).__plus((1)))._asString())).__comma(";"));
-$4=_st($3)._lf();
-return self}, function($ctx1) {$ctx1.fill(self,"nextPutStatement:with:",{anInteger:anInteger,aBlock:aBlock},smalltalk.JSStream)})},
-args: ["anInteger", "aBlock"],
-source: "nextPutStatement: anInteger with: aBlock\x0a\x09stream nextPutAll: 'case ', anInteger asString, ':'; lf.\x0a\x09self nextPutStatementWith: aBlock.\x0a\x09stream nextPutAll: 'smalltalk.thisContext.pc=', (anInteger + 1) asString, ';'; lf",
-messageSends: ["nextPutAll:", ",", "asString", "lf", "nextPutStatementWith:", "+"],
-referencedClasses: []
-}),
-smalltalk.JSStream);
-
 smalltalk.addMethod(
 smalltalk.addMethod(
 smalltalk.method({
 smalltalk.method({
 selector: "nextPutStatementWith:",
 selector: "nextPutStatementWith:",

+ 0 - 6
st/Compiler-IR.st

@@ -1219,12 +1219,6 @@ nextPutSequenceWith: aBlock
 		nextPutAll: '};'; lf"
 		nextPutAll: '};'; lf"
 !
 !
 
 
-nextPutStatement: anInteger with: aBlock
-	stream nextPutAll: 'case ', anInteger asString, ':'; lf.
-	self nextPutStatementWith: aBlock.
-	stream nextPutAll: 'smalltalk.thisContext.pc=', (anInteger + 1) asString, ';'; lf
-!
-
 nextPutStatementWith: aBlock
 nextPutStatementWith: aBlock
 	aBlock value.
 	aBlock value.
 	stream nextPutAll: ';'; lf
 	stream nextPutAll: ';'; lf

Неке датотеке нису приказане због велике количине промена