1
0
فهرست منبع

Added Google Closure compiler to jtalkc and updated Node.js Hello example to use new Smalltalk syntax.

Göran Krampe 13 سال پیش
والد
کامیت
29e56bd5ab
4فایلهای تغییر یافته به همراه24 افزوده شده و 12 حذف شده
  1. 19 3
      bin/jtalkc
  2. 1 1
      nodejs/hello/Hello.st
  3. 1 1
      nodejs/hello/Makefile
  4. 3 7
      nodejs/hello/README

+ 19 - 3
bin/jtalkc

@@ -117,8 +117,10 @@ case "$o" in
       MAIN=Main;;
    K) BASE=$KERNEL;;
    C) BASE=$COMPILER;;
-   o) CLOSURE=true;;
-   O) CLOSUREFULL=true;;
+   o) CLOSURE=true
+      CLOSUREPARTS=true;;
+   O) CLOSURE=true
+      CLOSUREFULL=true;;
    l) LOAD=$OPTARG;;
    L) LOAD="$JTALK/*.js";;
    I) INIT=$INITIALIZER;;
@@ -131,6 +133,20 @@ case "$o" in
 done
 shift $(($OPTIND - 1))
 
+# Check for Closure compiler and Java
+if [ ! -z $CLOSURE ]; then
+  java > /dev/null
+  if [ $? -eq 0 ]; then 
+    if [ ! -f ~/compiler.jar ]; then
+      echo "Can not find Closure compiler at ~/compiler.jar"
+      exit 1
+    fi
+  else
+   echo "java is not installed and is needed for -O or -o (Closure compiler)."
+   exit 1
+  fi
+fi
+
 # Define our Compiler
 # We need to add extra listed libraries in $LOAD not already in $CANVAS
 OURCOMPILER="$CANVAS $JTALK/js/init.js $JTALK/nodejs/nodecompile.js"
@@ -207,7 +223,7 @@ do
   fi 
 done
 
-if [ ! -z $CLOSURE ]; then
+if [ ! -z $CLOSUREPARTS ]; then
   echo "Compiling all js files using Google closure compiler."
 
   ALLJSFILES="$COMPILED $LIBS"

+ 1 - 1
nodejs/hello/Hello.st

@@ -5,7 +5,7 @@ Object subclass: #Hello
 !Hello class methodsFor: 'main'!
 
 main
-	{'console.log(smalltalk.Hello._new()._hello());'}
+	console log: Hello new hello
 ! ! 
 
 !Hello methodsFor: 'printing'!

+ 1 - 1
nodejs/hello/Makefile

@@ -1,5 +1,5 @@
 Program.js: Hello.st
-	../jtalkc -N -m Hello Hello.st Program
+	../../bin/jtalkc -N -O -m Hello Hello.st Program
 
 run: Program.js
 	./hello

+ 3 - 7
nodejs/hello/README

@@ -1,17 +1,13 @@
-Trivial Node.js example in JTalk:
+Trivial Node.js example in JTalk that also uses the Google Closure compiler
+if ~/compiler.jar is present.
 
 Hello.st - source code.
 hello    - trivial bash script to run resulting program.
-main.js  - small "doit" to actually run code. Will be added by ntalkc.
 Makefile - trivial makefile, read it.
 
-Hello.js - produced when you run make. Contains JTalk + Hello.st + main.js
+Hello.js - produced when you run make. Contains JTalk + Hello.st + a main call
 
 To play, do this:
 
-make run
-
-...or:
-
 make
 ./hello