Ver código fonte

Merge pull request #395 from mkroehnert/grunt

amberc and grunt.js fixes
Nicolas Petton 11 anos atrás
pai
commit
095575abd0
10 arquivos alterados com 66 adições e 628 exclusões
  1. 2 2
      CHANGELOG
  2. 6 2
      bin/amberc.js
  3. 0 353
      bin/amberc.sh
  4. 0 33
      bin/nodecompile.js
  5. 34 15
      grunt.js
  6. 0 8
      repl/Makefile
  7. 0 8
      server/Makefile
  8. 0 129
      st/Makefile
  9. 0 53
      test/Test.deploy.js
  10. 24 25
      test/Test.js

+ 2 - 2
CHANGELOG

@@ -17,9 +17,9 @@ Here's a summary of change since the 0.9.1 release:
   - support for blocks contexts
 
 - SUnit improvements and cleanup, with support for async assertions
-- New build system based on gruntjs, replacing the old makefiles
+- New build system based on grunt.js, replacing the old makefiles
 - Improved ClassBuilder with better class migration support
-- New bin/amberc compiler written in Amber
+- New bin/amberc compiler written in Amber/Node.js
 - Improved loader for third party packages
 - New IDE on it's way for Amber 1.0
 

+ 6 - 2
bin/amberc.js

@@ -316,7 +316,7 @@ AmberC.prototype.collect_js_files = function(jsFiles, callback) {
 AmberC.prototype.resolve_libraries = function() {
 	// Resolve libraries listed in this.kernel_libraries
 	var self = this;
-	var all_resolved = new Combo(function(resolved_library_files, resolved_compiler_files) {
+	var all_resolved = new Combo(function(resolved_kernel_files, resolved_compiler_files) {
 		self.resolve_init(resolved_compiler_files[0]);
 	});
 	this.resolve_kernel(all_resolved.add());
@@ -332,11 +332,15 @@ AmberC.prototype.resolve_kernel = function(callback) {
 	var self = this;
 	var kernel_files = this.kernel_libraries.concat(this.defaults.load);
 	var kernel_resolved = new Combo(function() {
+		var foundLibraries = [];
 		Array.prototype.slice.call(arguments).forEach(function(file) {
 			if (undefined !== file[0]) {
-				self.defaults.libraries.push(file[0]);
+				foundLibraries.push(file[0]);
 			}
 		});
+		// boot.js and Kernel files need to be used first
+		// otherwise the global smalltalk object is undefined
+		self.defaults.libraries = foundLibraries.concat(self.defaults.libraries);
 		callback(null);
 	});
 

+ 0 - 353
bin/amberc.sh

@@ -1,353 +0,0 @@
-#!/bin/bash
-#
-# This is a "compiler" for Amber code. Run without arguments for help.
-#
-# Get Amber root directory from the location of this script so that
-# we can find the st and js directories etc.
-
-# Earlier we used this but it does not work on Mac
-# Amber=$(readlink -f `dirname ${0}`/..)
-TARGET=`dirname ${0}`/..
-pushd . >/dev/null
-cd $TARGET
-AMBER="`\pwd -P`"
-popd >/dev/null
-
-function usage {
-	cat <<ENDOFHELP
-Usage: $0 [-l lib1,lib2...] [-i file] [-m class] [-M file]
-          [-o] [-O|-A] [-d] [-s suffix] [-S suffix] [file1 [file2 ...]] [Program]
-
-   Will compile Amber files - either separately or into a runnable complete
-   program. If no .st files are listed only a linking stage is performed.
-   Files listed will be handled using these rules:
-
-   *.js
-     Files are linked (concatenated) in listed order.
-     If not found we look in $AMBER/js
-
-   *.st
-     Files are compiled into .js files before concatenated.
-     If not found we look in $AMBER/st.
-
-     NOTE: Each file is currently considered to be a fileout of a single class
-     category of the same name as the file!
-
-   If no Program is specified each given .st file will be compiled into
-   a .js file. Otherwise a <Program>.js file is linked together based on
-   the options:
-
-  -l library1,library2
-     Additionally add listed libraries (no spaces or .js) in listed order.
-
-  -i file
-     Add library initializer <file> instead of default $AMBER/js/init.js 
-
-  -m class
-     Add at end a call to #main in class <class>. 
-
-  -M file
-     Add at end javascript file <file> acting as main.
-        
-  -o
-     Optimize each js file using the Google closure compiler.
-     Using Closure compiler found at ~/compiler.jar    
-
-  -O
-     Optimize final <Program>.js using the Google closure compiler.
-     Using Closure compiler found at ~/compiler.jar
-
-  -A Same as -O but use --compilation_level ADVANCED_OPTIMIZATIONS
-
-  -d
-     Additionally export code for deploy - stripped from source etc.
-     Uses suffix ".deploy.js" in addition to any explicit given suffic using -s.
-
-  -s suffix
-     Add <suffix> to compiled js files so that File.st is compiled into
-     File.<suffix>.js.
-
-  -S suffix
-     Use <suffix> for all libraries accessed using -L or -l. This makes it possible
-     to have multiple flavors of Amber and libraries in the same place.
-
-
-     Example invocations:
-
-     Just compile Kernel-Objects.st to Kernel-Objects.js:
-
-        amberc Kernel-Objects.st
-
-     Compile Hello.st to Hello.js and create complete program called
-     Program.js and adding a call to class method #main in class Hello:
-
-        amberc -m Hello Hello.st Program
-
-     Compile two .st files into corresponding .js files,
-     and link with specific myboot.js, myKernel.js, myinit.js
-     and main.js and create complete program called Program.js:
-
-        amberc -M main.js myinit.js myboot.js myKernel.js Cat1.st Cat2.st Program
-
-ENDOFHELP
-	exit 1;
-}
-
-# Check we at least got one argument
-if [ -z $1 ] ; then
-   usage
-fi
-
-# Define our predefined library combinations
-KERNEL="boot Kernel-Objects Kernel-Classes Kernel-Methods Kernel-Collections Kernel-Exceptions Kernel-Transcript Kernel-Announcements"
-COMPILER="$KERNEL parser Compiler Compiler-Exceptions"
-
-# Predefined initializer
-INITIALIZER="$AMBER/js/init.js"
-
-# Default values
-ENV=
-INIT=$INITIALIZER
-MAIN=
-MAINFILE=
-BASE=$KERNEL
-LOAD=
-CLOSUREOPTS=
-# Ok, bad coding practice but hey, who would use such a suffix?
-SUFFIX=no-silly-suffix
-SUFFIXUSED=
-DEPLOY=false
-NODECOMPILE=nodecompile
-
-# Read options and shift them away
-while getopts "l:i:m:M:oOAds:S:h?" o; do
-case "$o" in
-   l) LOAD=$OPTARG;;
-   i) INIT=$OPTARG;;
-   m) MAIN=$OPTARG;;
-   M) MAINFILE=$OPTARG;;
-   o) CLOSURE=true
-      CLOSUREPARTS=true;;
-   O) CLOSURE=true
-      CLOSUREFULL=true;;
-   A) CLOSURE=true
-      CLOSUREOPTS="$CLOSUREOPTS --compilation_level ADVANCED_OPTIMIZATIONS"
-      CLOSUREFULL=true;;
-   d) DEPLOY=true;;
-   s) SUFFIX=$OPTARG
-      SUFFIXUSED=$SUFFIX;;
-   S) LOADSUFFIX=$OPTARG
-      SUFFIXUSED=$SUFFIX;;
-   h) usage;;
-   [?])  usage;;
-   esac
-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, -A or -o (Closure compiler)."
-   exit 1
-  fi
-fi
-
-# Function for looking up listed js files
-function resolvejs {
-  FNAME="$1$LOADSUFFIX.js"
-  if [ -f $FNAME ]; then
-    RESOLVED="$FNAME" 
-  else
-    if [ -f $AMBER/js/$FNAME ]; then
-      RESOLVED="$AMBER/js/$FNAME"
-    else
-      echo "Javascript file not found: $FNAME"
-      exit 1
-    fi
-  fi
-}
-
-# Resolve listed libraries in $BASE deparated by spaces
-for FILE in $BASE
-do
-   resolvejs $FILE
-   TOBASE="$TOBASE $RESOLVED"
-done
-
-# Resolve listed libraries in $LOAD separated by ,
-LOAD=${LOAD//,/\ }
-for FILE in $LOAD
-do
-   resolvejs $FILE
-   TOLOAD="$TOLOAD $RESOLVED"
-done
-
-# Resolve COMPILER
-for FILE in $COMPILER
-do
-   resolvejs $FILE
-   TOCOMPILER="$TOCOMPILER $RESOLVED"
-done
-
-# Add supplied libraries we have not already loaded (they are already resolved)
-#for FILE in $EXTRA
-#do
-#   resolvejs $FILE
-#   TOEXTRA="$TOEXTRA $RESOLVED"
-#done
-
-TOCOMPILER="$TOCOMPILER$TOLOAD"
-
-# Resolve init and nodecompile
-THEREST="init $AMBER/bin/$NODECOMPILE"
-for FILE in $THEREST
-do
-   resolvejs $FILE
-   TOCOMPILER="$TOCOMPILER $RESOLVED"
-done
-
-# Add supplied libraries
-LIBS="$TOBASE $TOLOAD"
-
-# Get a unique tempdir and make it get auto removed on exit
-TMPDIR=`mktemp -d amberc.XXXXXX 2>>/dev/null` ||\
-    TMPDIR=/tmp/amberc.$$.`date +%s` && mkdir -p $TMPDIR
-trap "rm -rf $TMPDIR" EXIT
-
-
-# --------------------------------------------------
-# Collect libraries and Smalltalk files looking
-# both locally and in $AMBER/js and $AMBER/st 
-# --------------------------------------------------
-PROGRAM=
-until [ "$*" = "" ]
-do
-  case $1 in
-     *.st)
-        CATEGORY=`basename $1 .st`
-        if [ -f "$1" ]; then
-           COMPILE="$COMPILE $1 $CATEGORY"
-           COMPILED="$COMPILED $CATEGORY$SUFFIXUSED.js"
-        else
-           if [ -f $AMBER/st/$1 ]; then
-             COMPILE="$COMPILE $AMBER/st/$1 $CATEGORY"
-             COMPILED="$COMPILED $CATEGORY$SUFFIXUSED.js"
-           else
-             echo "Amber file not found: $1"
-             exit 1
-           fi
-        fi
-        ;;
-
-     *.js)
-        resolvejs $1
-	LIBS="$LIBS $RESOLVED" 
-        ;;
-      *)
-        # Will end up being the last non js/st argument
-        PROGRAM=$1
-        ;;
-  esac
-  shift
-done
-
-# --------------------------------------------------
-# Actual compilation phase of collected .st files
-# --------------------------------------------------
-
-# Create compiler dynamically
-cat $TOCOMPILER > $TMPDIR/compiler.js
- 
-# Compile all collected .st files to .js
-echo "Loading libraries$TOCOMPILER and compiling ..."
-node $TMPDIR/compiler.js $DEPLOY $SUFFIX $COMPILE
-
-# Verify all .js files corresponding to .st files were created, otherwise exit
-IFS=" "
-for FILE in $COMPILED
-do
-  if [ ! -f "$FILE" ]; then
-    echo "Failed compilation of $FILE, exiting."
-    exit 1
-  fi 
-done
-
-if [ ! -z $CLOSUREPARTS ]; then
-  echo "Compiling all js files using Google closure compiler."
-
-  ALLJSFILES="$COMPILED $LIBS"
-  for FILE in $ALLJSFILES
-  do
-    mv $FILE $FILE.original
-    java -jar ~/compiler.jar $CLOSUREOPTS --js $FILE.original --js_output_file $FILE
-    rm $FILE.original
-  done
-fi
-
-
-if [ -z $PROGRAM ]; then
-  echo "Done."
-  exit 0
-fi
-
-# --------------------------------------------------
-# Now we start composing resulting javascript file.
-# --------------------------------------------------
-
-# Add collected libraries to libs.js file.
-if [ ! -z "$LIBS" ]; then
-  echo "Adding libraries $LIBS ..."
-  cat $LIBS > $TMPDIR/libs.js
-  LIBS=$TMPDIR/libs.js
-fi
-
-echo "Adding Amber code$COMPILED ..."
-
-# Check for init file
-if [ ! -z "$INIT" ]; then
-   if [ -f "$INIT" ]; then
-      echo "Adding initializer $INIT ..."
-   else
-      echo "Can not find init file $INIT, exiting."
-      exit 1
-   fi 
-fi
-
-# Check for adding main
-if [ ! -z "$MAIN" ]; then
-  echo "Adding call to $MAIN class >> main ..."
-  echo "smalltalk.$MAIN._main()" > $TMPDIR/main.js
-  MAIN=$TMPDIR/main.js
-fi
-
-# Check for adding main file
-if [ ! -z "$MAINFILE" ]; then
-   if [ -f "$MAINFILE" ]; then
-      echo "Adding main as $MAINFILE ..."
-   else
-      echo "Can not find main file $MAINFILE, exiting."
-      exit 1
-   fi 
-   MAIN=$MAINFILE
-fi
-
-# And finally concatenate Program.js
-echo "Writing $PROGRAM.js ..."
-cat $LIBS $COMPILED $INIT $MAIN > $PROGRAM.js
-echo "Done."
-
-
-if [ ! -z $CLOSUREFULL ]; then
-  echo "Compiling $PROGRAM.js file using Google closure compiler."
-  mv $PROGRAM.js $PROGRAM.js.original
-  java -jar ~/compiler.jar $CLOSUREOPTS --js $PROGRAM.js.original --js_output_file $PROGRAM.js
-  rm $PROGRAM.js.original
-  echo "Done."
-fi
-

+ 0 - 33
bin/nodecompile.js

@@ -1,33 +0,0 @@
-// NOTE: This code is called using the amberc bash script - do not use directly.
-// The arguments variable is a series of .st filenames and category names.
-// If it is a .st file we import it, if it is a category name we export it
-// as aCategoryName.js.
-var util = require('util'), fs = require('fs');
-
-// Only care about our arguments, strip away node, all.js and debug flag.
-var arguments = process.argv.splice(4);
-
-// First argument is also produce deploy files: "true" or "false"
-var deploy = (process.argv[2] == "true");
-
-// Second argument is suffix: "no-silly-suffix" means none
-suffix = process.argv[3];
-if (suffix == "no-silly-suffix") {
-  suffix = "";
-}
-
-// If it ends with .st, import it, otherwise export category as .js
-arguments.forEach(function(val, index, array) {
-  if (/\.st/.test(val)) {
-    util.puts("Reading file " + val);
-    code = fs.readFileSync(val, "utf8");
-    smalltalk.Importer._new()._import_(code._stream());
-  } else {
-    util.puts("Exporting " + (deploy ? "(debug + deploy)" : "(debug)") + " category "
-		+ val + " as " + val + suffix + ".js" + (deploy ? " and " + val + suffix + ".deploy.js" : ""));
-    fs.writeFileSync(val + suffix + ".js", smalltalk.Exporter._new()._exportPackage_(val));
-    if (deploy) {
-	fs.writeFileSync(val + suffix + ".deploy.js", smalltalk.StrippedExporter._new()._exportPackage_(val));
-    }
-  }
-});

+ 34 - 15
grunt.js

@@ -5,10 +5,7 @@ module.exports = function(grunt) {
   grunt.loadNpmTasks('grunt-image-embed');
   grunt.loadNpmTasks('grunt-contrib-mincss');
 
-  grunt.registerTask('build:deploy', 'shell:compileDeploy concat:deploy min');
-  grunt.registerTask('build:dev', 'shell:compileDev concat:css imageEmbed mincss css2js concat:dev');
-//  grunt.registerTask('default', 'build:deploy build:dev');
-  grunt.registerTask('default', 'amberc');
+  grunt.registerTask('default', 'pegjs amberc:all');
 
   grunt.initConfig({
     pkg: '<json:package.json>',
@@ -22,7 +19,7 @@ module.exports = function(grunt) {
         src: 'js/parser.pegjs',
         dest: 'js/parser.js',
         trackLineAndColumn: true,
-        cache: false,
+        cache: true,
         export_var: 'smalltalk.parser'
       }
     },
@@ -32,6 +29,18 @@ module.exports = function(grunt) {
         amber_dir: process.cwd(),
         closure_jar: ''
       },
+      all: {
+        working_dir: 'st',
+        target_dir : 'js',
+        src: ['Kernel-Objects.st', 'Kernel-Classes.st', 'Kernel-Methods.st', 'Kernel-Collections.st',
+              'Kernel-Exceptions.st', 'Kernel-Transcript.st', 'Kernel-Announcements.st',
+              'Importer-Exporter.st', 'Compiler-Exceptions.st', 'Compiler-Core.st', 'Compiler-AST.st',
+              'Compiler-IR.st', 'Compiler-Inlining.st', 'Compiler-Semantic.st',
+              'Canvas.st', 'SUnit.st', 'IDE.st',
+              'Kernel-Tests.st', 'Compiler-Tests.st', 'SUnit-Tests.st'
+              ],
+        deploy: true
+      },
       amber_kernel: {
         working_dir: 'st',
         target_dir : 'js',
@@ -42,7 +51,7 @@ module.exports = function(grunt) {
       amber_compiler: {
         working_dir: 'st',
         target_dir : 'js',
-        src: ['Importer-Exporter.st', 'Compiler.st', 'Compiler-Exceptions.st', 'Compiler-Core.st', 'Compiler-AST.st',
+        src: ['Importer-Exporter.st', 'Compiler-Exceptions.st', 'Compiler-Core.st', 'Compiler-AST.st',
               'Compiler-IR.st', 'Compiler-Inlining.st', 'Compiler-Semantic.st'],
         output_name: 'Compiler',
         deploy: true
@@ -56,25 +65,34 @@ module.exports = function(grunt) {
       amber_IDE: {
         working_dir: 'st',
         target_dir : 'js',
-        src: ['IDE.st', 'Documentation.st'],
+        src: ['IDE.st'],
         libraries: ['Canvas'],
         deploy: true
       },
       amber_tests: {
         working_dir: 'st',
         target_dir : 'js',
-        src: ['Kernel-Tests.st', 'Compiler-Tests.st'],
+        src: ['Kernel-Tests.st', 'Compiler-Tests.st', 'SUnit-Tests.st'],
         libraries: ['SUnit']
       },
+      amber_test_runner: {
+        working_dir: 'test',
+        src: ['Test.st'],
+        libraries: [
+        'Compiler-Exceptions', 'Compiler-Core', 'Compiler-AST',
+        'Compiler-IR', 'Compiler-Inlining', 'Compiler-Semantic', 'Compiler-Interpreter', 'parser',
+        'SUnit',
+        'Kernel-Tests', 'Compiler-Tests', 'SUnit-Tests'],
+        output_name: 'run'
+      },
       amber_dev: {
         working_dir: 'js',
-        src: ['Kernel-Objects.js', 'Kernel-Classes.js', 'Kernel-Methods.js', 'Kernel-Collections.js',
-              'Kernel-Exceptions.js', 'Kernel-Transcript.js', 'Kernel-Announcements.js',
-              'Compiler.js', 'Compiler-Exceptions.js', 'Compiler-Core.js', 'Compiler-AST.js',
+        src: [
+              'Compiler-Exceptions.js', 'Compiler-Core.js', 'Compiler-AST.js',
               'Compiler-IR.js', 'Compiler-Inlining.js', 'Compiler-Semantic.js',
-              'Kernel-Tests.js', 'Compiler-Tests.js',
-              'Canvas.js', 'IDE.js', 'SUnit.js', 'Documentation.js'],
-        output_name: 'amber_lib'
+              'Canvas.js', 'IDE.js', 'SUnit.js',
+              'Kernel-Tests.js', 'Compiler-Tests.js', 'SUnit-Tests.js'],
+        output_name: 'amber_dev'
       },
       server: {
         working_dir: 'server',
@@ -97,7 +115,7 @@ module.exports = function(grunt) {
       tests: ['test/*.js'],
       grunt: ['grunt.js', 'grunt/**/*.js']
     },
-
+/*
     concat: {
       deploy: {
         src: ['tmp/amber-compiled.deploy.js'],
@@ -154,6 +172,7 @@ module.exports = function(grunt) {
         dest: 'dist/amber-<%= pkg.version %>.deploy.min.js'
       }
     }
+*/
   });
 
   grunt.registerMultiTask('css2js', 'Embed CSS into JS', function() {

+ 0 - 8
repl/Makefile

@@ -1,8 +0,0 @@
-repl.js: REPL.st
-	../bin/amberc -m Repl -l Compiler-Core,Compiler-Exceptions,Compiler-AST,Compiler-IR,Compiler-Inlining,Compiler-Semantic,parser REPL.st amber
-
-run: repl.js
-	../bin/amber
-
-clean:
-	rm -f amber.js REPL.js

+ 0 - 8
server/Makefile

@@ -1,8 +0,0 @@
-server.js: FileServer.st
-	../bin/amberc -m FileServer FileServer.st server
-
-run: server.js
-	./server
-
-clean:
-	rm -f FileServer.js

+ 0 - 129
st/Makefile

@@ -1,129 +0,0 @@
-#
-# This Makefile takes .st files in the amber/st directory and produces compiled
-# javascript files from them, for both debug and deployment.
-#
-# Where we find the current runnable code and where we put our js files on install
-JS      := ../js/
-
-# The compiler script
-AMBERC  := ../bin/amberc
-
-# Generic flags to AMBERC
-FLAGS   := -d
-
-# All corresponding js filenames for every st file available
-# In other words, if we have Kernel.st and Compiler.st, then OBJECTS will be "Kernel.js Compiler.js"
-OBJECTS := $(patsubst %.st,%.js,$(wildcard *.st))
-
-# Default make target since it is the first target in this Makefile
-all: $(OBJECTS)
-
-# Step by step
-#
-# First we copy the core javascript files from current working files
-# into this directory. These files are hand written or generated using
-# other tools (parser.js). $@ is the target name.
-boot.js init.js:
-	cp ../js/$@ .
-
-# generate the parser
-# $@ is the target
-# $< is the prerequisite
-parser.js: ../js/parser.pegjs
-	pegjs --track-line-and-column --cache -e smalltalk.parser $< $@
-
-# Then we compile Kernel-*.st files depending on having boot.js, init.js and parser.js
-# $< means the first dependency - in other words Kernel-*.st
-Kernel-Objects.js: Kernel-Objects.st boot.js init.js parser.js
-	$(AMBERC) $(FLAGS) $<
-
-Kernel-Classes.js: Kernel-Classes.st boot.js init.js parser.js
-	$(AMBERC) $(FLAGS) $<
-
-Kernel-Methods.js: Kernel-Methods.st boot.js init.js parser.js
-	$(AMBERC) $(FLAGS) $<
-
-Kernel-Collections.js: Kernel-Collections.st boot.js init.js parser.js
-	$(AMBERC) $(FLAGS) $<
-
-Kernel-Exceptions.js: Kernel-Exceptions.st boot.js init.js parser.js
-	$(AMBERC) $(FLAGS) $<
-
-Kernel-Transcript.js: Kernel-Transcript.st boot.js init.js parser.js
-	$(AMBERC) $(FLAGS) $<
-
-Kernel-Announcements.js: Kernel-Announcements.st boot.js init.js parser.js
-	$(AMBERC) $(FLAGS) $<
-
-# ...and Compiler, but using the new Kernel from above.
-# We only need to depend on Kernel js files since it in turn depends on boot.js etc
-Compiler.st: Importer-Exporter.st Compiler-Exceptions.st Compiler-Core.st \
-    Compiler-AST.st Compiler-Semantic.st Compiler-IR.st Compiler-Inlining.st \
-    Compiler-Interpreter.st
-	echo "Smalltalk current createPackage: 'Compiler' properties: #{}!" >$@
-	sed -e '/^Smalltalk current createPackage:.*!$$/ d' \
-      -e 's/package: '"'[^':]*'"'!/package:'"'Compiler'"'!/' \
-      -e 's/ methodsFor: '"'[^']*'"'!$$/ methodsFor: '"'"'*Compiler'"'"'!/' \
-      $^ >>$@
-
-Compiler.js: Compiler.st Kernel-Objects.js Kernel-Classes.js Kernel-Methods.js Kernel-Collections.js \
-	Kernel-Exceptions.js Kernel-Transcript.js
-	$(AMBERC) $(FLAGS) -l Importer-Exporter,Compiler-Exceptions,Compiler-Core,Compiler-AST,Compiler-Semantic,Compiler-IR,Compiler-Inlining $<
-
-# ...now that we have a new Kernel and Compiler we use them
-# to compile the rest of st files presuming that they only depend on Kernel, like
-# for example Canvas.js and Benchfib.js.
-%.js: %.st Compiler.js
-	$(AMBERC) $(FLAGS) $<
-
-# But for some libraries there are more dependencies to care for. Then
-# we need to use -l so that the compiler first loads that library
-# before compiling the .st file. Otherwise bindings will fail.
-#
-# NOTE: With the new dependency model in class Package etc this will change!
-#
-Canvas.js: Canvas.st Compiler.js
-	$(AMBERC) $(FLAGS) $<
-
-# IDE uses JQuery
-IDE.js: IDE.st Canvas.js Compiler.js
-	$(AMBERC) $(FLAGS) -l Canvas $<
-
-TrySmalltalk.js: TrySmalltalk.st IDE.js Compiler.js
-	$(AMBERC) $(FLAGS) -l Canvas,IDE $<
-
-# Some Examples use SUnit and also IDE
-Examples.js: Examples.st SUnit.js IDE.js Compiler.js
-	$(AMBERC) $(FLAGS) -l SUnit,Canvas,IDE $<
-
-# Tests typically also use SUnit
-Kernel-Tests.js: Kernel-Tests.st SUnit.js Compiler.js
-	$(AMBERC) $(FLAGS) -l SUnit $<
-
-Compiler-Tests.js: Compiler-Tests.st SUnit.js Compiler.js
-	$(AMBERC) $(FLAGS) -l SUnit $<
-
-SUnit-Tests.js: SUnit-Tests.st SUnit.js Compiler.js
-	$(AMBERC) $(FLAGS) -l SUnit $<
-
-# Documentation
-Documentation.js: Documentation.st Canvas.js Compiler.js
-	$(AMBERC) $(FLAGS) -l Canvas $<;
-
-#Helios
-Helios-Core.js: Helios-Core.st Canvas.js Compiler.js
-	$(AMBERC) $(FLAGS) -l Canvas $<;
-
-Helios-Browser.js: Helios-Browser.st Helios-Core.js Compiler.js
-	$(AMBERC) $(FLAGS) -l Helios-Core $<;
-
-# Installing is simply copying all js files to js directory.
-install: all
-	cp *.js $(JS)
-
-# And cleaning is trivial also
-clean:
-	rm -f *.js
-
-# These three are phony
-.PHONY: all install clean

+ 0 - 53
test/Test.deploy.js

@@ -1,53 +0,0 @@
-smalltalk.addPackage('Test', {});
-smalltalk.addClass('NodeTestRunner', smalltalk.Object, [], 'Test');
-
-smalltalk.addMethod(
-"_initialize",
-smalltalk.method({
-selector: "initialize",
-fn: function (){
-var self=this;
-smalltalk.send(self, "_runTestSuite", []);
-return self;}
-}),
-smalltalk.NodeTestRunner.klass);
-
-smalltalk.addMethod(
-"_runTestSuite",
-smalltalk.method({
-selector: "runTestSuite",
-fn: function (){
-var self=this;
-var $1,$2,$3;
-var suite;
-var worker;
-suite=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
-smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.TestCase || TestCase),"_allSubclasses",[]),"_select_",[(function(each){
-return smalltalk.send(smalltalk.send(each,"_isAbstract",[]),"_not",[]);
-})]),"_do_",[(function(each){
-return smalltalk.send(suite,"_addAll_",[smalltalk.send(each,"_buildSuite",[])]);
-})]);
-worker=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[suite]);
-smalltalk.send(smalltalk.send(worker,"_announcer",[]),"_on_do_",[(smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
-var result;
-result=smalltalk.send(ann,"_result",[]);
-result;
-$1=smalltalk.send(smalltalk.send(result,"_runs",[]),"__eq",[smalltalk.send(result,"_total",[])]);
-if(smalltalk.assert($1)){
-smalltalk.send(console,"_log_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_runs",[]),"_asString",[]),"__comma",[" tests run, "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_size",[]),"_asString",[])]),"__comma",[" failures, "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_size",[]),"_asString",[])]),"__comma",[" errors."])]);
-$2=smalltalk.send(smalltalk.send(result,"_failures",[]),"_isEmpty",[]);
-if(! smalltalk.assert($2)){
-smalltalk.send(self,"_throw_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_first",[]),"_class",[]),"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_first",[]),"_selector",[])]),"__comma",[" is failing!"])]);
-};
-$3=smalltalk.send(smalltalk.send(result,"_errors",[]),"_isEmpty",[]);
-if(! smalltalk.assert($3)){
-return smalltalk.send(self,"_throw_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_first",[]),"_class",[]),"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_first",[]),"_selector",[])]),"__comma",[" has errors!"])]);
-};
-};
-})]);
-smalltalk.send(worker,"_run",[]);
-return self}
-}),
-smalltalk.NodeTestRunner.klass);
-
-

+ 24 - 25
test/Test.js

@@ -1,4 +1,4 @@
-smalltalk.addPackage('Test', {});
+smalltalk.addPackage('Test');
 smalltalk.addClass('NodeTestRunner', smalltalk.Object, [], 'Test');
 
 smalltalk.addMethod(
@@ -8,10 +8,10 @@ selector: "initialize",
 category: 'not yet classified',
 fn: function (){
 var self=this;
-smalltalk.send(self, "_runTestSuite", []);
-return self;},
+return smalltalk.withContext(function($ctx1) { 
_st(self)._runTestSuite();
+return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.NodeTestRunner.klass)})},
 args: [],
-source: "initialize\x0d\x0a\x09self runTestSuite",
+source: "initialize\x0a\x09self runTestSuite",
 messageSends: ["runTestSuite"],
 referencedClasses: []
 }),
@@ -24,35 +24,34 @@ selector: "runTestSuite",
 category: 'not yet classified',
 fn: function (){
 var self=this;
-var $1,$2,$3;
-var suite;
-var worker;
-suite=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
-smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.TestCase || TestCase),"_allSubclasses",[]),"_select_",[(function(each){
-return smalltalk.send(smalltalk.send(each,"_isAbstract",[]),"_not",[]);
-})]),"_do_",[(function(each){
-return smalltalk.send(suite,"_addAll_",[smalltalk.send(each,"_buildSuite",[])]);
-})]);
-worker=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[suite]);
-smalltalk.send(smalltalk.send(worker,"_announcer",[]),"_on_do_",[(smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
+var suite,worker;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3;
+suite=_st((smalltalk.OrderedCollection || OrderedCollection))._new();
+_st(_st(_st((smalltalk.TestCase || TestCase))._allSubclasses())._select_((function(each){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(each)._isAbstract())._not();
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
return _st(suite)._addAll_(_st(each)._buildSuite());
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+worker=_st((smalltalk.TestSuiteRunner || TestSuiteRunner))._on_(suite);
+_st(_st(worker)._announcer())._on_do_((smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
 var result;
-result=smalltalk.send(ann,"_result",[]);
+return smalltalk.withContext(function($ctx2) {
result=_st(ann)._result();
 result;
-$1=smalltalk.send(smalltalk.send(result,"_runs",[]),"__eq",[smalltalk.send(result,"_total",[])]);
+$1=_st(_st(result)._runs()).__eq(_st(result)._total());
 if(smalltalk.assert($1)){
-smalltalk.send(console,"_log_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_runs",[]),"_asString",[]),"__comma",[" tests run, "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_size",[]),"_asString",[])]),"__comma",[" failures, "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_size",[]),"_asString",[])]),"__comma",[" errors."])]);
-$2=smalltalk.send(smalltalk.send(result,"_failures",[]),"_isEmpty",[]);
+_st(console)._log_(_st(_st(_st(_st(_st(_st(_st(result)._runs())._asString()).__comma(" tests run, ")).__comma(_st(_st(_st(result)._failures())._size())._asString())).__comma(" failures, ")).__comma(_st(_st(_st(result)._errors())._size())._asString())).__comma(" errors."));
+$2=_st(_st(result)._failures())._isEmpty();
 if(! smalltalk.assert($2)){
-smalltalk.send(self,"_throw_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_first",[]),"_class",[]),"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_first",[]),"_selector",[])]),"__comma",[" is failing!"])]);
+_st(self)._throw_(_st(_st(_st(_st(_st(_st(_st(result)._failures())._first())._class())._name()).__comma(" >> ")).__comma(_st(_st(_st(result)._failures())._first())._selector())).__comma(" is failing!"));
 };
-$3=smalltalk.send(smalltalk.send(result,"_errors",[]),"_isEmpty",[]);
+$3=_st(_st(result)._errors())._isEmpty();
 if(! smalltalk.assert($3)){
-return smalltalk.send(self,"_throw_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_first",[]),"_class",[]),"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_first",[]),"_selector",[])]),"__comma",[" has errors!"])]);
+return _st(self)._throw_(_st(_st(_st(_st(_st(_st(_st(result)._errors())._first())._class())._name()).__comma(" >> ")).__comma(_st(_st(_st(result)._errors())._first())._selector())).__comma(" has errors!"));
 };
 };
-})]);
-smalltalk.send(worker,"_run",[]);
-return self},
+}, function($ctx2) {$ctx2.fillBlock({ann:ann,result:result},$ctx1)})}));
+_st(worker)._run();
+return self}, function($ctx1) {$ctx1.fill(self,"runTestSuite",{suite:suite,worker:worker}, smalltalk.NodeTestRunner.klass)})},
 args: [],
 source: "runTestSuite\x0a\x09| suite worker |\x0a\x0a\x09suite := OrderedCollection new.\x0a    (TestCase allSubclasses select: [ :each | each isAbstract not ])\x0a\x09do: [ :each | suite addAll: each buildSuite ].\x0a\x0a\x09worker := TestSuiteRunner on: suite.\x0a\x09worker announcer on: ResultAnnouncement do:\x0a\x09[ :ann | | result |\x0a    \x09result := ann result.\x0a        result runs = result total ifTrue: [\x0a\x09        console log: result runs asString, ' tests run, ', result failures size asString, ' failures, ', result errors size asString, ' errors.'.\x0a\x0a            result failures isEmpty ifFalse: [\x0a                self throw: result failures first class name, ' >> ', result failures first selector, ' is failing!' ].\x0a            result errors isEmpty ifFalse: [\x0a                self throw: result errors first class name, ' >> ', result errors first selector, ' has errors!' ].\x0a    ]].\x0a    worker run",
 messageSends: ["new", "do:", "addAll:", "buildSuite", "select:", "not", "isAbstract", "allSubclasses", "on:", "on:do:", "result", "ifTrue:", "log:", ",", "asString", "size", "errors", "failures", "runs", "ifFalse:", "throw:", "selector", "first", "name", "class", "isEmpty", "=", "total", "announcer", "run"],