From 1c971408939a7bfc7c494111fd6577096e0aa141 Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Thu, 7 Jan 2016 14:35:00 -0800 Subject: [PATCH] working on python generation --- test/test_templates.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/test_templates.cxx diff --git a/test/test_templates.cxx b/test/test_templates.cxx new file mode 100644 index 0000000..ef64d3d --- /dev/null +++ b/test/test_templates.cxx @@ -0,0 +1,29 @@ +#include "decaf/expr.hxx" + +class Foo { +private: + template friend class BinExpr; + template friend class UnExpr; + template friend struct Reify; + Foo(const NOINIT&) {} +public: + int x; + Foo(int x) : x(x) {} +}; + +namespace decaf { namespace internal { +DECLARE_BINOP(ADD,Foo,Foo,Foo,out.x = l.x+r.x) +DECLARE_BINOP(SUB,Foo,Foo,Foo,out.x = l.x-r.x) +DECLARE_BINOP(MUL,Foo,Foo,Foo,out.x = l.x*r.x) +DECLARE_BINOP(EQ,Foo,Foo,bool,out = l.x==r.x) +DECLARE_PARTIAL_UNOP(INV,Foo,Foo,out.x = 1/r.x; return (r.x!=0)) +}} + +Foo frobble() { + Foo a(1); + a = a+a+a; + a = a*a; + a = a/a; + (void)(a==(a+a)); + return a; +}