/** * Builds a scopeless structure definition. * * @param declaration Definition's declaration */ public StructDefinition(StructDeclaration declaration) { super((ScopeNode) null); this.declaration = declaration; for (String fName : declaration.getFieldsList()) { IDeclaration fieldDecl = declaration.getFields().get(fName); assert (fieldDecl != null); Definition def = fieldDecl.createDefinition(); this.definitions.put(fName, def); } }
public void addIncludeToCurrentContext(String s) { // look back the stack until we find a CompilationUnit or a Component ICode thisone = null; // not sure if needed thisone = currentCode; if (thisone instanceof Component) { ((IComponent) thisone) .addExternalIncludes(Code.HASH_INCLUDE_ + Code.DQUOTE + s + Code.DQUOTE); return; } else if (thisone instanceof CompilationUnit) { ((ICompilationUnit) thisone) .addExternalInclude(Code.HASH_INCLUDE_ + Code.DQUOTE + s + Code.DQUOTE); // System.out.println("adding '" + s + "' to " + ((ICompilationUnit) thisone )); return; } int lastIndex = bodyStack.size() - 1; for (int i = lastIndex; i > 0; i--) { thisone = bodyStack.get(i); if (thisone instanceof StructDeclaration) { ((StructDeclaration) thisone) .addExternalIncludes(Code.HASH_INCLUDE_ + Code.DQUOTE + s + Code.DQUOTE); return; } else if (thisone instanceof Component) { ((IComponent) thisone) .addExternalIncludes(Code.HASH_INCLUDE_ + Code.DQUOTE + s + Code.DQUOTE); return; } else if (thisone instanceof CompilationUnit) { ((ICompilationUnit) thisone) .addExternalInclude(Code.HASH_INCLUDE_ + Code.DQUOTE + s + Code.DQUOTE); return; } } throw new RuntimeException("Didn't find Compilation Unit or Component when adding includes"); }