<commit_before>#include "utility.hpp"
#include "steve/lower.hpp"
#include "steve/net.hpp"
#include "steve/builtin.hpp"
#include "steve/prelude.hpp"

#include <iostream>


inline Stmt*
statement(Decl const* d)
{
  return make_decl_stmt(d);
}


inline Stmt*
statement(Expr const* e)
{
  return make_expr_stmt(e);
}


Record_decl*
make_eth_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("type"),
  };

  return make_record("eth", mem);
}


// For testing nested field exprs
Record_decl*
make_ipv4_nested_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("protocol"),
    make_record_member("e", make_eth_header())
  };

  return make_record("ipv4", mem);
}


Record_decl*
make_ipv4_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("protocol"),
  };

  return make_record("ipv4", mem);
}


Record_decl*
make_ipv6_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("protocol"),
  };

  return make_record("ipv6", mem);
}


Record_decl*
make_tcp_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("port")
  };

  return make_record("tcp", mem);<commit_msg>official header impl<commit_after>#include "utility.hpp"
#include "steve/lower.hpp"
#include "steve/net.hpp"
#include "steve/builtin.hpp"
#include "steve/prelude.hpp"

#include <iostream>


inline Stmt*
statement(Decl const* d)
{
  return make_decl_stmt(d);
}


inline Stmt*
statement(Expr const* e)
{
  return make_expr_stmt(e);
}


Record_decl*
make_eth_header()
{
  Decl_seq mem {
    make_member("src", get_msbf_type(48)),
    make_member("dest", get_msbf_type(48)),
    make_member("type", get_msbf_type(16)),
  };

  return make_record("eth", mem);
}


// For testing nested field exprs
Record_decl*
make_ipv4_nested_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("protocol"),
    make_record_member("e", make_eth_header())
  };

  return make_record("ipv4", mem);
}


// For testing nested field exprs
Record_decl*
make_ipv4_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("protocol"),
  };

  return make_record("ipv4", mem);
}


Record_decl*
make_real_ipv4_header()
{
  Decl_seq mem {
    make_member("version", get_msbf_type(4)),
    make_member("ihl", get_msbf_type(4)),
    make_member("dscp", get_msbf_type(6)),
    make_member("len", get_msbf_type(16)),
    make_member("id", get_msbf_type(16)),
    make_member("flags", get_msbf_type(3)),
    make_member("frag", get_msbf_type(13)),
    make_member("ttl", get_msbf_type(8)),
    make_member("protocol", get_msbf_type(8)),
    make_member("checksum", get_msbf_type(16)),
    make_member("src", get_msbf_type(6)),
    make_member("dst", get_msbf_type(6)),
  };

  return make_record("ipv4", mem);
}


Record_decl*
make_ipv6_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("protocol"),
  };

  return make_record("ipv6", mem);
}


Record_decl*
make_tcp_header()
{
  Decl_seq mem {
    make_int_member("src"),
    make_int_member("dest"),
    make_int_member("port")
  };

  return make_record("tcp", mem);
{'fraction_non_alphanumeric': 0.15478312537136066, 'fraction_numerical': 0.0106951871657754, 'mean_word_length': 4.845486111111111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7016232', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1294, 'n_words': 206}