Skip to content

Instantly share code, notes, and snippets.

@DarkDimius
Created February 17, 2017 16:14
Show Gist options
  • Save DarkDimius/eaed558f58b986ece94d481a1e9a7365 to your computer and use it in GitHub Desktop.
Save DarkDimius/eaed558f58b986ece94d481a1e9a7365 to your computer and use it in GitHub Desktop.
meta:
id: tasty
file-extension: tasty
endian: be
seq:
- id: magic
contents: [0x5C, 0xA1, 0xAB, 0x1F]
- id: major_version
type: Nat
- id: minor_version
type: Nat
- id: uuid
size: 16
- id: name_table_length
type: Nat
- id: name_table
type: NameTable
size: name_table_length.value
- id: sections
type: Section
repeat: eos
types:
Nat:
seq:
- id: groups
type: NatByte
repeat: until
repeat-until: not _.has_next
instances:
last:
value: groups.size - 1
value:
value: >-
groups[last].value
+ (last >= 1 ? (groups[last - 1].value << 7) : 0)
+ (last >= 2 ? (groups[last - 2].value << 14) : 0)
+ (last >= 3 ? (groups[last - 3].value << 21) : 0)
+ (last >= 4 ? (groups[last - 4].value << 28) : 0)
+ (last >= 5 ? (groups[last - 5].value << 35) : 0)
+ (last >= 6 ? (groups[last - 6].value << 42) : 0)
+ (last >= 7 ? (groups[last - 7].value << 49) : 0)
NatByte:
seq:
- id: b
type: u1
instances:
has_next:
value: (b & 128) == 0
value:
value: b & 0b0111_1111
NameTable:
seq:
- id: entries
type: NameT
repeat: eos
NameT:
seq:
- id: type
type: u1
enum: name_tag
- id: length
type: Nat
- id: body
size: length.value
type:
switch-on: type
cases:
name_tag::utf8 : Name_UTF8
name_tag::qualified : Name_Qualified
name_tag::signed : Name_Signed
name_tag::expanded : Name_Expanded
name_tag::objectclass : Name_ObjectClass
name_tag::superaccessor: Name_SuperAccessor
name_tag::defaultgetter: Name_Default_Getter
name_tag::shadowed : Name_Shadowed
Name_Ref:
seq:
- id: ref_id
type: Nat
instances:
value:
value: _root.name_table.entries[ref_id.value]
Name_UTF8:
seq:
- id: str
size-eos: true
type: str
encoding: UTF-8
Name_Qualified:
seq:
- id: qualified_ref
type: Name_Ref
- id: selector_ref
type: Name_Ref
Name_Signed:
seq:
- id: original_nameref
type: Name_Ref
- id: resultsig_nameref
type: Name_Ref
- id: paramsig_name
type: Name_Ref
repeat: eos
Name_Expanded:
seq:
- id: original_nameref
type: Name_Ref
Name_ObjectClass:
seq:
- id: object_nameref
type: Name_Ref
Name_SuperAccessor:
seq:
- id: accessed_nameref
type: Name_Ref
Name_Default_Getter:
seq:
- id: methodname
type: Name_Ref
- id: param_number
type: Name_Ref
Name_Shadowed:
seq:
- id: origial_nameref
type: Name_Ref
Section:
seq:
- id: name
type: Name_Ref
- id: length
type: Nat
- id: data
size: length.value
type:
switch-on: name.value.body.str
cases:
'"ASTs"' : Section_AST
'"Positions"' : Section_AST
Section_AST:
seq:
- id: trees
size-eos: true
enums:
name_tag:
1: utf8
2: qualified
3: signed
4: expanded
5: objectclass
6: superaccessor
7: defaultgetter
8: shadowed
ast_tag:
#costants
2: unit_const
3: false_const
4: true_const
5: null_const
#flags
6: private
7: internal
8: protected
9: abstract
10: final
11: sealed
12: case
13: implicit
14: lazy
15: override
16: inline
17: static
18: object
19: trait
20: local
21: synthetic
22: artifact
23: mutable
24: label
25: field_accessor
26: case_accessor
27: covariant
28: contravariant
29: scala2x
30: default_parameterized
31: in_supercall
32: stable
#types
64: shared
65: termref_direct
66: typeref_direct
67: termref_pkg
68: typeref_pkg
69: rec_this
70: byte_const
71: short_const
72: char_const
73: int_const
74: long_const
75: float_const
76: double_const
77: string_const
78: imported
79: renamed
# trees
112: ident
113: ident_tpt
114: select
115: select_tpt
116: termref_symbol
117: termref
118: typeref_symbol
119: typeref
120: selfdef
# skip
128: package
129: valdef
130: defdef
131: typedef
132: import
133: typeparam
134: params
#skip
136: param
137: apply
138: typeapply
139: typed
140: namedarg
141: assign
142: block
143: if
144: lambda
145: match
146: return
147: try
148: inlined
149: repeated
150: bind
151: alternative
152: unapply
153: annotated_type
154: annotated_tpt
155: casedef
156: template
157: super
158: super_type
159: refiend_type
160: refined_tpt
161: applied_type
162: applied_tpt
163: typebounds
164: typeboundstpt
165: typealias
166: and_type
167: and_tpt
168: or_type
169: or_tpt
170: method_type
171: poly_type
172: poly_tpt
173: param_type
174: annotation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment