2 * compiler/core/snacc_util.h
4 * Copyright (C) 1992 Michael Sample and the University of British Columbia
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/core/snacc-util.h,v 1.1 2001/06/20 21:27:59 dmitch Exp $
12 * $Log: snacc-util.h,v $
13 * Revision 1.1 2001/06/20 21:27:59 dmitch
14 * Adding missing snacc compiler files.
16 * Revision 1.1.1.1 1999/03/16 18:06:52 aram
17 * Originals from SMIME Free Library.
19 * Revision 1.3 1995/07/25 19:41:46 rj
20 * changed `_' to `-' in file names.
22 * Revision 1.2 1994/09/01 00:46:41 rj
23 * snacc_config.h's 2nd last macro, PrintErrLoc(), got here.
25 * Revision 1.1 1994/08/28 09:49:41 rj
26 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
30 #define PrintErrLoc( fileName, lineNo)\
31 fprintf (stderr, "file \"%s\", line %d: ", fileName, lineNo)
34 * macro to allocate room for str & null & put in give STR*
36 #define SETUP_STR( strPtr, string)\
37 (strPtr)->str = Malloc (strlen (string) + 1);\
38 strcpy ((strPtr)->str, string);\
39 (strPtr)->len = strlen (string) + 1
43 * Create a new list type such that each elmt has space
46 #define NEWLIST() AsnListNew (sizeof (void *))
49 * macro to append an element to the end of linked list
50 * - helps on left recursion when order must be maintained
52 * be careful of calling context if list is null
53 * that is, make sure the change to list is not lost.
55 #define APPEND( elmt, list) \
60 tmpPtr = (void **) AsnListAppend ((AsnList *)list);\
61 *tmpPtr = (void *) (elmt);\
65 * like APPEND except puts elmt at head of list
67 #define PREPEND( elmt, list) \
72 tmpPtr = (void **)AsnListPrepend ((AsnList *)list);\
73 *tmpPtr = (void *) (elmt);\
76 void SetupType
PROTO ((Type
**t
, enum BasicTypeChoiceId typeId
, unsigned long lineNum
));
78 void SetupMacroType
PROTO ((Type
**t
, enum MacroTypeChoiceId macroTypeId
, unsigned long lineNum
));
80 void SetupValue
PROTO ((Value
**v
, enum BasicValueChoiceId valId
, unsigned long lineNum
));
83 void AddPrivateImportElmt
PROTO ((Module
*m
, char *name
, char *refModuleName
, long int lineNo
));
85 ImportElmt
*LookupImportElmtInModule
PROTO ((Module
*m
, char *name
, ImportModule
**importModule
));
87 ImportElmt
*LookupImportElmtInImportElmtList
PROTO ((ImportElmtList
*importElmtList
, char *name
));
89 ImportModule
*LookupImportModule
PROTO ((Module
*m
, char *importModuleName
));
91 TypeDef
*LookupType
PROTO ((TypeDefList
*t
, char *typeName
));
93 Module
*LookupModule
PROTO ((ModuleList
*m
, char *modName
, OID
*oid
));
95 NamedType
*LookupFieldInType
PROTO ((Type
*t
, char *fieldName
));
97 Type
*GetType
PROTO ((Type
*t
));
99 Type
*ParanoidGetType
PROTO ((Type
*t
));
101 enum BasicTypeChoiceId GetBuiltinType
PROTO ((Type
*t
));
103 NamedNumberList
*GetNamedElmts
PROTO ((Type
*t
));
105 NamedNumberList
*GetAllNamedElmts
PROTO ((Type
*t
));
107 Type
*GetParent
PROTO ((Type
*ancestor
, Type
*child
));
109 ValueDef
*LookupValue
PROTO ((ValueDefList
*v
, char *valueName
));
111 Value
*GetValue
PROTO ((Value
*v
));
113 int CompareOids
PROTO ((OID
*oid1
, OID
*oid2
));
115 int HasNamedElmts
PROTO ((Type
*t
));
117 int TagsAreIdentical
PROTO ((TagList
*t1
, TagList
*t2
));
119 int HasDefaultTag
PROTO ((Type
*t
));
121 int IsPrimitiveByDefOrRef
PROTO ((Type
*t
));
123 int IsPrimitiveByDef
PROTO ((Type
*t
));
125 int IsDefinedByLibraryType
PROTO ((Type
*t
));
127 int IsTypeRef
PROTO ((Type
*t
));
129 int IsNewType
PROTO ((Type
*t
));
131 int IsTailOptional
PROTO ((NamedTypeList
*e
));
133 int NextIsTailOptional
PROTO ((NamedTypeList
*e
));
135 int AllElmtsOptional
PROTO ((NamedTypeList
*e
));
137 AnyRefList
**GetAnyRefListHndl
PROTO ((Type
*t
));
139 void AppendSubtype
PROTO ((Subtype
**s
, Subtype
*newSubtype
, enum SubtypeChoiceId op
));