blob: b197e93503ee7b8bceca98f248aa76dccd4ed22e [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001// Copyright (c) 2016, 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.
4package com.android.tools.r8.graph;
5
Benoit Lamarchedf98e682017-08-23 18:25:23 +02006import com.android.tools.r8.ApiLevelException;
Mads Ager418d1ca2017-05-22 09:35:49 +02007import com.android.tools.r8.dex.IndexedItemCollection;
8import com.android.tools.r8.dex.MixedSectionCollection;
9import com.android.tools.r8.errors.Unreachable;
10import com.android.tools.r8.ir.code.IRCode;
11import com.android.tools.r8.ir.optimize.Outliner.OutlineCode;
12import com.android.tools.r8.naming.ClassNameMapper;
13import com.android.tools.r8.utils.InternalOptions;
14
Lars Bak71143752017-08-16 13:28:44 +020015public abstract class Code extends CachedHashValueDexItem {
Mads Ager418d1ca2017-05-22 09:35:49 +020016
Benoit Lamarchedf98e682017-08-23 18:25:23 +020017 public abstract IRCode buildIR(DexEncodedMethod encodedMethod, InternalOptions options)
18 throws ApiLevelException;
Mads Ager418d1ca2017-05-22 09:35:49 +020019
20 public abstract void registerReachableDefinitions(UseRegistry registry);
21
Benoit Lamarche2aae3202017-10-11 11:01:06 +020022 @Override
Mads Ager418d1ca2017-05-22 09:35:49 +020023 public abstract String toString();
24
Ian Zerny4cd9db12017-06-23 13:46:28 +020025 public abstract String toString(DexEncodedMethod method, ClassNameMapper naming);
Mads Ager418d1ca2017-05-22 09:35:49 +020026
Ian Zerny282ffa82017-10-30 12:19:02 +010027 public boolean isCfCode() {
28 return false;
29 }
30
Mads Ager418d1ca2017-05-22 09:35:49 +020031 public boolean isDexCode() {
32 return false;
33 }
34
35 public boolean isJarCode() {
36 return false;
37 }
38
39 public boolean isOutlineCode() {
40 return false;
41 }
42
Stephan Herhut7fa3d1b2017-08-04 13:30:15 +020043 public int estimatedSizeForInlining() {
44 return Integer.MAX_VALUE;
45 }
46
Ian Zerny282ffa82017-10-30 12:19:02 +010047 public CfCode asCfCode() {
48 throw new Unreachable(getClass().getCanonicalName() + ".asCfCode()");
49 }
50
Mads Ager418d1ca2017-05-22 09:35:49 +020051 public DexCode asDexCode() {
Denis Vnukovfc2be5e2017-07-14 08:15:09 -070052 throw new Unreachable(getClass().getCanonicalName() + ".asDexCode()");
Mads Ager418d1ca2017-05-22 09:35:49 +020053 }
54
55 public JarCode asJarCode() {
Denis Vnukovfc2be5e2017-07-14 08:15:09 -070056 throw new Unreachable(getClass().getCanonicalName() + ".asJarCode()");
Mads Ager418d1ca2017-05-22 09:35:49 +020057 }
58
59 public OutlineCode asOutlineCode() {
Denis Vnukovfc2be5e2017-07-14 08:15:09 -070060 throw new Unreachable(getClass().getCanonicalName() + ".asOutlineCode()");
Mads Ager418d1ca2017-05-22 09:35:49 +020061 }
62
63 @Override
64 void collectIndexedItems(IndexedItemCollection collection) {
65 throw new Unreachable();
66 }
67
68 @Override
69 void collectMixedSectionItems(MixedSectionCollection collection) {
70 throw new Unreachable();
71 }
72}