-
Notifications
You must be signed in to change notification settings - Fork 12
/
IDeclaration.java
115 lines (103 loc) · 3.48 KB
/
IDeclaration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*******************************************************************************
* Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors: Matthew Khouzam - Initial API and implementation
* Contributors: Simon Marchi - Initial API and implementation
*******************************************************************************/
package org.eclipse.tracecompass.ctf.core.event.types;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
/**
* A CTF data type declaration.
*
* An example: <br>
* int i = 0; <br>
* <b>int</b> is the declaration.<br>
* <b>i</b> is the definition.<br>
* <b>0</b> is the value assigned to the definition, not the declaration.<br>
*
* @version 1.0
* @author Matthew Khouzam
* @author Simon Marchi
*/
public interface IDeclaration {
/**
* Create a definition from this declaration
*
* @param definitionScope
* the definition scope, the parent where the definition will be
* placed
* @param fieldName
* the name of the definition
* @param input
* a bitbuffer to read from
* @return a reference to the definition
* @throws CTFException
* error in reading
*/
@NonNull Definition createDefinition(IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull BitBuffer input) throws CTFException;
/**
* Get the path of a definition
*
* @param definitionScope
* the scope of the definition
* @param fieldName
* the name of the definition
* @return the path of the definition
* @since 1.0
*/
@NonNull ILexicalScope getPath(IDefinitionScope definitionScope, @NonNull String fieldName);
/**
* The minimum alignment. if the field is 32 bits, the definition will pad
* all the data up to (position%32==0)
*
* @return the alignment in bits
*/
long getAlignment();
/**
* The MAXIMUM size of this declaration (in bits).
*
* @return the maximum size
*/
int getMaximumSize();
@Override
int hashCode();
@Override
boolean equals(Object other);
/**
* Are the two declarations equivalent on a binary level. eg: an 8 bit
* little endian and big endian int.
*
* @param other
* the other {@link IDeclaration}
* @return true if the binary CTF stream will generate the same value with
* the two streams
*/
boolean isBinaryEquivalent(IDeclaration other);
/**
* This method returns the role of a declaration
* @return the role of the declaration
* @since 4.3
*/
public default @Nullable String getRole() {
return null;
}
/**
* This method sets the role for a declaration
* @param role
* the new role for the declaration
* @since 4.3
*/
public default void setRole(String role) {}
}