use oak_core::{ElementType, UniversalElementRole};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u16)]
pub enum JasmElementType {
RootToken,
ClassKw,
VersionKw,
MethodKw,
FieldKw,
StringKw,
SourceFileKw,
StackKw,
LocalsKw,
EndKw,
CompiledKw,
FromKw,
InnerClassKw,
NestMembersKw,
BootstrapMethodKw,
Public,
Private,
Protected,
Static,
Super,
Final,
Abstract,
Synchronized,
Native,
Synthetic,
Deprecated,
Varargs,
ALoad0,
ALoad1,
ALoad2,
ALoad3,
ILoad0,
ILoad1,
ILoad2,
ILoad3,
Ldc,
LdcW,
Ldc2W,
InvokeSpecial,
InvokeVirtual,
InvokeStatic,
InvokeInterface,
InvokeDynamic,
GetStatic,
PutStatic,
GetField,
PutField,
New,
CheckCast,
InstanceOf,
NewArray,
ANewArray,
ArrayLength,
AThrow,
MonitorEnter,
MonitorExit,
MultiANewArray,
IfNull,
IfNonNull,
Goto,
GotoW,
Jsr,
JsrW,
Ret,
TableSwitch,
LookupSwitch,
IReturn,
LReturn,
FReturn,
DReturn,
AReturn,
Return,
BiPush,
SiPush,
IInc,
Wide,
BreakPoint,
ImpDep1,
ImpDep2,
Nop,
Dup,
Pop,
LeftBrace,
RightBrace,
LeftBracket,
RightBracket,
LeftParen,
RightParen,
Comma,
Colon,
Semicolon,
Eq,
Dot,
Slash,
Identifier,
String,
Number,
Comment,
Whitespace,
Newline,
Eof,
Root,
Class,
Method,
Field,
Constant,
Attribute,
Instruction,
ExceptionHandler,
StackMapFrame,
InnerClass,
Annotation,
AnnotationParam,
AnnotationArray,
Error,
}
impl ElementType for JasmElementType {
type Role = UniversalElementRole;
fn role(&self) -> Self::Role {
use UniversalElementRole::*;
match self {
Self::Root => Root,
Self::Class => Definition,
Self::Method => Definition,
Self::Field => Definition,
_ => None,
}
}
}
impl From<crate::lexer::token_type::JasmTokenType> for JasmElementType {
fn from(token: crate::lexer::token_type::JasmTokenType) -> Self {
unsafe { std::mem::transmute(token) }
}
}