33 lines
		
	
	
		
			627 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			627 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| function hello(arg) {
 | |
|   this.arg=arg;
 | |
|   this.act = {
 | |
|     main : function () {
 | |
|       log('Hello',this.arg);
 | |
|     },
 | |
|     more : function () {
 | |
|       log('World');
 | |
|       // throw error
 | |
|       function foo() {
 | |
|         return {}.x()
 | |
|       }
 | |
|       // try { foo() } catch (e) { log(e.toString()) }
 | |
|       foo()
 | |
|     },
 | |
|     end : function () {
 | |
|       log('Terminate');
 | |
|     }
 | |
|   }
 | |
|   this.trans = {
 | |
|     main : more,
 | |
|     more : end
 | |
|   }
 | |
|   this.on = {
 | |
|     // w/o handler agent will be terminated on error
 | |
|     error : function (err) { log('error',err,this.next) }
 | |
|   }
 | |
|   this.next='main';
 | |
| }
 | |
| compile(hello,{verbose:1});
 | |
| create('hello','You')
 | |
| start()
 |