public override void TryCatchBlock <T>(System.Action <T> body, System.Action <T> handler, LocalVariable exception, T block) { Label start = new Label(); Label end = new Label(); Label handle = new Label(); Label after = new Label(); _methodVisitor.visitTryCatchBlock(start, end, handle, byteCodeName(exception.Type())); _methodVisitor.visitLabel(start); body(block); _methodVisitor.visitLabel(end); _methodVisitor.visitJumpInsn(GOTO, after); //handle catch _methodVisitor.visitLabel(handle); _methodVisitor.visitVarInsn(ASTORE, exception.Index()); handler(block); _methodVisitor.visitLabel(after); }
public override void Assign(LocalVariable variable, Expression value) { value.Accept(_expressionVisitor); if (variable.Type().Primitive) { switch (variable.Type().name()) { case "int": case "byte": case "short": case "char": case "boolean": _methodVisitor.visitVarInsn(ISTORE, variable.Index()); break; case "long": _methodVisitor.visitVarInsn(LSTORE, variable.Index()); break; case "float": _methodVisitor.visitVarInsn(FSTORE, variable.Index()); break; case "double": _methodVisitor.visitVarInsn(DSTORE, variable.Index()); break; default: _methodVisitor.visitVarInsn(ASTORE, variable.Index()); break; } } else { _methodVisitor.visitVarInsn(ASTORE, variable.Index()); } }
public override void Load(LocalVariable variable) { if (variable.Type().Primitive) { switch (variable.Type().name()) { case "int": case "byte": case "short": case "char": case "boolean": _methodVisitor.visitVarInsn(ILOAD, variable.Index()); break; case "long": _methodVisitor.visitVarInsn(LLOAD, variable.Index()); break; case "float": _methodVisitor.visitVarInsn(FLOAD, variable.Index()); break; case "double": _methodVisitor.visitVarInsn(DLOAD, variable.Index()); break; default: _methodVisitor.visitVarInsn(ALOAD, variable.Index()); break; } } else { _methodVisitor.visitVarInsn(ALOAD, variable.Index()); } }