4 * first links value refs in the import list then
5 * links value references in value defs and types' default values
10 * Completely Rewritten for new ModuleList data structure (ASN.1 based)
12 * Copyright (C) 1991, 1992 Michael Sample
13 * and the University of British Columbia
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/link-values.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $
21 * $Log: link-values.c,v $
22 * Revision 1.1 2001/06/20 21:27:57 dmitch
23 * Adding missing snacc compiler files.
25 * Revision 1.1.1.1 1999/03/16 18:06:49 aram
26 * Originals from SMIME Free Library.
28 * Revision 1.3 1995/07/25 19:41:38 rj
29 * changed `_' to `-' in file names.
31 * Revision 1.2 1994/09/01 00:38:43 rj
32 * snacc_config.h removed.
34 * Revision 1.1 1994/08/28 09:49:19 rj
35 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
43 #include "asn1module.h"
45 #include "snacc-util.h"
46 #include "link-values.h"
48 extern Module
*usefulTypeModG
;
50 /* non-exported fcn prototypes */
53 void ValueLinkImportLists
PROTO ((ModuleList
*m
));
55 void ValueLinkTypeDef
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
));
57 void ValueLinkElmtTypes
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, NamedTypeList
*e
));
59 void ValueLinkElmtType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, NamedType
*n
));
61 void ValueLinkType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*currType
));
63 void ValueLinkBasicType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*type
, BasicType
*bt
));
65 void ValueLinkSubtypes
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*currType
, Subtype
*s
));
67 void ValueLinkSubtypeValue
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*currType
, SubtypeValue
*s
));
69 void ValueLinkNamedElmts
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, ValueDefList
*v
));
72 void ValueLinkValueDef
PROTO ((ModuleList
*m
, Module
*currMod
, ValueDef
*v
));
75 void ValueLinkValue
PROTO ((ModuleList
*m
, Module
*currMod
, ValueDef
*head
, Type
*valuesType
, Value
*v
));
77 void ValueLinkBasicValue
PROTO ((ModuleList
*m
, Module
*currMod
, ValueDef
*head
, Type
*valuesType
, Value
*v
, BasicValue
*bv
));
79 void ValueLinkOid
PROTO ((ModuleList
*m
, Module
*currMod
, ValueDef
*head
, Value
*v
, OID
*oid
));
81 void ValueLinkRosOperationMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, RosOperationMacroType
*op
));
83 void ValueLinkRosErrorMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, RosErrorMacroType
*err
));
86 void ValueLinkRosBindMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, RosBindMacroType
*bind
));
88 void ValueLinkRosAseMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, RosAseMacroType
*ase
));
90 void ValueLinkRosAcMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, RosAcMacroType
*ac
));
92 void ValueLinkMtsasExtensionsMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, MtsasExtensionsMacroType
*exts
));
94 void ValueLinkMtsasExtensionMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, MtsasExtensionMacroType
*ext
));
96 void ValueLinkMtsasExtensionAttributeMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, MtsasExtensionAttributeMacroType
*ext
));
98 void ValueLinkMtsasTokenMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, MtsasTokenMacroType
*tok
));
100 void ValueLinkMtsasTokenDataMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, MtsasTokenDataMacroType
*tok
));
102 void ValueLinkMtsasSecurityCategoryMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, MtsasSecurityCategoryMacroType
*sec
));
104 void ValueLinkAsnObjectMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, AsnObjectMacroType
*obj
));
106 void ValueLinkAsnPortMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, AsnPortMacroType
*p
));
108 void ValueLinkAsnAbstractBindMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, AsnAbstractBindMacroType
*bind
));
110 void ValueLinkSnmpObjectTypeMacroType
PROTO ((ModuleList
*m
, Module
*currMod
, TypeDef
*head
, Type
*t
, BasicType
*bt
, SnmpObjectTypeMacroType
*ot
));
113 /* end of prototypes */
118 static char *asn1SrcFileNameG
;
119 static int linkOidCallDepthG
= 0; /* big hack!! */
122 * returns 0 if no link error occured
123 * otherwise returns a value < 0.
124 * processing should not continue is an error is returned
127 LinkValueRefs
PARAMS ((m
),
136 * link imported types/values to there definition if
137 * the defining module is in the modulelist
139 ValueLinkImportLists (m
);
142 /* link useful module, in case there are value defs there */
143 if (usefulTypeModG
!= NULL
)
145 currMod
= usefulTypeModG
;
146 asn1SrcFileNameG
= currMod
->asn1SrcFileName
;
149 * link this modules object identifier value
151 ValueLinkOid (m
, currMod
, NULL
, NULL
, currMod
->modId
->oid
);
155 * go through each type in typeList and link as nec
157 FOR_EACH_LIST_ELMT (td
, currMod
->typeDefs
)
159 ValueLinkTypeDef (m
, currMod
, td
);
164 * go through each value in valueList and link as nec
166 FOR_EACH_LIST_ELMT (vd
, currMod
->valueDefs
)
168 ValueLinkValueDef (m
, currMod
, vd
);
171 if (currMod
->status
!= MOD_ERROR
)
172 currMod
->status
= MOD_OK
;
178 * go through types, values & macros of each parsed module
181 FOR_EACH_LIST_ELMT (currMod
, m
)
184 asn1SrcFileNameG
= currMod
->asn1SrcFileName
;
187 * link this modules object identifier value
189 ValueLinkOid (m
, currMod
, NULL
, NULL
, currMod
->modId
->oid
);
193 * go through each type in typeList and link as nec
195 FOR_EACH_LIST_ELMT (td
, currMod
->typeDefs
)
197 ValueLinkTypeDef (m
, currMod
, td
);
201 * go through each value in valueList and link as nec
203 FOR_EACH_LIST_ELMT (vd
, currMod
->valueDefs
)
205 ValueLinkValueDef (m
, currMod
, vd
);
208 if (currMod
->status
!= MOD_ERROR
)
209 currMod
->status
= MOD_OK
;
216 } /* ValueLinkRefs */
220 * go through each modules import lists and link
221 * any values as nec. values'symbols start with a
225 ValueLinkImportLists
PARAMS ((m
),
231 ImportModule
*currImpList
;
232 ImportElmt
*currImpElmt
;
236 /* link imports of each module in the list */
237 FOR_EACH_LIST_ELMT (currMod
, m
)
239 /* for each import list in the current module */
240 FOR_EACH_LIST_ELMT (currImpList
, currMod
->imports
)
242 /* see if the referenced module is in the list */
243 impRefMod
= LookupModule (m
, currImpList
->modId
->name
, currImpList
->modId
->oid
);
245 if (impRefMod
== NULL
)
247 /* the type linker will have reported this error */
252 * link each value referencing import elmt in
253 * the current import list
255 FOR_EACH_LIST_ELMT (currImpElmt
, currImpList
->importElmts
)
258 * only link values (all vals have lowercase first letter)
260 if (!islower (currImpElmt
->name
[0]))
263 v
= LookupValue (impRefMod
->valueDefs
, currImpElmt
->name
);
268 currMod
->status
= MOD_ERROR
;
269 PrintErrLoc (currMod
->asn1SrcFileName
, currImpElmt
->lineNo
);
270 fprintf (stderr
,"ERROR - \"%s\" module imports value \"%s\", which is not exported from module \"%s\".\n", currMod
->modId
->name
, currImpElmt
->name
, impRefMod
->modId
->name
);
273 currImpElmt
->resolvedRef
=
274 (ImportElmtChoice
*)Malloc (sizeof (ImportElmtChoice
));
275 currImpElmt
->resolvedRef
->choiceId
= IMPORTELMTCHOICE_VALUE
;
276 currImpElmt
->resolvedRef
->a
.value
= v
;
278 else /* value not found in ref'd module */
280 currMod
->status
= MOD_ERROR
;
281 PrintErrLoc (currMod
->asn1SrcFileName
, currImpElmt
->lineNo
);
282 fprintf (stderr
,"ERROR - \"%s\" is imported from module \"%s\" by module \"%s\", but is not defined in the referenced module\n", currImpElmt
->name
, impRefMod
->modId
->name
, currMod
->modId
->name
);
288 } /* ValueLinkImportLists */
293 ValueLinkTypeDef
PARAMS ((m
, currMod
, head
),
295 Module
*currMod _AND_
302 ValueLinkType (m
, currMod
, head
, head
->type
);
304 } /* ValueLinkTypeDef */
309 ValueLinkType
PARAMS ((m
, currMod
, head
, t
),
311 Module
*currMod _AND_
319 ValueLinkBasicType (m
, currMod
, head
, t
, t
->basicType
);
321 ValueLinkSubtypes (m
, currMod
, head
, t
, t
->subtypes
);
323 if (t
->defaultVal
!= NULL
)
324 ValueLinkValue (m
, currMod
, NULL
, t
, t
->defaultVal
->value
);
326 } /* ValueLinkType */
331 ValueLinkElmtTypes
PARAMS ((m
, currMod
, head
, e
),
333 Module
*currMod _AND_
338 FOR_EACH_LIST_ELMT (n
, e
)
340 ValueLinkElmtType (m
, currMod
, head
, n
);
342 } /* ValueLinkElmtTypes */
346 ValueLinkElmtType
PARAMS ((m
, currMod
, head
, n
),
348 Module
*currMod _AND_
353 ValueLinkType (m
, currMod
, head
, n
->type
);
358 ValueLinkBasicType
PARAMS ((m
, currMod
, head
, type
, bt
),
360 Module
*currMod _AND_
366 TypeDefList
*tmpTypeDefs
;
369 NamedType
*tmpElmtType
;
371 ImportModule
*impMod
;
377 switch (bt
->choiceId
)
380 case BASICTYPE_SEQUENCE
:
382 case BASICTYPE_CHOICE
:
383 ValueLinkElmtTypes (m
, currMod
, head
, bt
->a
.set
);
388 case BASICTYPE_SEQUENCEOF
:
389 case BASICTYPE_SETOF
:
390 ValueLinkType (m
, currMod
, head
, bt
->a
.setOf
);
395 case BASICTYPE_SELECTION
:
396 case BASICTYPE_COMPONENTSOF
:
397 case BASICTYPE_ANYDEFINEDBY
:
398 case BASICTYPE_LOCALTYPEREF
:
399 case BASICTYPE_IMPORTTYPEREF
:
403 * these types may optionally have named elmts
405 case BASICTYPE_INTEGER
:
406 case BASICTYPE_BITSTRING
:
407 case BASICTYPE_ENUMERATED
:
408 ValueLinkNamedElmts (m
, currMod
, head
, type
, bt
->a
.integer
);
414 * these types have no extra info and cause no linking action
416 case BASICTYPE_UNKNOWN
:
417 case BASICTYPE_BOOLEAN
:
418 case BASICTYPE_OCTETSTRING
:
423 case BASICTYPE_MACRODEF
:
425 * these have no more info - only the choiceId is used
429 case BASICTYPE_MACROTYPE
:
430 switch (bt
->a
.macroType
->choiceId
)
432 case MACROTYPE_ROSOPERATION
:
433 case MACROTYPE_ASNABSTRACTOPERATION
:
435 ValueLinkRosOperationMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.rosOperation
);
438 case MACROTYPE_ROSERROR
:
439 case MACROTYPE_ASNABSTRACTERROR
:
440 ValueLinkRosErrorMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.rosError
);
443 case MACROTYPE_ROSBIND
:
444 case MACROTYPE_ROSUNBIND
:
445 ValueLinkRosBindMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.rosBind
);
448 case MACROTYPE_ROSASE
:
449 ValueLinkRosAseMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.rosAse
);
452 case MACROTYPE_MTSASEXTENSIONS
:
453 ValueLinkMtsasExtensionsMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.mtsasExtensions
);
456 case MACROTYPE_MTSASEXTENSION
:
457 ValueLinkMtsasExtensionMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.mtsasExtension
);
460 case MACROTYPE_MTSASEXTENSIONATTRIBUTE
:
461 ValueLinkMtsasExtensionAttributeMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.mtsasExtensionAttribute
);
464 case MACROTYPE_MTSASTOKEN
:
465 ValueLinkMtsasTokenMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.mtsasToken
);
468 case MACROTYPE_MTSASTOKENDATA
:
469 ValueLinkMtsasTokenDataMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.mtsasTokenData
);
472 case MACROTYPE_MTSASSECURITYCATEGORY
:
473 ValueLinkMtsasSecurityCategoryMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.mtsasSecurityCategory
);
476 case MACROTYPE_ASNOBJECT
:
477 ValueLinkAsnObjectMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.asnObject
);
480 case MACROTYPE_ASNPORT
:
481 ValueLinkAsnPortMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.asnPort
);
484 case MACROTYPE_ASNABSTRACTBIND
:
485 case MACROTYPE_ASNABSTRACTUNBIND
:
486 ValueLinkAsnAbstractBindMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.asnAbstractBind
);
489 case MACROTYPE_AFALGORITHM
:
490 case MACROTYPE_AFENCRYPTED
:
491 case MACROTYPE_AFPROTECTED
:
492 case MACROTYPE_AFSIGNATURE
:
493 case MACROTYPE_AFSIGNED
:
494 ValueLinkType (m
, currMod
, head
, bt
->a
.macroType
->a
.afAlgorithm
);
497 case MACROTYPE_SNMPOBJECTTYPE
:
498 ValueLinkSnmpObjectTypeMacroType (m
, currMod
, head
, type
, bt
, bt
->a
.macroType
->a
.snmpObjectType
);
502 fprintf (stderr
, "ValueLinkBasicType: ERROR - unknown macro type id!\n");
508 fprintf (stderr
, "ValueLinkBasicType: ERROR - unknown basic type id!\n");
511 } /* ValueLinkBasicType */
517 * resolve any type/value refs in the subtypes (if any)
520 ValueLinkSubtypes
PARAMS ((m
, currMod
, head
, currType
, s
),
522 Module
*currMod _AND_
535 ValueLinkSubtypeValue (m
, currMod
, head
, currType
, s
->a
.single
);
541 FOR_EACH_LIST_ELMT (sElmt
, s
->a
.and)
543 ValueLinkSubtypes (m
, currMod
, head
, currType
, sElmt
);
548 fprintf (stderr
, "ValueLinkSubtypes: ERROR - unknown Subtype id\n");
551 } /* ValueLinkSubtypes */
558 ValueLinkSubtypeValue
PARAMS ((m
, currMod
, head
, currType
, s
),
560 Module
*currMod _AND_
565 Constraint
*constraint
;
572 case SUBTYPEVALUE_SINGLEVALUE
:
573 ValueLinkValue (m
, currMod
, NULL
, currType
, s
->a
.singleValue
);
576 case SUBTYPEVALUE_CONTAINED
:
577 ValueLinkType (m
, currMod
, head
, s
->a
.contained
);
580 case SUBTYPEVALUE_VALUERANGE
:
581 ValueLinkValue (m
, currMod
, NULL
, currType
, s
->a
.valueRange
->lowerEndValue
);
582 ValueLinkValue (m
, currMod
, NULL
, currType
, s
->a
.valueRange
->upperEndValue
);
585 case SUBTYPEVALUE_PERMITTEDALPHABET
:
586 ValueLinkSubtypes (m
, currMod
, head
, currType
, s
->a
.permittedAlphabet
);
589 case SUBTYPEVALUE_SIZECONSTRAINT
:
590 ValueLinkSubtypes (m
, currMod
, head
, currType
, s
->a
.sizeConstraint
);
593 case SUBTYPEVALUE_INNERSUBTYPE
:
594 FOR_EACH_LIST_ELMT (constraint
, s
->a
.innerSubtype
->constraints
)
596 ValueLinkSubtypes (m
, currMod
, head
, currType
, constraint
->valueConstraints
);
601 fprintf (stderr
,"ValueLinkSubtype: ERROR - unknown subtype choiceId\n");
604 } /* ValueLinkSubtype */
610 ValueLinkNamedElmts
PARAMS ((m
, currMod
, head
, t
, v
),
612 Module
*currMod _AND_
618 FOR_EACH_LIST_ELMT (vd
, v
)
620 ValueLinkValue (m
, currMod
, vd
, vd
->value
->type
, vd
->value
);
623 } /* ValueLinkNamedElmts */
629 ValueLinkValueDef
PARAMS ((m
, currMod
, v
),
631 Module
*currMod _AND_
637 ValueLinkType (m
, currMod
, NULL
, v
->value
->type
);
638 ValueLinkValue (m
, currMod
, v
, v
->value
->type
, v
->value
);
640 } /* ValueLinkValueDef */
646 ValueLinkValue
PARAMS ((m
, currMod
, head
, valuesType
, v
),
648 Module
*currMod _AND_
650 Type
*valuesType _AND_
657 ValueLinkBasicValue (m
, currMod
, head
, valuesType
, v
, v
->basicValue
);
659 } /* ValueLinkValue */
664 ValueLinkBasicValue
PARAMS ((m
, currMod
, head
, valuesType
, v
, bv
),
666 Module
*currMod _AND_
668 Type
*valuesType _AND_
672 ValueDef
*tmpValueDef
;
675 ImportModule
*impMod
;
677 ValueDefList
*namedElmtList
;
684 switch (bv
->choiceId
)
686 case BASICVALUE_UNKNOWN
:
687 case BASICVALUE_EMPTY
:
688 case BASICVALUE_INTEGER
:
689 case BASICVALUE_SPECIALINTEGER
:
690 case BASICVALUE_BOOLEAN
:
691 case BASICVALUE_REAL
:
692 case BASICVALUE_SPECIALREAL
:
693 case BASICVALUE_ASCIITEXT
:
694 case BASICVALUE_ASCIIHEX
:
695 case BASICVALUE_ASCIIBITSTRING
:
696 case BASICVALUE_BERVALUE
:
697 case BASICVALUE_PERVALUE
:
698 case BASICVALUE_NAMEDVALUE
:
699 case BASICVALUE_NULL
:
700 case BASICVALUE_VALUENOTATION
:
705 case BASICVALUE_LOCALVALUEREF
:
708 * parser sets all value refs to "Local" so must
709 * check if local, then if import ....
713 * first check in named elmts of the given type
715 namedElmtList
= GetAllNamedElmts (valuesType
);
716 if (namedElmtList
!= NULL
)
718 n
= LookupValue (namedElmtList
, bv
->a
.localValueRef
->valueName
);
722 bv
->a
.localValueRef
->link
= n
;
723 bv
->a
.localValueRef
->module = currMod
;
725 /* now free list structure (not data elmts) */
726 AsnListFree (namedElmtList
);
728 break; /* exit switch since done here. */
733 * second, look for values defined in this module
735 tmpValueDef
= LookupValue (currMod
->valueDefs
, bv
->a
.localValueRef
->valueName
);
737 if (tmpValueDef
!= NULL
)
739 bv
->a
.localValueRef
->link
= tmpValueDef
;
740 break; /* exit switch since done here. */
744 bv
->choiceId
= BASICVALUE_IMPORTVALUEREF
;
745 /*!!!!!!!!!! fall through from else clause */
748 case BASICVALUE_IMPORTVALUEREF
:
749 /* This handles "modname.value" value refs. */
750 if (bv
->a
.importValueRef
->moduleName
!= NULL
)
753 * Lookup the import list maintained in this module
754 * from the named module. (the parser generates
755 * an import list from Foo module for "Foo.Bar" style
758 impMod
= LookupImportModule (currMod
, bv
->a
.importValueRef
->moduleName
);
760 if (impMod
== NULL
) /* whoa, compiler error */
762 currMod
->status
= MOD_ERROR
;
763 fprintf (stderr
,"Compiler Error: \"%s.%s\" valueref - no import list defined from module \"%s\".\n", bv
->a
.importValueRef
->moduleName
, bv
->a
.importValueRef
->valueName
, bv
->a
.importValueRef
->moduleName
);
767 impElmt
= LookupImportElmtInImportElmtList (impMod
->importElmts
, bv
->a
.importValueRef
->valueName
);
769 if (impElmt
== NULL
) /* whoa, compiler error again */
771 currMod
->status
= MOD_ERROR
;
772 fprintf (stderr
,"Compiler Error: \"%s.%s\" valueref - no import element defined for value \"%s\".\n", bv
->a
.importValueRef
->moduleName
, bv
->a
.importValueRef
->valueName
, bv
->a
.importValueRef
->valueName
);
776 else if (impElmt
->resolvedRef
!= NULL
)
778 if (impElmt
->resolvedRef
->choiceId
!=
779 IMPORTELMTCHOICE_VALUE
)
780 fprintf (stderr
,"Linker Warning: import VALUE ref \"%s\" resolves with an imported TYPE\n", impElmt
->name
);
782 bv
->a
.importValueRef
->link
= impElmt
->resolvedRef
->a
.value
;
783 bv
->a
.importValueRef
->module = impMod
->moduleRef
;
787 PrintErrLoc (currMod
->asn1SrcFileName
, v
->lineNo
);
788 fprintf (stderr
,"reference to unresolved imported value \"%s\"\n", impElmt
->name
);
793 impElmt
= LookupImportElmtInModule (currMod
, bv
->a
.importValueRef
->valueName
, &impMod
);
794 if ((impElmt
!= NULL
) && (!impElmt
->privateScope
))
797 * if import elmt is resolved then
801 if (impElmt
->resolvedRef
!= NULL
)
803 if (impElmt
->resolvedRef
->choiceId
!=
804 IMPORTELMTCHOICE_VALUE
)
805 fprintf (stderr
,"Linker Warning: import VALUE ref \"%s\" resolves with an imported TYPE\n", impElmt
->name
);
807 bv
->a
.importValueRef
->link
= impElmt
->resolvedRef
->a
.value
;
808 bv
->a
.importValueRef
->module = impMod
->moduleRef
;
812 PrintErrLoc (currMod
->asn1SrcFileName
, v
->lineNo
);
813 fprintf (stderr
,"reference to unresolved imported value \"%s\"\n", impElmt
->name
);
818 * third, look for values defined in the useful module
820 else if ((usefulTypeModG
!= NULL
) &&
821 ((tmpValueDef
= LookupValue (usefulTypeModG
->valueDefs
, bv
->a
.localValueRef
->valueName
)) != NULL
))
823 bv
->a
.localValueRef
->link
= tmpValueDef
;
824 bv
->a
.localValueRef
->module = usefulTypeModG
;
829 * value not defined locally, nor imported nor
830 * defined in useful types module
832 currMod
->status
= MOD_ERROR
;
833 PrintErrLoc (currMod
->asn1SrcFileName
, v
->lineNo
);
834 fprintf (stderr
,"ERROR - value \"%s\" is referenced but not defined or imported.\n", bv
->a
.importValueRef
->valueName
);
839 case BASICVALUE_LINKEDOID
:
840 ValueLinkOid (m
, currMod
, head
, v
, bv
->a
.linkedOid
);
844 fprintf (stderr
,"ValueLinkBasicValue: ERROR - unknown value type\n");
847 } /* ValueLinkBasicValue */
851 * link the value refs from an object identifier
855 * for { ccitt foo (1) bar bell (bunt) 2 } the format is
858 * arcnum is set to number from oid table (oid.c)
860 * - arc num is set to 1
861 * - sets up a new value def foo defined as 1
862 * - makes oid valueref a value ref to foo (doesn't link it tho)
864 * - makes oid valueref a value ref to bar (doesn't link it tho)
866 * - sets up a new value def bell defined as a val ref to bunt
867 * - makes oid valueref a value ref to bell (doesn't link it tho)
869 * -arc num is set to 2
873 ValueLinkOid
PARAMS ((m
, currMod
, head
, v
, oid
),
875 Module
*currMod _AND_
880 ValueDef
*tmpValueDef
;
882 ImportModule
*impMod
;
888 * WARNING: for cyclic oid value definintions like.
889 * foo OID ::= { bar 1 3 }
890 * bar OID ::= { foo 1 3 }
891 * infinite recursion is prevented by
892 * a hack (linkOidCallDepth)
894 if (linkOidCallDepthG
> 100)
896 currMod
->status
= MOD_ERROR
;
897 PrintErrLoc (currMod
->asn1SrcFileName
, v
->lineNo
);
898 fprintf (stderr
,"ERROR - OBJECT IDENTIFIER value \"%s\" appears to be defined recursively\n", head
->definedName
);
899 linkOidCallDepthG
= 0;
905 for (firstElmt
= oid
; oid
!= NULL
; oid
= oid
->next
)
907 if (oid
->valueRef
!= NULL
)
909 ValueLinkValue (m
, currMod
, head
, NULL
, oid
->valueRef
);
911 if ((oid
->valueRef
->basicValue
->choiceId
!=
912 BASICVALUE_LOCALVALUEREF
) &&
913 (oid
->valueRef
->basicValue
->choiceId
!=
914 BASICVALUE_IMPORTVALUEREF
))
916 fprintf (stderr
,"Internal error: Oid valueref is not a ref\n");
917 break; /* exit for */
921 * leave simplification (replacement of value refs with values)
922 * of oid values to normalize.c
933 ValueLinkRosOperationMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, op
),
935 Module
*currMod _AND_
939 RosOperationMacroType
*op
)
943 if (op
->arguments
!= NULL
)
944 ValueLinkType (m
, currMod
, head
, op
->arguments
->type
);
946 if (op
->result
!= NULL
)
947 ValueLinkType (m
, currMod
, head
, op
->result
->type
);
950 * go through errors (if any) and link types/values
952 FOR_EACH_LIST_ELMT (tOrV
, op
->errors
)
954 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
955 ValueLinkType (m
, currMod
, head
, tOrV
->a
.type
);
957 ValueLinkValue (m
, currMod
, NULL
, t
, tOrV
->a
.value
);
961 * go through linked operations (if any) and
964 FOR_EACH_LIST_ELMT (tOrV
, op
->linkedOps
)
966 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
967 ValueLinkType (m
, currMod
, head
, tOrV
->a
.type
);
969 ValueLinkValue (m
, currMod
, NULL
, t
, tOrV
->a
.value
);
971 } /* ValueLinkRosOperationMacroType */
975 ValueLinkRosErrorMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, err
),
977 Module
*currMod _AND_
981 RosErrorMacroType
*err
)
983 if ((err
!= NULL
) && (err
->parameter
!= NULL
))
985 ValueLinkType (m
, currMod
, head
, err
->parameter
->type
);
987 } /* ValueLinkRosErrorMacroType */
991 ValueLinkRosBindMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, bind
),
993 Module
*currMod _AND_
997 RosBindMacroType
*bind
)
1001 ValueLinkElmtType (m
, currMod
, head
, bind
->argument
);
1002 ValueLinkElmtType (m
, currMod
, head
, bind
->result
);
1003 ValueLinkElmtType (m
, currMod
, head
, bind
->error
);
1005 } /* ValueLinkRosBindMacroType */
1009 ValueLinkRosAseMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, ase
),
1011 Module
*currMod _AND_
1015 RosAseMacroType
*ase
)
1019 FOR_EACH_LIST_ELMT (v
, ase
->operations
)
1020 ValueLinkValue (m
, currMod
, NULL
, t
, v
);
1023 FOR_EACH_LIST_ELMT (v
, ase
->consumerInvokes
)
1024 ValueLinkValue (m
, currMod
, NULL
, t
, v
);
1027 FOR_EACH_LIST_ELMT (v
, ase
->supplierInvokes
)
1028 ValueLinkValue (m
, currMod
, NULL
, t
, v
);
1030 } /* ValueLinkRosAseMacroType */
1035 ValueLinkRosAcMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, ac
),
1037 Module
*currMod _AND_
1046 FOR_EACH_LIST_ELMT (v
, ac
->nonRoElements
)
1047 ValueLinkValue (m
, currMod
, NULL
, t
, v
);
1050 ValueLinkType (m
, currMod
, head
, ac
->bindMacroType
);
1051 ValueLinkType (m
, currMod
, head
, ac
->unbindMacroType
);
1053 FOR_EACH_LIST_ELMT (v
, ac
->operationsOf
)
1054 ValueLinkValue (m
, currMod
, NULL
, t
, v
);
1057 FOR_EACH_LIST_ELMT (v
, ac
->initiatorConsumerOf
)
1058 ValueLinkValue (m
, currMod
, NULL
, t
, v
);
1061 FOR_EACH_LIST_ELMT (v
, ac
->responderConsumerOf
)
1062 ValueLinkValue (m
, currMod
, NULL
, t
, v
);
1065 FOR_EACH_LIST_ELMT (oid
, ac
->abstractSyntaxes
)
1066 ValueLinkOid (m
, currMod
, NULL
, NULL
, oid
);
1068 } /* ValueLinkRosAcMacroType */
1073 ValueLinkMtsasExtensionsMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, exts
),
1075 Module
*currMod _AND_
1079 MtsasExtensionsMacroType
*exts
)
1083 FOR_EACH_LIST_ELMT (v
, exts
->extensions
)
1084 ValueLinkValue (m
, currMod
, NULL
, t
, v
);
1086 } /* ValueLinkMtsasExtensionsMacroType */
1090 ValueLinkMtsasExtensionMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, ext
),
1092 Module
*currMod _AND_
1096 MtsasExtensionMacroType
*ext
)
1098 ValueLinkElmtType (m
, currMod
, head
, ext
->elmtType
);
1099 ValueLinkValue (m
, currMod
, NULL
, t
, ext
->defaultValue
);
1101 } /* ValueLinkMtsasExtensionMacroType */
1105 ValueLinkMtsasExtensionAttributeMacroType
PARAMS ((m
, currMod
, head
, t
,bt
, ext
),
1107 Module
*currMod _AND_
1111 MtsasExtensionAttributeMacroType
*ext
)
1115 ValueLinkType (m
, currMod
, head
, ext
->type
);
1117 } /* ValueLinkMtsasExtensionAttributeMacroType */
1121 ValueLinkMtsasTokenMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, tok
),
1123 Module
*currMod _AND_
1127 MtsasTokenMacroType
*tok
)
1130 ValueLinkType (m
, currMod
, head
, tok
->type
);
1132 } /* ValueLinkMtsasTokenMacroType */
1136 ValueLinkMtsasTokenDataMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, tok
),
1138 Module
*currMod _AND_
1142 MtsasTokenDataMacroType
*tok
)
1145 ValueLinkType (m
, currMod
, head
, tok
->type
);
1147 } /* ValueLinkMtsasTokenDataMacroType */
1150 ValueLinkMtsasSecurityCategoryMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, sec
),
1152 Module
*currMod _AND_
1156 MtsasSecurityCategoryMacroType
*sec
)
1160 ValueLinkType (m
, currMod
, head
, sec
->type
);
1162 } /* ValueLinkMtsasSecurityCategoryMacroType */
1167 ValueLinkAsnObjectMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, obj
),
1169 Module
*currMod _AND_
1173 AsnObjectMacroType
*obj
)
1177 FOR_EACH_LIST_ELMT (ap
, obj
->ports
)
1178 ValueLinkValue (m
, currMod
, NULL
, t
, ap
->portValue
);
1180 } /* ValueLinkAsnObjectMacroType */
1184 ValueLinkAsnPortMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, p
),
1186 Module
*currMod _AND_
1190 AsnPortMacroType
*p
)
1194 FOR_EACH_LIST_ELMT (tOrV
, p
->abstractOps
)
1196 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1197 ValueLinkType (m
, currMod
, head
, tOrV
->a
.type
);
1199 ValueLinkValue (m
, currMod
, NULL
, t
, tOrV
->a
.value
);
1203 FOR_EACH_LIST_ELMT (tOrV
, p
->supplierInvokes
)
1205 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1206 ValueLinkType (m
, currMod
, head
, tOrV
->a
.type
);
1208 ValueLinkValue (m
, currMod
, NULL
, t
, tOrV
->a
.value
);
1212 FOR_EACH_LIST_ELMT (tOrV
, p
->consumerInvokes
)
1214 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1215 ValueLinkType (m
, currMod
, head
, tOrV
->a
.type
);
1217 ValueLinkValue (m
, currMod
, NULL
, t
, tOrV
->a
.value
);
1220 } /* ValueLinkAsnPortMacroType */
1225 ValueLinkAsnAbstractBindMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, bind
),
1227 Module
*currMod _AND_
1231 AsnAbstractBindMacroType
*bind
)
1235 FOR_EACH_LIST_ELMT (ap
, bind
->ports
)
1236 ValueLinkValue (m
, currMod
, NULL
, t
, ap
->portValue
);
1238 } /* ValueLinkAsnBindMacroType */
1243 ValueLinkSnmpObjectTypeMacroType
PARAMS ((m
, currMod
, head
, t
, bt
, ot
),
1245 Module
*currMod _AND_
1249 SnmpObjectTypeMacroType
*ot
)
1253 ValueLinkType (m
, currMod
, head
, ot
->syntax
);
1254 ValueLinkValue (m
, currMod
, NULL
, t
, ot
->description
);
1255 ValueLinkValue (m
, currMod
, NULL
, t
, ot
->reference
);
1256 ValueLinkValue (m
, currMod
, NULL
, t
, ot
->defVal
);
1258 FOR_EACH_LIST_ELMT (tOrV
, ot
->index
)
1260 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1261 ValueLinkType (m
, currMod
, head
, tOrV
->a
.type
);
1263 ValueLinkValue (m
, currMod
, NULL
, t
, tOrV
->a
.value
);
1266 } /* ValueLinkSnmpObjectTypeMacroType */