Advertisement
tinyevil

Untitled

Jul 6th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. namespace foo{
  2.  
  3. struct Foo{ field x:Bar; }
  4. // is equivalent to
  5. invoke (c) => {
  6. let Foo = c->create_struct("Foo");
  7. Foo->set_definition((c) => {
  8. let x = c->add_field("x");
  9. x->set_type((c) => c->resolve_type("Bar"));
  10. });
  11. }
  12.  
  13.  
  14. function bar(x:i32):Foo{ return c(); }
  15. // is equivalent to
  16. invoke (c) => {
  17. let bar = c->create_function("bar");
  18. bar->set_signature((c) => {
  19. c->add_parameter("x", c->get_i32_type());
  20. c->set_return_type(c->resolve_type("Foo"));
  21. });
  22. bar->set_definition((c) => {
  23. c->create_return_statement(c->create_call(c->resolve_expr("c"), {}));
  24. });
  25. }
  26.  
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement