-
-
Save hansihe/3415d479cab84038341c42f93ae6e76b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def_type("test") => container(virtual: "true") { | |
virtual_field("tag", ref: "data", prop: "tag") => u8; | |
field("data") => union("test_union", ref: "../tag") { | |
variant("zero", match: "0") => u8; | |
variant("one", match: "1") => container { | |
field("woo") => u8; | |
field("hoo") => u8; | |
}; | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let test_fun = function (input) { | |
let count = 0; | |
let type_input_0 = input; | |
{ | |
var type_input_1 = type_input_0; | |
switch (type_input_1.tag) { | |
case "zero": { | |
var type_input_1 = 0; | |
break; | |
} | |
case "one": { | |
var type_input_1 = 1; | |
break; | |
} | |
} | |
{ | |
count = count + types["u8"]["size_of"](type_input_1); | |
} | |
var type_input_2 = type_input_0; | |
{ | |
switch (type_input_2.tag) { | |
case "zero": { | |
var type_input_3 = type_input_2.data; | |
{ | |
count = count + types["u8"]["size_of"](type_input_3); | |
} | |
break; | |
} | |
case "one": { | |
var type_input_4 = type_input_2.data; | |
{ | |
var type_input_5 = type_input_4["woo"]; | |
{ | |
count = count + types["u8"]["size_of"](type_input_5); | |
} | |
var type_input_6 = type_input_4["hoo"]; | |
{ | |
count = count + types["u8"]["size_of"](type_input_6); | |
} | |
} | |
break; | |
} | |
} | |
} | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment