-/* types.cc -- Semantic actions for types and namespaces.
- *
- * Written by Scott Wood <scott@buserror.net>
- */
+// Semantic actions for types and namespaces
+//
+// This software is copyright (c) 2006 Scott Wood <scott@buserror.net>.
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors or contributors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is hereby granted to everyone, free of charge, to use, copy,
+// modify, prepare derivative works of, publish, distribute, perform,
+// sublicense, and/or sell copies of the Software, provided that the above
+// copyright notice and disclaimer of warranty be included in all copies or
+// substantial portions of this software.
#include <cfloat>
#include <sstream>
yyerrorfl(name->file, name->line,
"Explicit size %llu on \"%s\" is too small for "
"type \"%s\", which has a minimum size of %u",
- def.ucon, get_fq_name()->flatten()->c_str(),
+ (unsigned long long)def.ucon,
+ get_fq_name()->flatten()->c_str(),
type->get_fq_name()->flatten()->c_str(), defsize);
}
}
def.num_entries++;
}
+bool Struct::is_plain_data()
+{
+ if (!plain_data) {
+ plain_data = 1;
+ for (Struct::entries_iterator i = entries_begin(); i != entries_end(); ++i)
+ {
+ Datum *d = *i;
+ if (d->is_array() && !d->def.flags.field.Inline)
+ goto complex;
+
+ if (!d->type)
+ continue;
+
+ Type *type = dynamic_cast<Type *>(d->type->get_concrete_sym());
+ assert(type);
+
+ if (dynamic_cast<Interface *>(type))
+ goto complex;
+
+ Struct *str = dynamic_cast<Struct *>(type);
+ if (str) {
+ if (!d->def.flags.field.Inline)
+ goto complex;
+
+ // FIXME: check for inline struct loops
+ if (str->is_plain_data())
+ goto complex;
+ }
+ }
+ }
+
+ assert(plain_data == 1 || plain_data == 2);
+ return plain_data == 1;
+
+complex:
+ plain_data = 2;
+ return false;
+}
+
Param *Param::declare(const String *name, NameSpace *parent,
StrList *TYPE, CompiledParam::Flags flags,
Array *array)