private void convertType(ASNType asnType, SmiType st) { if (asnType instanceof ASNNamedNumberType) { ASNNamedNumberType nnt = (ASNNamedNumberType) asnType; if (!nnt.getNamedNumbers().isEmpty()) { for (ASNNamedNumber ann : nnt.getNamedNumbers()) { ASNLiteralValue lv = (ASNLiteralValue) ann.getIntValue(); st.addEnumValue(ann.getName(), lv.getNumberValue()); } } } }
private void processModule(SmiMib mib, ASNModule m, SmiModule sm) { for (ASNAssignment a : m.getAssignments()) { final IdToken idToken = a.getIdToken(); if (a instanceof ASNTypeAssignment) { ASNTypeAssignment typeAssignment = (ASNTypeAssignment) a; ASNType asnType = typeAssignment.getEntityType(); SmiPrimitiveType pt = convertToPrimitiveType(asnType); if (pt != null) { SmiType st = sm.createType(idToken); st.setPrimitiveType(pt); convertType(asnType, st); } else if (asnType instanceof SMITextualConventionMacro) { // System.out.println("TC: " + m.getName() + ": " + idToken); SMITextualConventionMacro atc = (SMITextualConventionMacro) asnType; SmiTextualConvention stc = sm.createTextualConvention(idToken); ASNType at = atc.getSyntax(); // System.out.println(" is " + at.getClass().getName()); convertType(at, stc); if (!atc.getSyntaxNamedBits().isEmpty()) { for (SMINamedBit nb : atc.getSyntaxNamedBits()) { stc.addEnumValue(nb.getName(), BigInteger.valueOf(nb.getNumber())); } } } } else if (a instanceof ASNValueAssignment) { ASNValueAssignment va = (ASNValueAssignment) a; ASNType asnType = va.getEntityType(); if (asnType instanceof SMIObjectTypeMacro) { // System.out.println("ObjectType macro: " + idToken); SMIObjectTypeMacro otm = (SMIObjectTypeMacro) asnType; if (otm.getSyntax().getType() != SMIType.Enum.SEQUENCE && otm.getSyntax().getType() != SMIType.Enum.SEQUENCEOF) { // System.out.println(" is not SEQ(OF)"); if (!otm.getNamedBits().isEmpty()) { SmiType type = sm.createType(SmiUtil.ucFirst(idToken)); // System.out.println("Create attr type " + type.getId()); for (SMINamedBit nb : otm.getNamedBits()) { type.addEnumValue(nb.getName(), BigInteger.valueOf(nb.getNumber())); } } } } } } }