public void visitVariablesDeclaration(VariablesDeclaration v) { visitDeclaration(v); visit(v.getDeclarators()); }
Set<Identifier> listChildIdentifiers(DeclarationsHolder h) { List<Identifier> list = new ArrayList<Identifier>(); for (Declaration d : h.getDeclarations()) { if (d instanceof Function) { list.add(((Function) d).getName()); } else if (d instanceof TaggedTypeRefDeclaration) { TaggedTypeRefDeclaration td = (TaggedTypeRefDeclaration) d; TaggedTypeRef tr = td.getTaggedTypeRef(); if (tr != null) { list.add(tr.getTag()); } } else if (d instanceof VariablesDeclaration) { for (Declarator dc : ((VariablesDeclaration) d).getDeclarators()) { list.add(ident(dc.resolveName())); } } } Set<Identifier> ret = new HashSet<Identifier>(); for (Identifier i : list) { if (i != null) { ret.add(i); } } return ret; }
@Override public void visitVariablesDeclaration(VariablesDeclaration v) { super.visitVariablesDeclaration(v); if (v.findParentOfTypes(Struct.class, Function.class, Enum.class) != null) { return; } for (Declarator d : v.getDeclarators()) { globalVariablesByName.put(ident(d.resolveName()), v); } getList(globalsByLibrary, getLibrary(v)).add(v); }
public int countFieldsInStruct(Struct s) throws UnsupportedConversionException { int count = 0; for (Declaration declaration : s.getDeclarations()) { if (declaration instanceof VariablesDeclaration) { count += ((VariablesDeclaration) declaration).getDeclarators().size(); } } for (SimpleTypeRef parentName : s.getParents()) { Struct parent = result.structsByName.get(parentName.getName()); if (parent == null) { throw new UnsupportedConversionException(s, "Cannot find parent " + parentName + " of struct " + s); } count += countFieldsInStruct(parent); } return count; }
@Override public void visitVariablesDeclaration(VariablesDeclaration v) { super.visitVariablesDeclaration(v); if (v.findParentOfTypes(Struct.class, Function.class, Enum.class) != null) { return; } for (Declarator d : v.getDeclarators()) { globalVariablesByName.put(ident(d.resolveName()), v); } getList(globalsByLibrary, getLibrary(v)).add(v); }
Set<Identifier> listChildIdentifiers(DeclarationsHolder h) { List<Identifier> list = new ArrayList<Identifier>(); for (Declaration d : h.getDeclarations()) { if (d instanceof Function) { list.add(((Function) d).getName()); } else if (d instanceof TaggedTypeRefDeclaration) { TaggedTypeRefDeclaration td = (TaggedTypeRefDeclaration) d; TaggedTypeRef tr = td.getTaggedTypeRef(); if (tr != null) { list.add(tr.getTag()); } } else if (d instanceof VariablesDeclaration) { for (Declarator dc : ((VariablesDeclaration) d).getDeclarators()) { list.add(ident(dc.resolveName())); } } } Set<Identifier> ret = new HashSet<Identifier>(); for (Identifier i : list) { if (i != null) { ret.add(i); } } return ret; }
public int countFieldsInStruct(Struct s) throws UnsupportedConversionException { int count = 0; for (Declaration declaration : s.getDeclarations()) { if (declaration instanceof VariablesDeclaration) { count += ((VariablesDeclaration) declaration).getDeclarators().size(); } } for (SimpleTypeRef parentName : s.getParents()) { Struct parent = result.structsByName.get(parentName.getName()); if (parent == null) { throw new UnsupportedConversionException(s, "Cannot find parent " + parentName + " of struct " + s); } count += countFieldsInStruct(parent); } return count; }
public int countFieldsInStruct(Struct s) throws UnsupportedConversionException { int count = 0; for (Declaration declaration : s.getDeclarations()) { if (declaration instanceof VariablesDeclaration) { count += ((VariablesDeclaration) declaration).getDeclarators().size(); } } for (SimpleTypeRef parentName : s.getParents()) { Struct parent = result.structsByName.get(parentName.getName()); if (parent == null) { throw new UnsupportedConversionException(s, "Cannot find parent " + parentName + " of struct " + s); } count += countFieldsInStruct(parent); } return count; }
public int countFieldsInStruct(Struct s) throws UnsupportedConversionException { int count = 0; for (Declaration declaration : s.getDeclarations()) { if (declaration instanceof VariablesDeclaration) { count += ((VariablesDeclaration) declaration).getDeclarators().size(); } } for (SimpleTypeRef parentName : s.getParents()) { Struct parent = result.structsByName.get(parentName.getName()); if (parent == null) { throw new UnsupportedConversionException(s, "Cannot find parent " + parentName + " of struct " + s); } count += countFieldsInStruct(parent); } return count; }
if (vd.getDeclarators().size() != 1) { continue; // should not happen !
@Override public void visitVariablesDeclaration(VariablesDeclaration v) { if (v.getDeclarators().isEmpty() && v.getValueType() instanceof TaggedTypeRef) { TaggedTypeRefDeclaration d = new TaggedTypeRefDeclaration((TaggedTypeRef) v.getValueType()); d.importComments(v); v.replaceBy(d); d.accept(this); } else { super.visitVariablesDeclaration(v); } }
if (vd.getDeclarators().size() != 1) { continue; // should not happen !
@Override public void visitVariablesDeclaration(VariablesDeclaration v) { if (v.getDeclarators().isEmpty() && v.getValueType() instanceof TaggedTypeRef) { TaggedTypeRefDeclaration d = new TaggedTypeRefDeclaration((TaggedTypeRef) v.getValueType()); d.importComments(v); v.replaceBy(d); d.accept(this); } else { super.visitVariablesDeclaration(v); } }
if (vd.getDeclarators().size() != 1) { continue; // should not happen !
if (vd.getDeclarators().size() != 1) { continue; // should not happen !
@Test public void addSibling() { VariablesDeclaration d = new VariablesDeclaration(); Declarator s1 = new Declarator.DirectDeclarator(), s2 = new Declarator.DirectDeclarator(); d.setDeclarators(Arrays.asList(s1)); s1.insertSibling(s2, false); List<Declarator> list = d.getDeclarators(); assertEquals("Failed to add after", 2, list.size()); assertSame("Added, but not after", s1, list.get(0)); assertSame(s2, list.get(1)); s2.replaceBy(null); list = d.getDeclarators(); assertEquals("Failed to remove added element", 1, list.size()); assertSame("Removed bad element", s1, list.get(0)); d.setDeclarators(Arrays.asList(s1)); s1.insertSibling(s2, true); list = d.getDeclarators(); assertEquals("Failed to add before", 2, list.size()); assertSame("Added, but not before", s2, list.get(0)); assertSame(s1, list.get(1)); s2.replaceBy(null); list = d.getDeclarators(); assertEquals("Failed to remove added element", 1, list.size()); assertSame("Removed bad element", s1, list.get(0)); } }
for (Declarator decl : v.getDeclarators()) { if (!(decl instanceof DirectDeclarator)) { continue; // TODO provide a mapping of exported values
try { TypeRef valueType = v.getValueType(); for (Declarator vs : v.getDeclarators()) { if (vs.getDefaultValue() != null) { continue;
int nDecl = v.getDeclarators().size(); for (Declarator vs : v.getDeclarators()) { if (vs == null || vs instanceof DirectDeclarator && nDecl == 1) { continue;
typeDef = new TypeDef(vd.getValueType(), vd.getDeclarators());