Flush mapper before pushing back a result of (virtual) method invocation. The static method call was already doing that.
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.vm4brwsr;
21 public static final int INTEGER = 0;
22 public static final int LONG = 1;
23 public static final int FLOAT = 2;
24 public static final int DOUBLE = 3;
25 public static final int REFERENCE = 4;
27 public static final int LAST = REFERENCE;
32 public static boolean isCategory2(final int varType) {
33 return (varType == LONG) || (varType == DOUBLE);
36 public static int fromStackMapType(final int smType) {
37 switch (smType & 0xff) {
38 case ByteCodeParser.ITEM_Integer:
39 return VarType.INTEGER;
40 case ByteCodeParser.ITEM_Float:
42 case ByteCodeParser.ITEM_Double:
43 return VarType.DOUBLE;
44 case ByteCodeParser.ITEM_Long:
46 case ByteCodeParser.ITEM_Null:
47 case ByteCodeParser.ITEM_InitObject:
48 case ByteCodeParser.ITEM_Object:
49 case ByteCodeParser.ITEM_NewObject:
50 return VarType.REFERENCE;
52 case ByteCodeParser.ITEM_Bogus:
53 /* unclear how to handle for now */
55 throw new IllegalStateException("Unhandled stack map type");
59 public static int fromConstantType(final byte constantTag) {
60 switch (constantTag) {
61 case ByteCodeParser.CONSTANT_INTEGER:
62 return VarType.INTEGER;
63 case ByteCodeParser.CONSTANT_FLOAT:
65 case ByteCodeParser.CONSTANT_LONG:
67 case ByteCodeParser.CONSTANT_DOUBLE:
68 return VarType.DOUBLE;
70 case ByteCodeParser.CONSTANT_CLASS:
71 case ByteCodeParser.CONSTANT_UTF8:
72 case ByteCodeParser.CONSTANT_UNICODE:
73 case ByteCodeParser.CONSTANT_STRING:
74 return VarType.REFERENCE;
76 case ByteCodeParser.CONSTANT_FIELD:
77 case ByteCodeParser.CONSTANT_METHOD:
78 case ByteCodeParser.CONSTANT_INTERFACEMETHOD:
79 case ByteCodeParser.CONSTANT_NAMEANDTYPE:
80 /* unclear how to handle for now */
82 throw new IllegalStateException("Unhandled constant tag");
86 public static int fromFieldType(final char fieldType) {
93 return VarType.INTEGER;
99 return VarType.DOUBLE;
102 return VarType.REFERENCE;
105 throw new IllegalStateException("Unhandled field type");
109 public static String toString(final int varType) {
111 case VarType.INTEGER: return "int";
112 case VarType.LONG: return "long";
113 case VarType.FLOAT: return "float";
114 case VarType.DOUBLE: return "double";
115 case VarType.REFERENCE: return "ref";
117 throw new IllegalStateException("Unhandled field type");