Ajout de tables de hash dans la figure CTL
This commit is contained in:
parent
942970ddc1
commit
f9c74c25c0
|
@ -57,8 +57,10 @@
|
||||||
|
|
||||||
# define CTL_DECLAR_ALL 0
|
# define CTL_DECLAR_ALL 0
|
||||||
# define CTL_DECLAR_VARIABLE 1
|
# define CTL_DECLAR_VARIABLE 1
|
||||||
# define CTL_DECLAR_CONSTANT 2
|
# define CTL_DECLAR_DEFINE 2
|
||||||
# define CTL_MAX_DECLAR_TYPE 3
|
# define CTL_DECLAR_ASSUME 3
|
||||||
|
# define CTL_DECLAR_INITIAL 4
|
||||||
|
# define CTL_MAX_DECLAR_TYPE 5
|
||||||
|
|
||||||
/*------------------------------------------------------\
|
/*------------------------------------------------------\
|
||||||
| |
|
| |
|
||||||
|
@ -82,7 +84,9 @@
|
||||||
|
|
||||||
# define GetCtlNumDecl( F ) ((F)->HASH_DECLAR[ CTL_DECLAR_ALL ]->NUMBER_ELEM)
|
# define GetCtlNumDecl( F ) ((F)->HASH_DECLAR[ CTL_DECLAR_ALL ]->NUMBER_ELEM)
|
||||||
# define GetCtlNumDeclVar( F ) ((F)->HASH_DECLAR[ CTL_DECLAR_VARIABLE ]->NUMBER_ELEM)
|
# define GetCtlNumDeclVar( F ) ((F)->HASH_DECLAR[ CTL_DECLAR_VARIABLE ]->NUMBER_ELEM)
|
||||||
# define GetCtlNumDeclCst( F ) ((F)->HASH_DECLAR[ CTL_DECLAR_CONSTANT ]->NUMBER_ELEM)
|
# define GetCtlNumDeclDef( F ) ((F)->HASH_DECLAR[ CTL_DECLAR_DEFINE ]->NUMBER_ELEM)
|
||||||
|
# define GetCtlNumDeclAss( F ) ((F)->HASH_DECLAR[ CTL_DECLAR_ASSUME ]->NUMBER_ELEM)
|
||||||
|
# define GetCtlNumDeclInit( F ) ((F)->HASH_DECLAR[ CTL_DECLAR_INITIAL ]->NUMBER_ELEM)
|
||||||
|
|
||||||
/*------------------------------------------------------\
|
/*------------------------------------------------------\
|
||||||
| |
|
| |
|
||||||
|
@ -92,8 +96,12 @@
|
||||||
|
|
||||||
# define searchctlsymvar( F, N, I ) \
|
# define searchctlsymvar( F, N, I ) \
|
||||||
(searchctlsym( (F), (N), (I), CTL_DECLAR_VARIABLE ))
|
(searchctlsym( (F), (N), (I), CTL_DECLAR_VARIABLE ))
|
||||||
# define searchctlsymcst( F, N, I ) \
|
# define searchctlsymdef( F, N, I ) \
|
||||||
(searchctlsym( (F), (N), (I), CTL_DECLAR_CONSTANT ))
|
(searchctlsym( (F), (N), (I), CTL_DECLAR_DEFINE ))
|
||||||
|
# define searchctlsymass( F, N, I ) \
|
||||||
|
(searchctlsym( (F), (N), (I), CTL_DECLAR_ASSUME ))
|
||||||
|
# define searchctlsyminit( F, N, I ) \
|
||||||
|
(searchctlsym( (F), (N), (I), CTL_DECLAR_INITIAL ))
|
||||||
# define searchctlsymall( F, N, I ) \
|
# define searchctlsymall( F, N, I ) \
|
||||||
(searchctlsym( (F), (N), (I), CTL_DECLAR_ALL ))
|
(searchctlsym( (F), (N), (I), CTL_DECLAR_ALL ))
|
||||||
|
|
||||||
|
@ -105,8 +113,12 @@
|
||||||
|
|
||||||
# define searchctldeclvar( F, N ) \
|
# define searchctldeclvar( F, N ) \
|
||||||
(searchctldecl( (F), (N), CTL_DECLAR_VARIABLE ))
|
(searchctldecl( (F), (N), CTL_DECLAR_VARIABLE ))
|
||||||
# define searchctldeclcst( F, N ) \
|
# define searchctldecldef( F, N ) \
|
||||||
(searchctldecl( (F), (N), CTL_DECLAR_CONSTANT ))
|
(searchctldecl( (F), (N), CTL_DECLAR_DEFINE ))
|
||||||
|
# define searchctldeclass( F, N ) \
|
||||||
|
(searchctldecl( (F), (N), CTL_DECLAR_ASSUME ))
|
||||||
|
# define searchctldeclinit( F, N ) \
|
||||||
|
(searchctldecl( (F), (N), CTL_DECLAR_INITIAL ))
|
||||||
# define searchctldeclall( F, N ) \
|
# define searchctldeclall( F, N ) \
|
||||||
(searchctldecl( (F), (N), CTL_DECLAR_ALL ))
|
(searchctldecl( (F), (N), CTL_DECLAR_ALL ))
|
||||||
|
|
||||||
|
@ -219,7 +231,9 @@
|
||||||
struct ctlfig_list *NEXT;
|
struct ctlfig_list *NEXT;
|
||||||
char *NAME;
|
char *NAME;
|
||||||
ctltype_list *TYPE;
|
ctltype_list *TYPE;
|
||||||
|
authtable *HASH_TYPE;
|
||||||
ctlform_list *FORM;
|
ctlform_list *FORM;
|
||||||
|
authtable *HASH_FORM;
|
||||||
ctldecl_list *DECLAR[ CTL_MAX_DECLAR_TYPE ];
|
ctldecl_list *DECLAR[ CTL_MAX_DECLAR_TYPE ];
|
||||||
authtable *HASH_DECLAR[ CTL_MAX_DECLAR_TYPE ];
|
authtable *HASH_DECLAR[ CTL_MAX_DECLAR_TYPE ];
|
||||||
void *CIRCUIT;
|
void *CIRCUIT;
|
||||||
|
@ -288,7 +302,9 @@
|
||||||
|
|
||||||
extern ctldecl_list *addctldecl __P((ctlfig_list *Figure, vexexpr *Atom, unsigned char Type ));
|
extern ctldecl_list *addctldecl __P((ctlfig_list *Figure, vexexpr *Atom, unsigned char Type ));
|
||||||
extern ctldecl_list *addctldeclvar __P((ctlfig_list *Figure, vexexpr *Atom));
|
extern ctldecl_list *addctldeclvar __P((ctlfig_list *Figure, vexexpr *Atom));
|
||||||
extern ctldecl_list *addctldeclcst __P((ctlfig_list *Figure, vexexpr *Atom));
|
extern ctldecl_list *addctldecldef __P((ctlfig_list *Figure, vexexpr *Atom));
|
||||||
|
extern ctldecl_list *addctldeclass __P((ctlfig_list *Figure, vexexpr *Atom));
|
||||||
|
extern ctldecl_list *addctldeclinit __P((ctlfig_list *Figure, vexexpr *Atom));
|
||||||
|
|
||||||
extern ctlline_list *addctlline __P((ctlfig_list *Figure, ctlline_list **HeadLine, long Line));
|
extern ctlline_list *addctlline __P((ctlfig_list *Figure, ctlline_list **HeadLine, long Line));
|
||||||
extern ctlline_list *addctlfileline __P((ctlfig_list *Figure, ctlline_list **HeadLine, char *File, long Line));
|
extern ctlline_list *addctlfileline __P((ctlfig_list *Figure, ctlline_list **HeadLine, char *File, long Line));
|
||||||
|
|
|
@ -72,7 +72,9 @@
|
||||||
{
|
{
|
||||||
"ALL",
|
"ALL",
|
||||||
"VARIABLE",
|
"VARIABLE",
|
||||||
"CONSTANT"
|
"DEFINE",
|
||||||
|
"ASSUME",
|
||||||
|
"INITIAL"
|
||||||
};
|
};
|
||||||
|
|
||||||
/*------------------------------------------------------------\
|
/*------------------------------------------------------------\
|
||||||
|
@ -109,6 +111,9 @@ ctlfig_list *addctlfig( Name )
|
||||||
Figure->HASH_DECLAR[ Type ] = createauthtable( 50 );
|
Figure->HASH_DECLAR[ Type ] = createauthtable( 50 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Figure->HASH_FORM = createauthtable( 50 );
|
||||||
|
Figure->HASH_TYPE = createauthtable( 50 );
|
||||||
|
|
||||||
return( Figure );
|
return( Figure );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,51 +244,109 @@ ctldecl_list *addctldeclvar( Figure, Atom )
|
||||||
ctlfig_list *Figure;
|
ctlfig_list *Figure;
|
||||||
vexexpr *Atom;
|
vexexpr *Atom;
|
||||||
{
|
{
|
||||||
ctldecl_list *Constant;
|
ctldecl_list *Variable;
|
||||||
char *Name;
|
char *Name;
|
||||||
|
|
||||||
if ( ! IsVexNodeAtom( Atom ) ) Name = getvexarrayname( Atom );
|
if ( ! IsVexNodeAtom( Atom ) ) Name = getvexarrayname( Atom );
|
||||||
else Name = GetVexAtomValue( Atom );
|
else Name = GetVexAtomValue( Atom );
|
||||||
|
|
||||||
Constant = searchctldeclall( Figure, Name );
|
Variable = searchctldeclall( Figure, Name );
|
||||||
|
|
||||||
if ( Constant != (ctldecl_list *)0 )
|
if ( Variable != (ctldecl_list *)0 )
|
||||||
{
|
{
|
||||||
ctlerror( CTL_VARIABLE_EXIST_ERROR, Name, 0 );
|
ctlerror( CTL_DECLAR_EXIST_ERROR, Name, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant = loc_addctldecl( Figure, Atom, CTL_DECLAR_VARIABLE );
|
Variable = loc_addctldecl( Figure, Atom, CTL_DECLAR_VARIABLE );
|
||||||
|
|
||||||
return( Constant );
|
return( Variable );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------\
|
/*------------------------------------------------------------\
|
||||||
| |
|
| |
|
||||||
| Ctl Add Declaration Constant |
|
| Ctl Add Declaration Define |
|
||||||
| |
|
| |
|
||||||
\------------------------------------------------------------*/
|
\------------------------------------------------------------*/
|
||||||
|
|
||||||
ctldecl_list *addctldeclcst( Figure, Atom )
|
ctldecl_list *addctldecldef( Figure, Atom )
|
||||||
|
|
||||||
ctlfig_list *Figure;
|
ctlfig_list *Figure;
|
||||||
vexexpr *Atom;
|
vexexpr *Atom;
|
||||||
{
|
{
|
||||||
ctldecl_list *Constant;
|
ctldecl_list *Define;
|
||||||
char *Name;
|
char *Name;
|
||||||
|
|
||||||
if ( ! IsVexNodeAtom( Atom ) ) Name = getvexarrayname( Atom );
|
if ( ! IsVexNodeAtom( Atom ) ) Name = getvexarrayname( Atom );
|
||||||
else Name = GetVexAtomValue( Atom );
|
else Name = GetVexAtomValue( Atom );
|
||||||
|
|
||||||
Constant = searchctldeclall( Figure, Name );
|
Define = searchctldeclall( Figure, Name );
|
||||||
|
|
||||||
if ( Constant != (ctldecl_list *)0 )
|
if ( Define != (ctldecl_list *)0 )
|
||||||
{
|
{
|
||||||
ctlerror( CTL_CONSTANT_EXIST_ERROR, Name, 0 );
|
ctlerror( CTL_DECLAR_EXIST_ERROR, Name, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant = loc_addctldecl( Figure, Atom, CTL_DECLAR_CONSTANT );
|
Define = loc_addctldecl( Figure, Atom, CTL_DECLAR_DEFINE );
|
||||||
|
|
||||||
return( Constant );
|
return( Define );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------\
|
||||||
|
| |
|
||||||
|
| Ctl Add Declaration Assume |
|
||||||
|
| |
|
||||||
|
\------------------------------------------------------------*/
|
||||||
|
|
||||||
|
ctldecl_list *addctldeclass( Figure, Atom )
|
||||||
|
|
||||||
|
ctlfig_list *Figure;
|
||||||
|
vexexpr *Atom;
|
||||||
|
{
|
||||||
|
ctldecl_list *Assume;
|
||||||
|
char *Name;
|
||||||
|
|
||||||
|
if ( ! IsVexNodeAtom( Atom ) ) Name = getvexarrayname( Atom );
|
||||||
|
else Name = GetVexAtomValue( Atom );
|
||||||
|
|
||||||
|
Assume = searchctldeclall( Figure, Name );
|
||||||
|
|
||||||
|
if ( Assume != (ctldecl_list *)0 )
|
||||||
|
{
|
||||||
|
ctlerror( CTL_DECLAR_EXIST_ERROR, Name, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
Assume = loc_addctldecl( Figure, Atom, CTL_DECLAR_ASSUME );
|
||||||
|
|
||||||
|
return( Assume );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------\
|
||||||
|
| |
|
||||||
|
| Ctl Add Declaration Initial |
|
||||||
|
| |
|
||||||
|
\------------------------------------------------------------*/
|
||||||
|
|
||||||
|
ctldecl_list *addctldeclinit( Figure, Atom )
|
||||||
|
|
||||||
|
ctlfig_list *Figure;
|
||||||
|
vexexpr *Atom;
|
||||||
|
{
|
||||||
|
ctldecl_list *Initial;
|
||||||
|
char *Name;
|
||||||
|
|
||||||
|
if ( ! IsVexNodeAtom( Atom ) ) Name = getvexarrayname( Atom );
|
||||||
|
else Name = GetVexAtomValue( Atom );
|
||||||
|
|
||||||
|
Initial = searchctldeclall( Figure, Name );
|
||||||
|
|
||||||
|
if ( Initial != (ctldecl_list *)0 )
|
||||||
|
{
|
||||||
|
ctlerror( CTL_DECLAR_EXIST_ERROR, Name, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
Initial = loc_addctldecl( Figure, Atom, CTL_DECLAR_INITIAL );
|
||||||
|
|
||||||
|
return( Initial );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------\
|
/*------------------------------------------------------------\
|
||||||
|
@ -371,6 +434,8 @@ ctlform_list *addctlform( Figure, Name, Expr )
|
||||||
|
|
||||||
*(Form->PREV) = Form;
|
*(Form->PREV) = Form;
|
||||||
|
|
||||||
|
addauthelem( Figure->HASH_FORM, Name, (long)Form );
|
||||||
|
|
||||||
return( Form );
|
return( Form );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,6 +473,8 @@ ctltype_list *addctltype( Figure, Name, Index,
|
||||||
Type->BASE = Base;
|
Type->BASE = Base;
|
||||||
Figure->TYPE = Type;
|
Figure->TYPE = Type;
|
||||||
|
|
||||||
|
addauthelem( Figure->HASH_TYPE, Name, (long)Type );
|
||||||
|
|
||||||
return( Type );
|
return( Type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,8 @@ int delctlfig( Name )
|
||||||
destroyauthtable( Figure->HASH_DECLAR[ Type ] );
|
destroyauthtable( Figure->HASH_DECLAR[ Type ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroyauthtable( Figure->HASH_FORM );
|
||||||
|
|
||||||
ScanForm = Figure->FORM;
|
ScanForm = Figure->FORM;
|
||||||
|
|
||||||
while ( ScanForm != (ctlform_list *)0 )
|
while ( ScanForm != (ctlform_list *)0 )
|
||||||
|
@ -177,6 +179,8 @@ int delctlfig( Name )
|
||||||
freectlform( Delete );
|
freectlform( Delete );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroyauthtable( Figure->HASH_TYPE );
|
||||||
|
|
||||||
ScanType = Figure->TYPE;
|
ScanType = Figure->TYPE;
|
||||||
|
|
||||||
while ( ScanType != (ctltype_list *)0 )
|
while ( ScanType != (ctltype_list *)0 )
|
||||||
|
|
|
@ -97,12 +97,6 @@ void ctl_error( Error, Text1, Text2, File, Line )
|
||||||
case CTL_UNKNOWN_DECLAR_TYPE :
|
case CTL_UNKNOWN_DECLAR_TYPE :
|
||||||
fprintf( stderr, "unknown declar type %ld for %s\n", (long)Text1, Text2 );
|
fprintf( stderr, "unknown declar type %ld for %s\n", (long)Text1, Text2 );
|
||||||
break;
|
break;
|
||||||
case CTL_VARIABLE_EXIST_ERROR :
|
|
||||||
fprintf( stderr, "variable %s exists already\n", Text1 );
|
|
||||||
break;
|
|
||||||
case CTL_CONSTANT_EXIST_ERROR :
|
|
||||||
fprintf( stderr, "constant %s exists already\n", Text1 );
|
|
||||||
break;
|
|
||||||
case CTL_DECLAR_EXIST_ERROR :
|
case CTL_DECLAR_EXIST_ERROR :
|
||||||
fprintf( stderr, "symbol %s already declared\n", Text1 );
|
fprintf( stderr, "symbol %s already declared\n", Text1 );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -52,14 +52,12 @@
|
||||||
| |
|
| |
|
||||||
\------------------------------------------------------------*/
|
\------------------------------------------------------------*/
|
||||||
|
|
||||||
# define CTL_VARIABLE_EXIST_ERROR 0
|
# define CTL_UNKNOWN_DECLAR_TYPE 1
|
||||||
# define CTL_CONSTANT_EXIST_ERROR 1
|
# define CTL_UNDECLARED_SYMBOL 2
|
||||||
# define CTL_UNKNOWN_DECLAR_TYPE 2
|
# define CTL_DECLAR_EXIST_ERROR 3
|
||||||
# define CTL_UNDECLARED_SYMBOL 3
|
# define CTL_BAD_DECLAR_TYPE 4
|
||||||
# define CTL_DECLAR_EXIST_ERROR 4
|
# define CTL_ILLEGAL_INDEX_ERROR 5
|
||||||
# define CTL_BAD_DECLAR_TYPE 5
|
# define CTL_ILLEGAL_POSITION_ERROR 6
|
||||||
# define CTL_ILLEGAL_INDEX_ERROR 6
|
|
||||||
# define CTL_ILLEGAL_POSITION_ERROR 7
|
|
||||||
|
|
||||||
/*------------------------------------------------------------\
|
/*------------------------------------------------------------\
|
||||||
| |
|
| |
|
||||||
|
|
|
@ -210,18 +210,17 @@ ctlform_list *searchctlform( Figure, Name )
|
||||||
ctlfig_list *Figure;
|
ctlfig_list *Figure;
|
||||||
char *Name;
|
char *Name;
|
||||||
{
|
{
|
||||||
ctlform_list *Form;
|
authelem *Element;
|
||||||
|
|
||||||
Name = namealloc( Name );
|
Name = namealloc( Name );
|
||||||
|
Element = searchauthelem( Figure->HASH_FORM, Name );
|
||||||
|
|
||||||
for ( Form = Figure->FORM;
|
if ( Element != (authelem *)0 )
|
||||||
Form != (ctlform_list *)0;
|
|
||||||
Form = Form->NEXT )
|
|
||||||
{
|
{
|
||||||
if ( Form->NAME == Name ) break;
|
return( (ctlform_list *)( Element->VALUE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( Form );
|
return( (ctlform_list *)0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------\
|
/*------------------------------------------------------------\
|
||||||
|
@ -235,17 +234,16 @@ ctltype_list *searchctltype( Figure, Name )
|
||||||
ctlfig_list *Figure;
|
ctlfig_list *Figure;
|
||||||
char *Name;
|
char *Name;
|
||||||
{
|
{
|
||||||
ctltype_list *Type;
|
authelem *Element;
|
||||||
|
|
||||||
Name = namealloc( Name );
|
Name = namealloc( Name );
|
||||||
|
Element = searchauthelem( Figure->HASH_TYPE, Name );
|
||||||
|
|
||||||
for ( Type = Figure->TYPE;
|
if ( Element != (authelem *)0 )
|
||||||
Type != (ctltype_list *)0;
|
|
||||||
Type = Type->NEXT )
|
|
||||||
{
|
{
|
||||||
if ( Type->NAME == Name ) break;
|
return( (ctltype_list *)( Element->VALUE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( Type );
|
return( (ctltype_list *)0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,9 @@ void viewctldecl( Decl )
|
||||||
fprintf( stdout, "\n\t\tVEX_INIT : " );
|
fprintf( stdout, "\n\t\tVEX_INIT : " );
|
||||||
viewvexexprbound( Decl->VEX_INIT );
|
viewvexexprbound( Decl->VEX_INIT );
|
||||||
|
|
||||||
|
fprintf( stdout, "\n\t\tTYPE : %s",
|
||||||
|
( Decl->TYPE != (ctltype_list *)0 ) ? Decl->TYPE->NAME : "ERROR" );
|
||||||
|
|
||||||
fprintf( stdout, "\n\t\tDECL_SYM :\n" );
|
fprintf( stdout, "\n\t\tDECL_SYM :\n" );
|
||||||
|
|
||||||
DeclSym = Decl->DECL_SYM;
|
DeclSym = Decl->DECL_SYM;
|
||||||
|
|
Loading…
Reference in New Issue