File: java_flags.h

package info (click to toggle)
libxtc-rats-java 1.15.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 18,580 kB
  • sloc: java: 288,962; ansic: 20,406; ml: 14,775; makefile: 1,358; cpp: 621; sh: 352; xml: 259; perl: 123
file content (120 lines) | stat: -rw-r--r-- 2,660 bytes parent folder | download
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
116
117
118
119
120
// java_flags.h            see license.txt for copyright and terms of use
// enumerated flags for parsing Java

// Basically, this module is a set of enums that are used by at
// least two different modules in the Java front end (if they
// were only used by one module, they'd be declared in that
// module instead).  It's intended to be a lightweight module,
// dependent on almost nothing else.
//
// Each enum has a 'toString' that yields a printable representation.
// If it yields 'char const *', then it's guaranteed to be a valid
// pointer with unchanging contents throughout execution.
//
// Those that are OR-able together have the necessary operators
// declared (ENUM_BITWISE_OPS), and their 'toString' uses bitwise-OR
// syntax.

#ifndef JAVA_FLAGS_H
#define JAVA_FLAGS_H

#include "srcloc.h"  // SourceLoc
#include "str.h"     // string

// Modifiers

enum Modifiers {
  MOD_NONE           = 0,
  MOD_PUBLIC         = 0x00000001,
  MOD_PROTECTED      = 0x00000002,
  MOD_PRIVATE        = 0x00000004,
  MOD_STATIC         = 0x00000008,
  MOD_ABSTRACT       = 0x00000010,
  MOD_FINAL          = 0x00000020,
  MOD_NATIVE         = 0x00000040,
  MOD_SYNCHRONIZED   = 0x00000080,
  MOD_TRANSIENT      = 0x00000100,
  MOD_VOLATILE       = 0x00000200,
  MOD_STRICTFP       = 0x00000400,
  ALL_MODIFIERS      = 0x000007FF,
  NUM_MODIFIERS      = 11
};

extern char const * const modifierNames[NUM_MODIFIERS];
string toString(Modifiers m);

// Binary operators

enum BinaryOperator {
  BIN_MULT,
  BIN_DIV,
  BIN_MOD,
  BIN_PLUS,
  BIN_MINUS,
  BIN_LSHIFT,
  BIN_RSHIFT,
  BIN_URSHIFT,
  BIN_LT,
  BIN_GT,
  BIN_LTEQ,
  BIN_GTEQ,
  BIN_INSTANCE,
  BIN_EQ,
  BIN_NOTEQ,
  BIN_BITAND,
  BIN_BITXOR,
  BIN_BITOR,
  BIN_AND,
  BIN_OR,
  BIN_ASSIGN,
  NUM_BINARY_OPS
};

inline bool isValid(BinaryOperator op) {
  return (unsigned)op < NUM_BINARY_OPS;
}
extern char const * const binaryOpNames[NUM_BINARY_OPS];   // "*", ..
char const *toString(BinaryOperator op);

// Unary operators

enum UnaryOperator {
  UN_PLUS,
  UN_MINUS,
  UN_PREINC,
  UN_PREDEC,
  UN_POSTINC,
  UN_POSTDEC,
  UN_BITNOT,
  UN_NOT,
  NUM_UNARY_OPS
};

inline bool isValid(UnaryOperator op) {
  return (unsigned)op < NUM_UNARY_OPS;
}
extern char const * const unaryOpNames[NUM_UNARY_OPS];
char const *toString(UnaryOperator op);

// Basic types

enum BasicType {
  TYPE_VOID,
  TYPE_BYTE,
  TYPE_SHORT,
  TYPE_CHAR,
  TYPE_INT,
  TYPE_LONG,
  TYPE_FLOAT,
  TYPE_DOUBLE,
  TYPE_BOOLEAN,
  NUM_TYPES
};

inline bool isValid(BasicType t) {
  return (unsigned)t < NUM_TYPES;
}
extern char const * const basicTypeNames[NUM_TYPES];
char const *toString(BasicType t);

#endif // JAVA_FLAGS_H