1
0
mirror of https://github.com/danog/toncontest.git synced 2024-11-26 12:04:50 +01:00
Go to file
2019-10-17 15:41:43 +02:00
.vscode Implement moar 2019-10-07 21:18:40 +02:00
lib@6ecce5a9df add 2019-10-14 23:34:00 +02:00
lightning Update 2019-10-17 15:41:43 +02:00
test Update 2019-10-06 20:34:05 +02:00
toolchain Final test suite 2019-10-15 00:17:30 +02:00
wallet Commit 2019-10-15 16:17:12 +02:00
.gitignore Improve 2019-10-06 20:51:57 +02:00
.gitmodules First commit 2019-09-29 13:54:49 +02:00
README.md Update 2019-10-17 15:41:43 +02:00

Daniil Gentili entry

This is my entry for the TON contest.

Building

Simply run the build.sh script to automatically build tonlib and set up some simplified wrapper scripts.

toolchain/build.sh

This will automatically build the lite client, fift and func, and will also edit .bashrc to add some wrapper scripts to the PATH.

  • lite-client runs the lite client, already preconfigured to connect to the testnet, with db path set to $TONLIB_HOME/../ton-db-dir (aka this repo/ton-db-dir).
  • funcompile is a wrapper for the func compiler, automatically including the stdlib while compiling.
  • fift is a simple wrapper for the fift compiler.

Contents

// <type> <type>_atq(tuple t, int index) asm "INDEXVARQ";
AsmOp compile_tuple_atq(std::vector<VarDescr>& res, std::vector<VarDescr>& args) {
  assert(args.size() == 2 && res.size() == 1);
  auto& y = args[1];
  if (y.is_int_const() && y.int_const >= 0 && y.int_const < 16) {
    y.unused();
    return exec_arg_op("INDEXQ", y.int_const, 1, 1);
  }
  return exec_op("INDEXVARQ", 2, 1);
}

// ...

  define_builtin_func("int_atq", TypeExpr::new_map(TupleInt, Int), compile_tuple_atq);
  define_builtin_func("cell_atq", TypeExpr::new_map(TupleInt, Cell), compile_tuple_atq);
  define_builtin_func("slice_atq", TypeExpr::new_map(TupleInt, Cell), compile_tuple_atq);
  define_builtin_func("tuple_atq", TypeExpr::new_map(TupleInt, Tuple), compile_tuple_atq);
  define_builtin_func("atq", TypeExpr::new_forall({X}, TypeExpr::new_map(TupleInt, X)), compile_tuple_atq);

...as well as tuple set primitives (which I actually intended to implement in funC and use in a previous version of the wallet smart contract, then scrapped in favor of a simple dictionary).