• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 package com.android.tools.r8.ir.code;
5 
6 import com.android.tools.r8.errors.Unreachable;
7 
8 public enum ConstType {
9   INT,
10   LONG,
11   FLOAT,
12   DOUBLE,
13   OBJECT,
14   INT_OR_FLOAT,
15   LONG_OR_DOUBLE;
16 
fromNumericType(NumericType type)17   public static ConstType fromNumericType(NumericType type) {
18     switch (type) {
19       case BYTE:
20       case CHAR:
21       case SHORT:
22       case INT:
23         return INT;
24       case LONG:
25         return LONG;
26       case FLOAT:
27         return FLOAT;
28       case DOUBLE:
29         return DOUBLE;
30       default:
31         throw new Unreachable("Invalid numeric type '" + type + "'");
32     }
33   }
34 
fromMoveType(MoveType moveType)35   public static ConstType fromMoveType(MoveType moveType) {
36     switch (moveType) {
37       case SINGLE:
38         return INT_OR_FLOAT;
39       case WIDE:
40         return LONG_OR_DOUBLE;
41       case OBJECT:
42         // Currently constants never have type OBJECT even when it is the null object.
43         return INT;
44       default:
45         throw new Unreachable("Invalid move type '" + moveType + "'");
46     }
47   }
48 }
49