Browse Source

working on python generation

master
Michael Hamburg 9 years ago
parent
commit
1c97140893
1 changed files with 29 additions and 0 deletions
  1. +29
    -0
      test/test_templates.cxx

+ 29
- 0
test/test_templates.cxx View File

@@ -0,0 +1,29 @@
#include "decaf/expr.hxx"

class Foo {
private:
template<BinOp OP, class L, class R, class T> friend class BinExpr;
template<UnOp OP, class R, class T> friend class UnExpr;
template<class T> 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;
}

Loading…
Cancel
Save