Skip to content

Commit

Permalink
various fixes to get esc to parse its parser; start at refactoring th…
Browse files Browse the repository at this point in the history
…e back end

--HG--
branch : com.mozilla.es4.smlnj
extra : convert_revision : 5a7376fe326ddc38dfedc3ee8101c1a20bb19d7b
  • Loading branch information
jeffdyer committed Aug 28, 2007
1 parent 8fadb97 commit d45fa42
Show file tree
Hide file tree
Showing 20 changed files with 2,204 additions and 70 deletions.
24 changes: 13 additions & 11 deletions comp-esc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

### DECODE

./esc1.sh tests/self/debug.es
./esc1.sh tests/self/ast.es
./esc1.sh tests/self/decoder.es
./esc1.sh tests/self/encoder.es
./esc1.sh tests/self/esc2.es
#./esc1.sh tests/self/debug.es
#./esc1.sh tests/self/ast.es
#./esc1.sh tests/self/decoder.es
#./esc1.sh tests/self/encoder.es
#./esc1.sh tests/self/esc2.es

### PARSE

./esc1.sh tests/self/lex-char.es
./esc1.sh tests/self/lex-token.es
./esc1.sh tests/self/lex-scan.es
#./esc1.sh tests/self/lex-char.es
#./esc1.sh tests/self/lex-token.es
#./esc1.sh tests/self/lex-scan.es
#./esc1.sh tests/self/parse-util.es
#./esc1.sh tests/self/parse-ident.es
#./esc1.sh tests/self/parse-expr.es
#./esc1.sh tests/self/parse-ptrn.es
#./esc1.sh tests/self/parse-type.es
#./esc1.sh tests/self/parse-stmt.es
#./esc1.sh tests/self/parse-prgm.es
#./esc1.sh tests/self/esc1.es
./esc1.sh tests/self/parse-prgm.es
./esc1.sh tests/self/esc1.es

### GENERATE

Expand All @@ -48,7 +48,9 @@

### PARSE

#./esc2.sh tests/self/lexer.es
#./esc2.sh tests/self/lex-char.es
#./esc2.sh tests/self/lex-token.es
#./esc2.sh tests/self/lex-scan.es
#./esc2.sh tests/self/parser-util.es
#./esc2.sh tests/self/parser-identexpr.es
#./esc2.sh tests/self/parser-expr.es
Expand Down
42 changes: 42 additions & 0 deletions esc-env.ast
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,48 @@ var ast =
, { 'ast_class': 'NamespaceFixture'
, 'ns': { 'ast_class': 'AnonymousNamespace'
, 'name': 'Parse' } } ]
, [ { 'ast_class': 'PropName'
, 'name': { 'ns': { 'ast_class': 'PublicNamespace'
, 'name': '' }
, 'id': 'Lex' } }
, { 'ast_class': 'NamespaceFixture'
, 'ns': { 'ast_class': 'AnonymousNamespace'
, 'name': 'Lex' } } ]
, [ { 'ast_class': 'PropName'
, 'name': { 'ns': { 'ast_class': 'PublicNamespace'
, 'name': '' }
, 'id': 'Gen' } }
, { 'ast_class': 'NamespaceFixture'
, 'ns': { 'ast_class': 'AnonymousNamespace'
, 'name': 'Gen' } } ]
, [ { 'ast_class': 'PropName'
, 'name': { 'ns': { 'ast_class': 'PublicNamespace'
, 'name': '' }
, 'id': 'Util' } }
, { 'ast_class': 'NamespaceFixture'
, 'ns': { 'ast_class': 'AnonymousNamespace'
, 'name': 'Util' } } ]
, [ { 'ast_class': 'PropName'
, 'name': { 'ns': { 'ast_class': 'PublicNamespace'
, 'name': '' }
, 'id': 'Abc' } }
, { 'ast_class': 'NamespaceFixture'
, 'ns': { 'ast_class': 'AnonymousNamespace'
, 'name': 'Abc' } } ]
, [ { 'ast_class': 'PropName'
, 'name': { 'ns': { 'ast_class': 'PublicNamespace'
, 'name': '' }
, 'id': 'Asm' } }
, { 'ast_class': 'NamespaceFixture'
, 'ns': { 'ast_class': 'AnonymousNamespace'
, 'name': 'Asm' } } ]
, [ { 'ast_class': 'PropName'
, 'name': { 'ns': { 'ast_class': 'PublicNamespace'
, 'name': '' }
, 'id': 'Emit' } }
, { 'ast_class': 'NamespaceFixture'
, 'ns': { 'ast_class': 'AnonymousNamespace'
, 'name': 'Emit' } } ]
, ]
, 'exprs': [ ] }
, 'block': { 'ast_class': 'Block'
Expand Down
25 changes: 12 additions & 13 deletions esc-sanity.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#./esc.sh tests/self/hello.es
#/work/tamarin/bin/shell tests/self/hello.es.abc
#./esc1.sh tests/self/if.es
#/work/tamarin/bin/shell tests/self/if.es.abc
#./esc.sh tests/self/for.es
#/work/tamarin/bin/shell tests/self/for.es.abc
#./esc.sh tests/self/try.es
#/work/tamarin/bin/shell tests/self/try.es.abc
#./esc.sh tests/self/cls.es
#/work/tamarin/bin/shell tests/self/cls.es.abc
#./esc.sh tests/self/switch.es
#/work/tamarin/bin/shell tests/self/switch.es.abc
./esc.sh tests/self/hello.es
/work/tamarin/bin/shell tests/self/hello.es.abc
./esc1.sh tests/self/if.es
/work/tamarin/bin/shell tests/self/if.es.abc
./esc.sh tests/self/for.es
/work/tamarin/bin/shell tests/self/for.es.abc
./esc.sh tests/self/try.es
/work/tamarin/bin/shell tests/self/try.es.abc
./esc.sh tests/self/cls.es
/work/tamarin/bin/shell tests/self/cls.es.abc
./esc.sh tests/self/switch.es
/work/tamarin/bin/shell tests/self/switch.es.abc
./esc.sh tests/self/switchtype.es
/work/tamarin/bin/shell tests/self/switchtype.es.abc

6 changes: 4 additions & 2 deletions esc1.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cp $1 esc-tmp.es
make run-dumped FILE="tests/self/debug.es tests/self/util.es tests/self/util-es4ri.es tests/self/ast.es tests/self/decoder.es tests/self/encoder.es tests/self/lexer.es tests/self/parser.es tests/self/esc1.es"
make run-dumped FILE="tests/self/debug.es tests/self/util.es tests/self/util-es4ri.es tests/self/ast.es tests/self/decoder.es tests/self/encoder.es tests/self/lex-char.es tests/self/lex-token.es tests/self/lex-scan.es tests/self/parser.es tests/self/esc1.es"
cp esc-tmp.ast $1.1.ast
cp esc-tmp.ast $1.ast
rm esc-tmp.es
rm esc-tmp.ast
rm esc-tmp.ast


2 changes: 1 addition & 1 deletion esc2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cp $1.ast esc-tmp.ast
cp $1.ast $1.1.ast
make run-dumped FILE="tests/self/debug.es tests/self/ast.es tests/self/encoder.es tests/self/decoder.es tests/self/lexer.es tests/self/util.es tests/self/parser.es tests/self/util-es4ri.es esc-tmp.ast tests/self/esc2.es"
make run-dumped FILE="tests/self/debug.es tests/self/ast.es tests/self/encoder.es tests/self/decoder.es tests/self/util.es tests/self/util-es4ri.es esc-tmp.ast tests/self/esc2.es"
cp esc-tmp.ast $1.ast
cp esc-tmp.ast $1.2.ast
diff -s $1.1.ast $1.2.ast
4 changes: 0 additions & 4 deletions escp.sh

This file was deleted.

4 changes: 0 additions & 4 deletions run-cogentest.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export TESTNAME="hello-test"
make run FILE="tests/self/debug.es tests/self/ast.es tests/self/ast_encoder.es tests/self/util.es tests/self/util-es4ri.es tests/self/bytestream.es tests/self/abcfile.es tests/self/assembler.es tests/self/emitter.es tests/self/cogen-stmt.es tests/self/cogen-expr.es tests/self/cogen.es tests/self/cogen_test.es tests/self/cogen-driver.es"

#Uncomment below lines to run parser tests
#TESTNAME="esc-tmp"
#make run FILE="tests/self/debug.es tests/self/ast.es tests/self/ast_encoder.es tests/self/lexer.es tests/self/parser.es tests/self/util.es tests/self/util-es4ri.es tests/self/bytestream.es tests/self/abcfile.es tests/self/assembler.es tests/self/emitter.es tests/self/cogen-stmt.es tests/self/cogen-expr.es tests/self/cogen.es tests/self/esc-driver.es"

java -cp c:/hg/my-asc-working/lib/asc.jar macromedia.asc.embedding.Main -d -m $TESTNAME.es

/cygdrive/c/hg/my-tamarin-central/platform/win32/obj_8/shell/Release_Debugger/avmplus_s.exe $TESTNAME.abc
2 changes: 1 addition & 1 deletion run-esc.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cp $1 esc-tmp.es
make run-dumped FILE="tests/self/debug.es tests/self/ast.es tests/self/encoder.es tests/self/decoder.es tests/self/lexer.es tests/self/util.es tests/self/parser.es tests/self/util-es4ri.es tests/self/bytestream.es tests/self/abcfile.es tests/self/assembler.es tests/self/emitter.es tests/self/cogen-stmt.es tests/self/cogen-expr.es tests/self/cogen.es tests/self/esc.es"
make run-dumped FILE="tests/self/debug.es tests/self/ast.es tests/self/encoder.es tests/self/decoder.es tests/self/lex-char.es tests/self/lex-token.es tests/self/lex-scan.es tests/self/util.es tests/self/parser.es tests/self/util-es4ri.es tests/self/bytestream.es tests/self/abcfile.es tests/self/assembler.es tests/self/emitter.es tests/self/cogen-stmt.es tests/self/cogen-expr.es tests/self/cogen.es tests/self/esc.es"

cp esc-tmp.il $1.il
cp esc-tmp.abc $1.abc
Expand Down
1 change: 1 addition & 0 deletions tests/self/abcfile.es
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- mode: java; mode: font-lock; tab-width: 4; insert-tabs-mode: nil; indent-tabs-mode: nil -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
Expand Down
6 changes: 4 additions & 2 deletions tests/self/assembler.es
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- mode: java; mode: font-lock; tab-width: 4; insert-tabs-mode: nil; indent-tabs-mode: nil -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
Expand Down Expand Up @@ -128,6 +129,7 @@ package assembler
* depth.
* - Ditto for the scope depth, really.
*/

public class AVM2Assembler
{
const listify = true;
Expand Down Expand Up @@ -623,14 +625,14 @@ package assembler
}

private function stack(n) {
current_stack_depth += n;
current_stack_depth = current_stack_depth + n;
if (current_stack_depth > max_stack_depth) {
max_stack_depth = current_stack_depth;
}
}

private function scope(n) {
current_scope_depth += n;
current_scope_depth = current_scope_depth + n;
if (current_scope_depth > max_scope_depth)
max_scope_depth = current_scope_depth;
}
Expand Down
9 changes: 8 additions & 1 deletion tests/self/cogen-expr.es
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- mode: java; mode: font-lock; tab-width: 4; insert-tabs-mode: nil; indent-tabs-mode: nil -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
Expand Down Expand Up @@ -55,15 +56,21 @@
* calls the super class's "m" with "o" as the receiver (o must be of a reasonable type):
* 'callsuper' instruction
*/

package cogen
{
import util.*;
import abcfile.*;
import assembler.*;
import emitter.*;
use default namespace public;

/// use default namespace Gen;
/// use namespace Util;
/// use namespace Abc;
/// use namespace Asm;
/// use namespace Emit;
use namespace Ast;
use default namespace public;

function cgExpr(ctx, e) {
switch type (e) {
Expand Down
8 changes: 7 additions & 1 deletion tests/self/cogen-stmt.es
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- mode: java; mode: font-lock; tab-width: 4; insert-tabs-mode: nil; indent-tabs-mode: nil -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
Expand Down Expand Up @@ -40,8 +41,13 @@ package cogen
import util.*;
import abcfile.*;
import assembler.*;

use default namespace public;

/// use default namespace Gen;
/// use namespace Util;
/// use namespace Abc;
/// use namespace Asm;
/// use namespace Emit;
use namespace Ast;

function cgStmt(ctx, s) {
Expand Down
9 changes: 8 additions & 1 deletion tests/self/cogen.es
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- mode: java; mode: font-lock; tab-width: 4; insert-tabs-mode: nil; indent-tabs-mode: nil -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
Expand Down Expand Up @@ -35,17 +36,23 @@
*
* ***** END LICENSE BLOCK ***** */

/// namespace Gen;
package cogen
{
import util.*;
import abcfile.*;
import assembler.*;
import emitter.*;

/// use default namespace Gen;
/// use namespace Util;
/// use namespace Abc;
/// use namespace Asm;
/// use namespace Emit;
use namespace Ast;

/* Returns an ABCFile structure */
public function cg(tree: PROGRAM) {
/// function cg(tree: PROGRAM) {
var e = new ABCEmitter;
var s = e.newScript();
CTX.prototype = { "emitter": e, "script": s, "cp": e.constants };
Expand Down
8 changes: 6 additions & 2 deletions tests/self/encoder.es
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ namespace Encode;
: string {
let str = "\n";

/*
for ( ; n > 0; n-- ) {
str = str + " ";
}

*/
return str;
}

Expand Down Expand Up @@ -301,7 +302,7 @@ namespace Encode;
"{ 'ast_class': 'ReturnStmt'"
+ indent(nesting)
+ ", 'expr': "
+ expr (nd.expr,nesting+", 'expr': ".length)
+ exprOpt (nd.expr,nesting+", 'expr': ".length)
+ " }";
}
case (nd: ThrowStmt) {
Expand Down Expand Up @@ -436,6 +437,9 @@ namespace Encode;
+ "null" // for now: blockOpt (nd.finallyBlock,nesting+", 'finallyBlock': ".length)
+ " }";
}
case (nd: EmptyStmt) {
var str = "";
}
case (x: *) {
throw "error stmt " + nd;
}
Expand Down
Loading

0 comments on commit d45fa42

Please sign in to comment.