home *** CD-ROM | disk | FTP | other *** search
- package espresso;
-
- class Try extends AST {
- Bits captured;
- Bits uninits;
- int excVarAdr = -1;
- LocalItem excVar;
- Label finalLabel = null;
- int endPc;
- int startPc;
- AST finalizer;
- FunDef[] catchers;
- AST body;
-
- void print(int var1) {
- System.out.print("try ");
- this.body.print();
-
- for(int var2 = 0; var2 < this.catchers.length; ++var2) {
- System.out.print(" catch");
- this.catchers[var2].print();
- }
-
- if (this.finalizer != null) {
- System.out.print(" finally ");
- this.finalizer.print();
- }
-
- }
-
- Item gen() {
- this.uninits = Gen.uninitSet();
- this.startPc = Gen.curPc();
- this.body.genDrop();
- this.endPc = Gen.curPc();
- this.finalisation();
- Label var1 = Gen.branch(167);
- if (this.catchers.length != 0 || this.finalizer != null) {
- this.excVar = new LocalItem(super.pos, Gen.newLocal(Predef.throwableTyp));
- }
-
- for(int var2 = 0; var2 < this.catchers.length; ++var2) {
- this.catchers[var2].genDrop();
- this.finalisation();
- var1 = Gen.mergeLabels(var1, Gen.branch(167));
- }
-
- if (this.finalizer != null) {
- Gen.entryPoint(1, this.uninits);
- Gen.registerCatch(this.startPc, Gen.curPc() - 3, Gen.curPc(), 0);
- this.excVar.store(Predef.throwableTyp);
- this.finalisation();
- this.excVar.load(Predef.throwableTyp);
- Gen.emitop(191);
- Gen.entryPoint(1);
- Gen.resolve(this.finalLabel);
- LocalItem var3 = new LocalItem(super.pos, Gen.newLocal(Predef.objectTyp));
- var3.store(Predef.objectTyp);
- this.genFinal();
- Gen.emitop1w(169, var3.disp);
- Gen.alive = false;
- }
-
- Gen.resolve(var1);
- return Item.voidItem;
- }
-
- void genFinal() {
- this.finalizer.genDrop();
- }
-
- void finalisation() {
- if (this.finalizer != null && Gen.alive) {
- this.finalLabel = new Label(Gen.curPc(), this.finalLabel, 1, Gen.uninitSet());
- Gen.emitJump(this.finalLabel, 168);
- }
-
- }
-
- AST simplify() {
- this.body = this.body.simplify();
-
- for(int var1 = 0; var1 < this.catchers.length; ++var1) {
- this.catchers[var1] = (FunDef)this.catchers[var1].simplify();
- }
-
- if (this.finalizer != null) {
- this.finalizer = this.finalizer.simplify();
- }
-
- return this;
- }
-
- void markCaptured(Bits var1) {
- this.body.markCaptured(var1);
- var1.orSet(this.captured);
- Bits var2 = var1.dup();
- Bits var3 = new Bits();
-
- for(int var4 = 0; var4 < this.catchers.length; ++var4) {
- var3.assign(var2);
- this.catchers[var4].markCaptured(var3);
- var1.orSet(var3);
- }
-
- if (this.finalizer != null) {
- this.finalizer.markCaptured(var1);
- }
-
- }
-
- Typ attr(Env var1, int var2, Typ var3) {
- super.typ = var3;
- Env var4 = new Env(var1, this);
-
- for(int var5 = 0; var5 < this.catchers.length; ++var5) {
- super.typ = Attr.join(this.catchers[var5].pos, super.typ, this.catchers[var5].attr(var4, 12, var3));
- }
-
- if (this.finalizer != null) {
- super.typ = Attr.join(this.finalizer.pos, super.typ, this.finalizer.attr(var4, 12, var3));
- }
-
- for(int var6 = 0; var6 < this.catchers.length; ++var6) {
- var4.reported = TypSet.incl(var4.reported, this.catchers[var6].params[0].obj.typ);
- }
-
- super.typ = this.body.attr(var4, 12, var3);
- return super.typ;
- }
-
- Try(int var1, AST var2, ASTS var3, AST var4) {
- super(var1, 18);
- this.body = var2;
- this.catchers = new FunDef[var3.length];
-
- for(int var5 = 0; var5 < var3.length; ++var5) {
- this.catchers[var5] = (FunDef)var3.elems[var5];
- }
-
- this.finalizer = var4;
- this.captured = new Bits();
- }
- }
-