protected void createElementForNode(Object node) { boolean exists = nodeMap.containsKey(node); if (!exists || NodeUtil.findAnnotation(node.getClass(), GraphDuplicate.class) != null) { Element nodeElem = dom.createElement("node"); nodeElem.setAttribute("id", !exists ? oldOrNextId(node) : nextId()); nodeMap.put(node, nodeElem); Element properties = dom.createElement("properties"); nodeElem.appendChild(properties); nodesElement.appendChild(nodeElem); setNodeProperty(node, "name", node.getClass().getSimpleName().replaceFirst("Node$", "")); NodeInfo nodeInfo = node.getClass().getAnnotation(NodeInfo.class); if (nodeInfo != null) { setNodeProperty(node, "cost", nodeInfo.cost()); if (!nodeInfo.shortName().isEmpty()) { setNodeProperty(node, "shortName", nodeInfo.shortName()); } } setNodeProperty(node, "class", node.getClass().getSimpleName()); if (node instanceof Node) { readNodeProperties((Node) node); copyDebugProperties((Node) node); } } }
private static void setBasicProperties(Map<String, ? super Object> properties, Node source) { String className = className(source.getClass()); properties.put("label", dropNodeSuffix(className)); properties.put("cost", source.getCost()); NodeInfo nodeInfo = source.getClass().getAnnotation(NodeInfo.class); if (nodeInfo != null) { if (!nodeInfo.shortName().isEmpty()) { properties.put("shortName", nodeInfo.shortName()); } } if (Introspection.isIntrospectable(source)) { final List<Introspection.SpecializationInfo> specializations = Introspection.getSpecializations(source); for (Introspection.SpecializationInfo specialization : specializations) { final String methodName = specialization.getMethodName(); properties.put(methodName + ".isActive", specialization.isActive()); properties.put(methodName + ".isExcluded", specialization.isExcluded()); properties.put(methodName + ".instances", specialization.getInstances()); for (int i = 0; i < specialization.getInstances(); i++) { final List<Object> cachedData = specialization.getCachedData(i); for (Object o : cachedData) { properties.put(methodName + "-cachedData[" + i + "]", o); } } } } }
public void installBuiltin(NodeFactory<? extends LuaNode> factory) { int argumentCount = factory.getExecutionSignature().size(); Object[] argumentNodes = new Object[argumentCount]; for (int i = 0; i < argumentCount; i++) { argumentNodes[i] = new LuaReadArgumentNode(i); } for (int i = 0; i < argumentCount; i++) { argumentNodes[i] = new LuaReadArgumentNode(i); } LuaNode builtinBodyNode = factory.createNode(argumentNodes); String name = builtinBodyNode.getClass().getAnnotation(NodeInfo.class).shortName(); LuaRootNode rootNode = new LuaRootNode(builtinBodyNode, null); luaFunctionRegistry.register(name, rootNode); }
final void createElementForNode(Object node) { boolean exists = nodeMap.containsKey(node); if (!exists) { int nodeId = !exists ? oldOrNextId(node) : nextId(); nodeMap.put(node, new NodeElement(nodeId)); String className = NodeUtil.className(node.getClass()); setNodeProperty(node, "name", dropNodeSuffix(className)); NodeInfo nodeInfo = node.getClass().getAnnotation(NodeInfo.class); if (nodeInfo != null) { setNodeProperty(node, "cost", nodeInfo.cost()); if (!nodeInfo.shortName().isEmpty()) { setNodeProperty(node, "shortName", nodeInfo.shortName()); } } setNodeProperty(node, "class", className); if (node instanceof Node) { readNodeProperties((Node) node); copyDebugProperties((Node) node); } } }
final void createElementForNode(Object node) { boolean exists = nodeMap.containsKey(node); if (!exists) { int nodeId = !exists ? oldOrNextId(node) : nextId(); nodeMap.put(node, new NodeElement(nodeId)); String className = NodeUtil.className(node.getClass()); setNodeProperty(node, "name", dropNodeSuffix(className)); NodeInfo nodeInfo = node.getClass().getAnnotation(NodeInfo.class); if (nodeInfo != null) { setNodeProperty(node, "cost", nodeInfo.cost()); if (!nodeInfo.shortName().isEmpty()) { setNodeProperty(node, "shortName", nodeInfo.shortName()); } } setNodeProperty(node, "class", className); if (node instanceof Node) { readNodeProperties((Node) node); copyDebugProperties((Node) node); } } }