Skip to content

Instantly share code, notes, and snippets.

@run-dlang
Created May 30, 2023 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save run-dlang/5dd783c750f04329405af1b1e4a83cde to your computer and use it in GitHub Desktop.
Save run-dlang/5dd783c750f04329405af1b1e4a83cde to your computer and use it in GitHub Desktop.
Code shared from run.dlang.io.
module parser.definitions.attributes;
import std.sumtype;
struct ConstantValue
{
ushort constantvalue_index;
}
struct ExceptionTable
{
ushort start_pc;
ushort end_pc;
ushort handler_pc;
ushort catch_type;
}
struct Code
{
ushort max_stack;
ushort max_locals;
ubyte[] code;
ExceptionTable[] exception_table;
Attribute[] attributes;
}
/*
————————————————————————————————————————————————————————————————————————————
VerificationTypeInfo &&& StackMapFrame.
————————————————————————————————————————————————————————————————————————————
*/
struct Top
{
}
struct Integer
{
}
struct Float
{
}
struct Null
{
}
struct UninitializedThis
{
}
struct Object
{
ushort cpool_index;
}
struct UninitializedVariable
{
ushort offset;
}
struct Long
{
}
struct Double
{
}
alias VerificationTypeInfo = SumType!(
Top,
Integer,
Float,
Null,
UninitializedThis,
Object,
UninitializedVariable,
Long,
Double
);
struct Same
{
}
struct SameLocals1StackItem
{
VerificationTypeInfo stack;
}
struct SameLocals1StackItemExt
{
ushort offset_delta;
VerificationTypeInfo stack;
}
struct Chop
{
ushort offset_delta;
}
struct SameExt
{
ushort offset_delta;
}
struct Append
{
ushort offset_delta;
VerificationTypeInfo[] locals;
}
struct Full
{
ushort offset_delta;
VerificationTypeInfo[] locals;
VerificationTypeInfo[] stack;
}
alias StackMapFrame = SumType!(
Same,
SameLocals1StackItem,
SameLocals1StackItemExt,
Chop,
SameExt,
Append,
Full
);
// —————————————————————————————————————————————————————————————————————————————
struct StackMapTable
{
StackMapFrame[] entries;
}
struct Exceptions
{
ushort[] exception_table_index;
}
struct InnerClass
{
ushort inner_class_info_index;
ushort outer_class_info_index;
ushort inner_name_index;
ushort inner_class_access_flags;
}
struct InnerClasses
{
InnerClass[] classes;
}
struct EnclosingMethod
{
ushort class_index;
ushort method_index;
}
struct Synthetic
{
}
struct Signature
{
ushort signature_index;
}
struct SourceFile
{
ushort sourcefile_index;
}
struct SourceDebugExtension
{
ubyte[] debug_extension;
}
struct LineNumber
{
ushort start_pc;
ushort line_number;
}
struct LineNumberTable
{
LineNumber[] line_number_table;
}
struct LocalVariable
{
ushort start_pc;
ushort length;
ushort name_index;
ushort descriptor_index;
ushort index;
}
struct LocalVariableTable
{
LocalVariable[] local_variable_table;
}
struct LocalVariableType
{
ushort start_pc;
ushort length;
ushort name_index;
ushort signature_index;
ushort index;
}
struct LocalVariableTypeTable
{
LocalVariableType[] local_variable_type_table;
}
struct Deprecated
{
}
/*
————————————————————————————————————————————————————————————————————————————
Runtime Annotations
————————————————————————————————————————————————————————————————————————————
*/
/*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Element Value
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*/
struct ConstValueIndex
{
ushort const_value_index;
}
struct EnumConstValue
{
ushort type_name_index;
ushort const_name_index;
}
struct ClassInfoIndex
{
ushort class_info_index;
}
struct AnnotationValue
{
Annotation annotation_value;
}
struct ArrayValue
{
ElementValue[] values;
}
alias ElementValue = SumType!(
ConstValueIndex,
EnumConstValue,
ClassInfoIndex,
AnnotationValue,
ArrayValue,
);
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
struct ElementValuePair
{
ushort index;
ElementValue element_value;
}
struct Annotation
{
ElementValuePair[] pairs;
}
struct RuntimeVisibleAnnotations
{
Annotation[] annotations;
}
// —————————————————————————————————————————————————————————————————————————————
alias Attribute = SumType!(
ConstantValue,
Code,
StackMapTable,
Exceptions,
InnerClasses,
EnclosingMethod,
Synthetic,
Signature,
SourceFile,
LineNumberTable,
LocalVariableTable,
LocalVariableTypeTable,
Deprecated
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment