Search in sources :

Example 1 with Objects

use of com.ibm.uma.om.Objects in project openj9 by eclipse.

the class ObjectlistsParser method parse.

public static Vector<Objects> parse(Node node, String containingFile) throws UMAException {
    Vector<Objects> objects = new Vector<Objects>();
    NodeList nodeList = node.getChildNodes();
    for (int j = 0; j < nodeList.getLength(); j++) {
        Node item = nodeList.item(j);
        if (item.getNodeName().equalsIgnoreCase("objects")) {
            Objects objs = ObjectsParser.parse(item, containingFile);
            objects.add(objs);
        }
    }
    return objects;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Objects(com.ibm.uma.om.Objects) Vector(java.util.Vector)

Example 2 with Objects

use of com.ibm.uma.om.Objects in project openj9 by eclipse.

the class ObjectsParser method parse.

public static Objects parse(Node node, String containingFile) throws UMAException {
    Objects objects = new Objects(containingFile);
    NamedNodeMap attributes = node.getAttributes();
    objects.setGroup(attributes.getNamedItem("group").getNodeValue());
    NodeList nodeList = node.getChildNodes();
    for (int j = 0; j < nodeList.getLength(); j++) {
        Node item = nodeList.item(j);
        if (item.getNodeName().equalsIgnoreCase("object")) {
            Object object = ObjectParser.parse(item, containingFile);
            objects.addObject(object);
        } else if (item.getNodeName().equalsIgnoreCase("group")) {
            NamedNodeMap attr = item.getAttributes();
            String objectGroupName = attr.getNamedItem("name").getNodeValue();
            Object object = new Object(objectGroupName, containingFile);
            objects.addObject(object);
        }
    }
    Parser.populatePredicateList(nodeList, objects);
    return objects;
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Objects(com.ibm.uma.om.Objects) Object(com.ibm.uma.om.Object)

Example 3 with Objects

use of com.ibm.uma.om.Objects in project openj9 by eclipse.

the class UMA method writeMakefileObjectLine.

void writeMakefileObjectLine(StringBuffer buffer, Module module, Artifact artifact) throws UMAException {
    // Add all objects into a set, eliminating duplicates.
    HashSet<String> objtable = new HashSet<String>();
    Vector<Object> objects = artifact.getObjects();
    for (Object object : objects) {
        if (object.evaluate()) {
            switch(object.getType()) {
                case Object.SINGLE:
                    if (!objtable.contains(object.getName())) {
                        objtable.add(object.getName());
                    }
                    break;
                case Object.GROUP:
                    Vector<String> newGroups = new Vector<String>();
                    newGroups.add(object.getName());
                    while (newGroups != null) {
                        Vector<String> groups = newGroups;
                        newGroups = null;
                        for (String groupName : groups) {
                            Objects objs = module.getObjects().get(groupName);
                            if (objs == null) {
                                throw new UMAException("Error: bad object group name [" + groupName + "] in " + module.getModulePath() + ".");
                            }
                            if (objs.evaluate()) {
                                for (Object obj : objs.getObjects()) {
                                    if (obj.evaluate()) {
                                        switch(obj.getType()) {
                                            case Object.SINGLE:
                                                if (!objtable.contains(obj.getName())) {
                                                    objtable.add(obj.getName());
                                                }
                                                break;
                                            case Object.GROUP:
                                                if (newGroups == null) {
                                                    newGroups = new Vector<String>();
                                                }
                                                newGroups.add(obj.getName());
                                                break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
            }
        // switch
        }
    }
    StringBuffer objectBuffer = new StringBuffer();
    if (objtable.size() >= 1) {
        produceObjectLine(objectBuffer, objtable, "UMA_OBJECTS");
    }
    HashSet<String> targetSpecificObjects = new HashSet<String>();
    produceObjectLine(objectBuffer, targetSpecificObjects, "UMA_OBJECTS+");
    objtable = new HashSet<String>();
    platform.addTargetSpecificObjectsForStaticLink(objtable, artifact);
    if (objtable.size() >= 1) {
        produceObjectLine(objectBuffer, objtable, "UMA_STATIC_OBJECTS");
    }
    if (objectBuffer.length() > 0) {
        buffer.append(objectBuffer.toString());
    }
}
Also used : Objects(com.ibm.uma.om.Objects) Object(com.ibm.uma.om.Object) Vector(java.util.Vector) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 4 with Objects

use of com.ibm.uma.om.Objects in project openj9 by eclipse.

the class ModuleParser method parse.

public static Module parse(Document moduleXml, String modulePath) throws UMAException {
    Module module = new Module(modulePath);
    // Initialize the Module based on the XML document
    Element elem = moduleXml.getDocumentElement();
    NodeList nodeList = elem.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        String nodeName = node.getLocalName();
        if (nodeName == null)
            continue;
        if (nodeName.equalsIgnoreCase("artifact")) {
            Artifact artifact = ArtifactParser.parse(node, module);
            module.addArtifact(artifact);
            UMA.getUma().addArtifact(artifact);
        } else if (nodeName.equalsIgnoreCase("exports")) {
            Exports exps = ExportsParser.parse(node, module.getContainingFile());
            module.addExports(exps.getGroup(), exps);
        } else if (nodeName.equalsIgnoreCase("objects")) {
            Objects objs = ObjectsParser.parse(node, module.getContainingFile());
            module.addObjects(objs.getGroup(), objs);
        } else if (nodeName.equalsIgnoreCase("exportlists")) {
            Vector<Exports> exports = ExportlistsParser.parse(node, module.getContainingFile());
            for (Exports exps : exports) {
                module.addExports(exps.getGroup(), exps);
            }
        } else if (nodeName.equalsIgnoreCase("objectlists")) {
            Vector<Objects> objects = ObjectlistsParser.parse(node, module.getContainingFile());
            for (Objects objs : objects) {
                module.addObjects(objs.getGroup(), objs);
            }
        } else if (nodeName.equalsIgnoreCase("flaglists")) {
            Vector<Flags> flags = FlaglistsParser.parse(node, module.getContainingFile());
            for (Flags f : flags) {
                // System.out.println("Flag: " + (f == null ? "null" : f.getGroup()));
                module.addFlags(f.getGroup(), f);
            }
        } else if (nodeName.equalsIgnoreCase("flags")) {
            Flags flags = FlagsParser.parse(node, module.getContainingFile());
            // System.out.println("GROUP: " + flags.getGroup());
            for (Flag f : flags.getFlags()) {
            /*
					if (f != null) {
						System.out.println("FLAG: "+ f.getName());
					} else {
						System.out.println("NULL FLAG");
					}
					*/
            }
            module.addFlags(flags.getGroup(), flags);
        }
    }
    Parser.populatePredicateList(nodeList, module);
    return module;
}
Also used : Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Flags(com.ibm.uma.om.Flags) Flag(com.ibm.uma.om.Flag) Artifact(com.ibm.uma.om.Artifact) Exports(com.ibm.uma.om.Exports) Objects(com.ibm.uma.om.Objects) Module(com.ibm.uma.om.Module) Vector(java.util.Vector)

Aggregations

Objects (com.ibm.uma.om.Objects)4 Vector (java.util.Vector)3 Node (org.w3c.dom.Node)3 NodeList (org.w3c.dom.NodeList)3 Object (com.ibm.uma.om.Object)2 Artifact (com.ibm.uma.om.Artifact)1 Exports (com.ibm.uma.om.Exports)1 Flag (com.ibm.uma.om.Flag)1 Flags (com.ibm.uma.om.Flags)1 Module (com.ibm.uma.om.Module)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Element (org.w3c.dom.Element)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1