X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=idlcomp%2Ftypes.cc;h=623b57607f0937bc96fe3f1842052b3abcee5a92;hb=ed94ee97c9872c957efa4790c4ea073f371262a6;hp=75597f2afa1b966e531019e883c9a016accd41ad;hpb=7da27a216a7f4bb3331fe315cdbec69bfcf2c762;p=polintos%2Fscott%2Fpriv.git diff --git a/idlcomp/types.cc b/idlcomp/types.cc index 75597f2..623b576 100644 --- a/idlcomp/types.cc +++ b/idlcomp/types.cc @@ -1,7 +1,16 @@ -/* types.cc -- Semantic actions for types and namespaces. - * - * Written by Scott Wood - */ +// Semantic actions for types and namespaces +// +// This software is copyright (c) 2006 Scott Wood . +// +// 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 #include @@ -311,7 +320,8 @@ void Datum::final_analysis() 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); } } @@ -338,6 +348,45 @@ void Struct::add_elem(Datum *d) 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(d->type->get_concrete_sym()); + assert(type); + + if (dynamic_cast(type)) + goto complex; + + Struct *str = dynamic_cast(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)