Exemplo n.º 1
0
        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());
            }
        }
Exemplo n.º 2
0
        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());
            }
        }
Exemplo n.º 3
0
 public override void TryCatchBlock <T>(System.Action <T> body, System.Action <T> handler, LocalVariable exception, T block)
 {
     Indent().Append("try\n");
     Indent().Append("{\n");
     _levels.push(_level);
     body(block);
     _levels.pop();
     Indent().Append("}\n");
     Indent().Append("catch ( ").Append(exception.Type().fullName()).Append(" ").Append(exception.Name()).Append(" )\n");
     Indent().Append("{\n");
     _levels.push(_level);
     handler(block);
     _levels.pop();
     Indent().Append("}\n");
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public override void Assign(LocalVariable variable, Expression value)
 {
     Indent().Append(variable.Type().fullName()).Append(' ').Append(variable.Name()).Append(" = ");
     value.Accept(this);
     Append(";\n");
 }
Exemplo n.º 6
0
 public override void Declare(LocalVariable local)
 {
     Indent().Append(local.Type().fullName()).Append(' ').Append(local.Name()).Append(";\n");
 }