1 #include <ozulis/compiler.hh>
2 #include <ozulis/target-data.hh>
3 #include <ozulis/visitors/browser.hh>
4 #include <ozulis/visitors/sizeof.hh>
23 return Compiler::instance().targetData().findPointer()->size
;
26 #define CONST_SIZE_TYPE(Type_, Size) \
27 static void visit##Type_##Type(const ast::Node & /*node_*/, Sizeof & ctx) \
32 CONST_SIZE_TYPE(Pointer
, Sizeof::pointerSize())
33 CONST_SIZE_TYPE(Reference
, Sizeof::pointerSize())
34 CONST_SIZE_TYPE(Void
, 1)
35 CONST_SIZE_TYPE(Bool
, 1)
36 CONST_SIZE_TYPE(Float
, sizeof (float))
37 CONST_SIZE_TYPE(Double
, sizeof (double))
39 static void visitIntegerType(const ast::Node
& node_
, Sizeof
& ctx
)
41 const ast::IntegerType
& node
=
42 reinterpret_cast<const ast::IntegerType
&> (node_
);
43 ctx
.size
+= (node
.size
>> 3) + !!(node
.size
& 0x7);
49 #define REGISTER_METHOD(Class) \
50 registerMethod(ast::Class::nodeTypeId(), visit##Class)
52 REGISTER_METHOD(PointerType
);
53 REGISTER_METHOD(ReferenceType
);
54 REGISTER_METHOD(VoidType
);
55 REGISTER_METHOD(BoolType
);
56 REGISTER_METHOD(IntegerType
);
57 REGISTER_METHOD(FloatType
);
58 REGISTER_METHOD(DoubleType
);
60 completeWith
<ConstBrowser
<Sizeof
> >();