From 7f83dccd56b2e9c711f9cbc1a53502fd01a94798 Mon Sep 17 00:00:00 2001 From: Ken McMillan Date: Fri, 29 Jun 2018 12:10:21 -0700 Subject: [PATCH] working on quic_server_test --- ivy/include/1.7/udp_impl.ivy | 2 +- ivy/ivy_to_cpp.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ivy/include/1.7/udp_impl.ivy b/ivy/include/1.7/udp_impl.ivy index a662884..9bae14d 100644 --- a/ivy/include/1.7/udp_impl.ivy +++ b/ivy/include/1.7/udp_impl.ivy @@ -100,7 +100,7 @@ module udp_impl(host,pkt,ser,des) = { class udp_reader : public udp_task { std::vector buf; public: - udp_reader(int my_id, int sock, const udp_callbacks &cb, ivy_class *ivy) + udp_reader(`host` my_id, int sock, const udp_callbacks &cb, ivy_class *ivy) : udp_task(my_id, sock, cb, ivy) { } diff --git a/ivy/ivy_to_cpp.py b/ivy/ivy_to_cpp.py index 0206f84..dd0907d 100755 --- a/ivy/ivy_to_cpp.py +++ b/ivy/ivy_to_cpp.py @@ -974,7 +974,7 @@ def create_thunk(impl,actname,action,classname): params = [p for p in action.formal_params if p.name.startswith('prm:')] inputs = [p for p in action.formal_params if not p.name.startswith('prm:')] for p in params: - declare_symbol(impl,p) + declare_symbol(impl,p,classname=classname) impl.append(' ') emit_param_decls(impl,tc,params,extra = [ classname + ' *__ivy'],classname=classname) impl.append(': __ivy(__ivy)' + ''.join(',' + varname(p) + '(' + varname(p) + ')' for p in params) + '{}\n') @@ -1178,6 +1178,8 @@ def check_iterable_sort(sort): nt = native_type_full(im.module.native_types[sort.name]).strip() if nt in ['int','bool','long long']: return + if isinstance(sort,il.EnumeratedSort): + return raise iu.IvyError(None,"cannot iterate over non-integer sort {}".format(sort)) @@ -1189,7 +1191,11 @@ def open_loop(impl,vs,declare=True,bounds=None): bds = bounds[num] if bounds else ["0",str(sort_card(idx.sort))] vn = varname(idx.name) ct = 'long long ' if ctype(idx.sort) == 'long long' else 'int ' - impl.append('for ('+ (ct if declare else '') + vn + ' = ' + bds[0] + '; ' + vn + ' < ' + bds[1] + '; ' + vn + '++) {\n') + if isinstance(idx.sort,il.EnumeratedSort): + ct = ctype(idx.sort) + impl.append('for ('+ ((ct + ' ') if declare else '') + vn + ' = (' + ct + ')' + bds[0] + '; (int) ' + vn + ' < ' + bds[1] + '; ' + vn + ' = (' + ct + ')(((int)' + vn + ') + 1)) {\n') + else: + impl.append('for ('+ (ct if declare else '') + vn + ' = ' + bds[0] + '; ' + vn + ' < ' + bds[1] + '; ' + vn + '++) {\n') indent_level += 1 def close_loop(impl,vs):