1syntax = "proto2";
2
3message VarRef {
4  required int32 varnum = 1;
5}
6
7message ArrType {
8    repeated Const elements = 1;
9}
10
11message KVPair {
12    required string key = 1;
13    required string val = 2;
14}
15
16message HashType {
17    repeated KVPair keyval = 1;
18}
19
20message StringExtNoArg {
21  enum StrExtOp {
22    DUMP = 0;
23    STRIP = 1;
24    LSTRIP = 2;
25    RSTRIP = 3;
26    STRIPE = 4;
27    LSTRIPE = 5;
28    RSTRIPE = 6;
29    SWAPCASE = 7;
30    SWAPCASEE = 8;
31    SQUEEZE = 9;
32  }
33  required StrExtOp str_op = 1;
34  required string str_arg = 2;
35}
36
37message MathConst {
38    enum MathConstLit {
39        PI = 0;
40        E = 1;
41    }
42    required MathConstLit math_const = 1;
43}
44
45message Const {
46    oneof const_oneof {
47        uint32 int_lit = 1;
48        bool bool_val = 4;
49    }
50}
51
52message BinaryOp {
53  enum Op {
54    ADD = 0;
55    SUB = 1;
56    MUL = 2;
57    DIV = 3;
58    MOD = 4;
59    XOR = 5;
60    AND = 6;
61    OR = 7;
62    EQ = 8;
63    NE = 9;
64    LE = 10;
65    GE = 11;
66    LT = 12;
67    GT = 13;
68    RS = 14;
69  };
70  required Op op = 1;
71  required Rvalue left = 2;
72  required Rvalue right = 3;
73}
74
75message Rvalue {
76  oneof rvalue_oneof {
77    VarRef varref = 1;
78    Const cons = 2;
79    BinaryOp binop = 3;
80  }
81}
82
83message AssignmentStatement {
84  required Rvalue rvalue = 2;
85}
86
87
88message IfElse {
89  required Rvalue cond = 1;
90  required StatementSeq if_body = 2;
91  required StatementSeq else_body = 3;
92}
93
94//TODO: Add Switch statement
95//message Switch {
96//    required Rvalue switch_var = 1;
97//    repeated Rvalue cond = 2;
98//}
99
100message Ternary {
101    required Rvalue tern_cond = 1;
102    required Rvalue t_branch = 2;
103    required Rvalue f_branch = 3;
104}
105
106message ObjectSpace {
107    enum OS_methods {
108        COUNT = 1;
109    }
110    required OS_methods os_func = 1;
111    required HashType os_arg = 2;
112}
113
114message Time {
115    enum T_methods {
116        AT = 1;
117        GM = 2;
118    }
119    required T_methods t_func = 1;
120    required uint32 t_arg = 2;
121}
122
123message Array {
124    enum Arr_methods {
125        FLATTEN = 1;
126        COMPACT = 2;
127        FETCH = 3;
128        FILL = 4;
129        ROTATE = 5;
130        ROTATE_E = 6;
131        DELETEIF = 7;
132        INSERT = 8;
133        BSEARCH = 9;
134        KEEPIF = 10;
135        SELECT = 11;
136        VALUES_AT = 12;
137        BLOCK = 13;
138        DIG = 14;
139        SLICE = 15;
140        PERM = 16;
141        COMB = 17;
142        ASSOC = 18;
143        RASSOC = 19;
144    }
145    required Arr_methods arr_func = 1;
146    required ArrType  arr_arg = 2;
147    required Rvalue   val_arg = 3;
148}
149
150message MathType {
151    oneof math_arg_oneof {
152        Rvalue math_rval = 2;
153        MathConst math_const = 3;
154    }
155}
156
157message MathOps {
158    enum Mops {
159      CBRT = 1;
160      COS = 2;
161      ERF = 3;
162      ERFC = 4;
163      LOG = 5;
164      LOG10 = 6;
165      LOG2 = 7;
166      SIN = 8;
167      SQRT = 9;
168      TAN = 10;
169    }
170    required Mops math_op = 1;
171    required MathType math_arg = 2;
172}
173
174message BuiltinFuncs {
175    oneof bifunc_oneof {
176        ObjectSpace os = 1;
177        Time time = 2;
178        Array arr = 3;
179        MathOps mops = 4;
180    }
181}
182
183message Statement {
184  oneof stmt_oneof {
185    AssignmentStatement assignment = 1;
186    IfElse              ifelse     = 2;
187    Ternary             ternary_stmt = 3;
188    BuiltinFuncs        builtins = 4;
189    StatementSeq        blockstmt = 5;
190  }
191}
192
193message StatementSeq {
194  repeated Statement statements = 1;
195}
196
197message Function {
198  required StatementSeq statements = 1;
199}
200
201package ruby_fuzzer;
202