소스 검색

Merge pull request #21 from mkroehnert/grunt

All Node.js examples now work with latest Amber
Nicolas Petton 11 년 전
부모
커밋
20e8a284db

+ 36 - 41
nodejs/Gruntfile.js

@@ -4,47 +4,42 @@ module.exports = function(grunt) {
   grunt.registerTask('default', ['amberc:hello']);
 
   grunt.initConfig({
-    pkg: grunt.file.readJSON('package.json'),
-
-    amberc: {	
-		 _config: {
-			amber_dir: '../../vendor/amber',
-			closure_jar: ''
-		},
-		hello: {
-			working_dir: 'hello',
-			src: ['Hello.st'],
-			main_class: 'Hello',
-			output_name: 'Program'
-		 },
-		benchfib: {
-			working_dir: 'benchfib',
-			src: ['Benchfib.st'],
-			main_class: 'Benchfib',
-			output_name: 'Program'
-		},
-		meta: {
-			working_dir: 'meta',
-			src: ['MyScript.st'],
-			main_class: 'MyScript',
-			libraries: ['parser','Compiler'],
-			output_name: 'Program'
-		},
-		pystone: {
-			working_dir: 'pystone',
-			src: ['Pystone.st'],
-			main_class: 'Pystone',
-			output_name: 'Program'
-		},
-		trivialserver: {
-			working_dir: 'trivialserver',
-			src: ['TrivialServer.st'],
-			main_class: 'TrivialServer',
-			output_name: 'Program'
-		}
-
+    pkg: grunt.file.readJSON('../package.json'),
 
+    amberc: {
+      _config: {
+        amber_dir: '../vendor/amber',
+        closure_jar: ''
+      },
+      hello: {
+        src: ['hello/Hello.st'],
+        main_class: 'Hello',
+        output_name: 'hello/Program'
+      },
+      benchfib: {
+        src: ['benchfib/Benchfib.st'],
+        main_class: 'Benchfib',
+        output_name: 'benchfib/Program'
+      },
+      meta: {
+        src: ['meta/MyScript.st'],
+        main_class: 'MyScript',
+        libraries: [
+            'Importer-Exporter', 'Compiler-Exceptions', 'Compiler-Core', 'Compiler-AST',
+            'Compiler-IR', 'Compiler-Inlining', 'Compiler-Semantic', 'Compiler-Interpreter', 'parser'
+        ],
+        output_name: 'meta/Program'
+      },
+      pystone: {
+        src: ['pystone/Pystone.st'],
+        main_class: 'Pystone',
+        output_name: 'pystone/Program'
+      },
+      trivialserver: {
+        src: ['trivialserver/TrivialServer.st'],
+        main_class: 'TrivialServer',
+        output_name: 'trivialserver/Program'
       }
-    });
-
+    }
+  });
 }

+ 2 - 2
nodejs/README

@@ -1,6 +1,6 @@
-JTalk + Node.js = Awesomeness
+Amber + Node.js = Awesomeness
 =============================
-These are some experiments of using JTalk together with Node.js:
+These are some experiments of using Amber together with Node.js:
 
 hello           - Hello world example with a simple Makefile.
 benchfib        - Port of tinybenchmarks from Squeak.

+ 1 - 1
nodejs/benchfib/Benchfib.st

@@ -1,6 +1,6 @@
 Object subclass: #Benchfib
 	instanceVariableNames: ''
-	category: 'Benchfib'!
+	package: 'Benchfib'!
 
 !Benchfib class methodsFor: 'not yet classified'!
 

+ 1 - 0
nodejs/benchfib/benchfib

@@ -1 +1,2 @@
+#!/bin/bash
 time node Program.js $@

+ 1 - 1
nodejs/hello/Hello.st

@@ -1,6 +1,6 @@
 Object subclass: #Hello
         instanceVariableNames: ''
-        category: 'Hello'!
+        package: 'Hello'!
 
 !Hello class methodsFor: 'main'!
 

+ 1 - 0
nodejs/hello/hello

@@ -1 +1,2 @@
+#!/bin/bash
 node Program.js $@

+ 12 - 10
nodejs/meta/MyScript.st

@@ -1,6 +1,6 @@
 Object subclass: #MyScript
 	instanceVariableNames: ''
-	category: 'MyScript'!
+	package: 'MyScript'!
 
 !MyScript class methodsFor: 'main'!
 main
@@ -8,20 +8,22 @@ main
 	creating a class, compiling some methods and then exporting
 	this package in javascript format to stdout"
 
-	| klass compiler method |
+	| klass method |
+
+	console log: 'Creating new class #Dummy'.
+
 	Object subclass: #Dummy instanceVariableNames: '' package: 'Dummy'.
 	klass := Smalltalk current at: #Dummy.
-	compiler := Compiler new.
 
-	method := compiler load: 'foo ^10' forClass: klass.
-	method category: 'foo'.
-	klass addCompiledMethod: method.
+	console log: 'Add method #foo to class #Dummy'.
+	klass compile: 'foo ^10' category: 'foo'.
 
-	method := compiler load: 'bar ^ self foo * 2' forClass: klass.
-	method category: 'foo'.
-	klass addCompiledMethod: method.
+	console log: 'Add method #bar to class #Dummy'.
+	klass compile: 'bar ^ self foo * 2' category: 'foo'.
 
-	console log: (Exporter new exportPackage: 'Dummy')
+	console log: '--- Exported JavaScript for class #Dummy ---'.
+	console log: (Exporter new exportPackage: 'Dummy').
+	console log: '--- Exported JavaScript for class #Dummy End---'.
 ! !
 
 

+ 1 - 0
nodejs/meta/meta

@@ -1 +1,2 @@
+#!/bin/bash
 node Program.js $@

+ 0 - 8
nodejs/pystone/Makefile

@@ -1,8 +0,0 @@
-Program.js: Pystone.st
-	../../../bin/amberc -m Pystone Pystone.st Program
-
-run: Program.js
-	./pystone
-
-clean:
-	rm -f *.js

+ 1 - 1
nodejs/pystone/Pystone.st

@@ -1,6 +1,6 @@
 Object subclass: #PyStoneRecord
 	instanceVariableNames: 'ptrComp discr enumComp intComp stringComp'
-	category: 'Pystone'!
+	package: 'Pystone'!
 !PyStoneRecord commentStamp!
 Record class used in Pystone benchmark.!
 

+ 1 - 0
nodejs/pystone/pystone

@@ -1 +1,2 @@
+#!/bin/bash
 node Program.js $@

+ 1 - 1
nodejs/trivialserver/TrivialServer.st

@@ -1,6 +1,6 @@
 Object subclass: #TrivialServer
         instanceVariableNames: 'os http counter'
-        category: 'TrivialServer'!
+        package: 'TrivialServer'!
 
 !TrivialServer methodsFor: 'initializing'!
 initialize

+ 1 - 0
nodejs/trivialserver/trivial

@@ -1 +1,2 @@
+#!/bin/bash
 node Program.js $@