virtual void visit(VariableDeclaration &);
};
-/** Determines the size and alignment of a variable, in bytes. */
+/** Determines the size and alignment of a variable or a type, in bytes. */
class MemoryRequirementsCalculator: private NodeVisitor
{
public:
{
unsigned size;
unsigned alignment;
+ unsigned stride;
- Result(unsigned s, unsigned a): size(s), alignment(a) { }
+ Result(unsigned s, unsigned a): size(s), alignment(a), stride(s+a-1-(s+a-1)%a) { }
};
private:
unsigned r_size;
public:
Result apply(VariableDeclaration &v) { v.visit(*this); return Result(r_size, r_alignment); }
+ Result apply(TypeDeclaration &t) { t.visit(*this); return Result(r_size, r_alignment); }
private:
virtual void visit(BasicTypeDeclaration &);