MemberAccess::MemberAccess():
- declaration(0)
+ declaration(0),
+ index(-1)
{ }
MemberAccess::MemberAccess(const MemberAccess &other):
Expression(other),
left(other.left),
member(other.member),
- declaration(0)
+ declaration(0),
+ index(-1)
{ }
void MemberAccess::visit(NodeVisitor &visitor)
BasicTypeDeclaration::BasicTypeDeclaration():
kind(ALIAS),
size(0),
+ sign(true),
base_type(0)
{ }
TypeDeclaration(other),
kind(other.kind),
size(other.size),
+ sign(other.sign),
base(other.base),
base_type(0)
{ }
InterfaceBlock::InterfaceBlock(const InterfaceBlock &other):
Statement(other),
interface(other.interface),
- name(other.name),
+ block_name(other.block_name),
members(other.members),
instance_name(other.instance_name),
array(other.array),
{ }
-string get_unused_variable_name(const Block &block, const string &base, const string &prefix_hint)
+string get_unused_variable_name(const Block &block, const string &base)
{
string name = base;
- bool prefixed = false;
unsigned number = 1;
- unsigned size_without_number = name.size();
- while(block.variables.count(name))
+ unsigned base_size = name.size();
+ while(1)
{
- if(!prefixed && !prefix_hint.empty())
- {
- if(name.front()!='_')
- name = "_"+name;
- name = prefix_hint+name;
- if(name.front()!='_')
- name = "_"+name;
- prefixed = true;
- size_without_number = name.size();
- }
- else
- {
- name.erase(size_without_number);
- name += format("_%d", number);
- ++number;
- }
+ bool unused = true;
+ for(const Block *b=█ (unused && b); b=b->parent)
+ unused = !b->variables.count(name);
+ if(unused)
+ return name;
+
+ name.erase(base_size);
+ name += format("_%d", number);
+ ++number;
}
+}
- return name;
+int get_layout_value(const Layout &layout, const string &name, int def_value)
+{
+ for(vector<Layout::Qualifier>::const_iterator i=layout.qualifiers.begin(); i!=layout.qualifiers.end(); ++i)
+ if(i->name==name)
+ return i->value;
+ return def_value;
+}
+
+void add_to_chain(Assignment::Target &target, Assignment::Target::ChainType type, unsigned index)
+{
+ if(target.chain_len<7)
+ target.chain[target.chain_len] = type | min<unsigned>(index, 0x3F);
+ ++target.chain_len;
}
} // namespace SL