Exemplo n.º 1
0
            // case 1 : id1
            // is id1 reserved word    -->  label:=id1, no = id1.value
            // if (INDEX==0) && id1 is value reference to OBJ-ID ->replace component with components of other OBJ-ID
            // is id1 reference to INTEGER --> no := INTEGER value
            // is id1 reference to REL_OBJ ID --> ?
            //default: id1 is unknown or reference wrong type
            List<ObjectIdentifierComponent> handleCase1(int Index, Module mod, ObjectIdentifierComponent prev)
            {
                int tmp;
                string prvLbl = null;
                if (prev != null)
                    prvLbl = prev.label;
                if (YellowIDs.isYellowId(Index, id1, prvLbl, out tmp))
                {
                    no = tmp;
                    label = id1;
                    return null;
                }
                if (!mod.isValueDeclared(id1))
                    throw new SemanticErrorException("Error in line: " + tr1.Line + ", col:" + tr1.CharPositionInLine + ". Unknown identifier: " + id1);
                Asn1Value val = mod.GetValue(id1);
                if (val.m_TypeID == Asn1Value.TypeID.UNRESOLVED)
                    return null; // not yet resolved. wait for next round
                if (val.m_TypeID == TypeID.INT)
                {
                    tmp = (int)((IntegerValue)val).Value;
                    no = tmp;
                    return null;
                }
                if (val.m_TypeID == TypeID.OBJECT_IDENTIFIER)
                {
                    if (Index == 0)
                    {
                        ObjectIdentifierValue obj = val as ObjectIdentifierValue;
                        if (!obj.IsResolved())
                            return null; //wait until resolved
                        return obj.m_components;
                    }
                    else
                        throw new SemanticErrorException("Error in line: " + tr1.Line + ", col:" + tr1.CharPositionInLine + ". Identifier: " + id1 + "resolves to OBJECT IDENTIFIER but it is not the first item");
                }
                if (val.m_TypeID == TypeID.REL_OBJ_ID)
                {
                    throw new Exception("UNIMPLEMENTED FEATURE");
                }

                throw new SemanticErrorException("Error in line: " + tr1.Line + ", col:" + tr1.CharPositionInLine + ". Identifier: " + id1 + "does not resolve to INTEGER or RELATIVE-OID");
            }
Exemplo n.º 2
0
 internal List<ObjectIdentifierComponent> Fixup(int Index, Module mod, ObjectIdentifierComponent prev)
 {
     if (SemanticCheckFinished())
         return null;
     switch (caseNo)
     {
         case 1:
             return handleCase1(Index, mod, prev);
         case 2:
             return handleCase2(Index, mod);
         case 5:
             return handleCase5(Index, mod);
         case 6:
             return handleCase6(Index, mod);
         default:
             throw new Exception("INTERNAL ERROR.");
     }
 }