- Moved special terms into their own (very) special file.

This commit is contained in:
ccremers 2005-06-16 14:10:07 +00:00
parent db18b203a9
commit b6e9841c0f
16 changed files with 95 additions and 88 deletions

View File

@ -32,16 +32,7 @@
#include "timer.h"
#include "type.h"
#include "switches.h"
extern Term CLAIM_Secret;
extern Term CLAIM_Nisynch;
extern Term CLAIM_Niagree;
extern Term CLAIM_Empty;
extern Term TERM_Agent;
extern Term TERM_Hidden;
extern Term TERM_Function;
extern Term TERM_Nonce;
#include "specialterm.h"
extern int *graph;
extern int nodes;

View File

@ -11,6 +11,7 @@
#include "substitution.h"
#include "compiler.h"
#include "switches.h"
#include "specialterm.h"
/*
Simple sys pointer as a global. Yields cleaner code although it's against programming standards.
@ -34,8 +35,6 @@ extern int protocolCount;
void tacProcess (Tac tc);
void levelInit (void);
void levelDone (void);
Term symbolDeclare (Symbol s, int isVar);
void levelTacDeclaration (Tac tc, int isVar);
Term levelFind (Symbol s, int i);
Term symbolFind (Symbol s);
Term tacTerm (Tac tc);
@ -43,29 +42,6 @@ Termlist tacTermlist (Tac tc);
Term levelDeclare (Symbol s, int isVar, int level);
void compute_role_variables (const System sys, Protocol p, Role r);
#define levelDeclareVar(s) levelTacDeclaration(s,1)
#define levelDeclareConst(s) levelTacDeclaration(s,0)
#define levelVar(s) symbolDeclare(s,1)
#define levelConst(s) symbolDeclare(s,0)
/* externally used:
* TERM_Function in termlists.c for inversekeys
* TERM_Type in system.c for type determination.
*/
Term TERM_Agent;
Term TERM_Function;
Term TERM_Hidden;
Term TERM_Type;
Term TERM_Nonce;
Term TERM_Ticket;
Term TERM_Claim;
Term CLAIM_Secret;
Term CLAIM_Nisynch;
Term CLAIM_Niagree;
Term CLAIM_Empty;
/*
* Global stuff
*/
@ -92,24 +68,8 @@ compilerInit (const System mysys)
level = -1;
levelInit ();
/* Init system constants */
#define langhide(x,y) x = levelConst(symbolSysConst(" _" y "_ "))
#define langtype(x,y) x->stype = termlistAdd(x->stype,y);
#define langcons(x,y,z) x = levelConst(symbolSysConst(y)); langtype(x,z)
langhide (TERM_Type, "Type");
langhide (TERM_Hidden, "Hidden");
langhide (TERM_Claim, "Claim");
langcons (TERM_Agent, "Agent", TERM_Type);
langcons (TERM_Function, "Function", TERM_Type);
langcons (TERM_Nonce, "Nonce", TERM_Type);
langcons (TERM_Ticket, "Ticket", TERM_Type);
langcons (CLAIM_Secret, "Secret", TERM_Claim);
langcons (CLAIM_Nisynch, "Nisynch", TERM_Claim);
langcons (CLAIM_Niagree, "Niagree", TERM_Claim);
langcons (CLAIM_Empty, "Empty", TERM_Claim);
/* create special terms */
specialTermInit (sys);
}
//! Make a global constant

View File

@ -15,4 +15,12 @@ Term makeGlobalConstant (const char *s);
Term makeGlobalVariable (const char *s);
void compute_role_variables (const System sys, Protocol p, Role r);
Term symbolDeclare (Symbol s, int isVar);
void levelTacDeclaration (Tac tc, int isVar);
#define levelDeclareVar(s) levelTacDeclaration(s,1)
#define levelDeclareConst(s) levelTacDeclaration(s,0)
#define levelVar(s) symbolDeclare(s,1)
#define levelConst(s) symbolDeclare(s,0)
#endif

View File

@ -13,6 +13,7 @@
#include "varbuf.h"
#include "output.h"
#include "latex.h"
#include "specialterm.h"
//! Multiplication factor for distance between events in an MSC diagram.
#define EVENTSPACE 1
@ -22,7 +23,6 @@
extern const char *progname;
extern const char *releasetag;
extern int globalLatex;
extern Term TERM_Function;
/*! Additional information for an events. */
struct traceinfo

View File

@ -58,6 +58,7 @@ enum exittypes
#include "output.h"
#include "binding.h"
#include "version.h"
#include "specialterm.h"
#include "argtable2.h"
@ -65,7 +66,6 @@ enum exittypes
System sys;
extern struct tacnode *spdltac;
extern Term TERM_Claim;
extern int mgu_match;
void scanner_cleanup (void);

View File

@ -59,13 +59,12 @@ enum exittypes
#include "output.h"
#include "binding.h"
#include "switches.h"
#include "specialterm.h"
// The global system state
System sys;
extern struct tacnode *spdltac;
extern Term TERM_Claim;
extern Term CLAIM_Empty;
extern int mgu_match;
void scanner_cleanup (void);

View File

@ -6,6 +6,7 @@
#include "mgu.h"
#include "memory.h"
#include "type.h"
#include "specialterm.h"
/*
Most General Unifier
@ -24,8 +25,6 @@
*/
static int mgu_match = 0;
extern Term TERM_Hidden;
//! Set mgu mode (basically switches.match)
void
setMguMode (const int match)

View File

@ -21,17 +21,13 @@
#include "attackminimize.h"
#include "claim.h"
#include "switches.h"
#include "specialterm.h"
/*
A model checker. Really.
*/
extern Term CLAIM_Secret;
extern Term CLAIM_Nisynch;
extern Term CLAIM_Niagree;
extern Term CLAIM_Empty;
/*
Some forward declarations.
*/

51
src/specialterm.c Normal file
View File

@ -0,0 +1,51 @@
#include <stdlib.h>
#include <stdio.h>
#include "term.h"
#include "compiler.h"
/*
* Some macros
*/
#define langhide(x,y) x = levelConst(symbolSysConst(" _" y "_ "))
#define langtype(x,y) x->stype = termlistAdd(x->stype,y);
#define langcons(x,y,z) x = levelConst(symbolSysConst(y)); langtype(x,z)
/* externally used:
*/
Term TERM_Agent;
Term TERM_Function;
Term TERM_Hidden;
Term TERM_Type;
Term TERM_Nonce;
Term TERM_Ticket;
Term TERM_Claim;
Term CLAIM_Secret;
Term CLAIM_Nisynch;
Term CLAIM_Niagree;
Term CLAIM_Empty;
//! Init special terms
/**
* This is called by compilerInit
*/
void
specialTermInit (const System sys)
{
/* Init system constants */
langhide (TERM_Type, "Type");
langhide (TERM_Hidden, "Hidden");
langhide (TERM_Claim, "Claim");
langcons (TERM_Agent, "Agent", TERM_Type);
langcons (TERM_Function, "Function", TERM_Type);
langcons (TERM_Nonce, "Nonce", TERM_Type);
langcons (TERM_Ticket, "Ticket", TERM_Type);
langcons (CLAIM_Secret, "Secret", TERM_Claim);
langcons (CLAIM_Nisynch, "Nisynch", TERM_Claim);
langcons (CLAIM_Niagree, "Niagree", TERM_Claim);
langcons (CLAIM_Empty, "Empty", TERM_Claim);
}

21
src/specialterm.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef SPECIALTERM
#define SPECIALTERM
/*
* Some declarations in spercialterm.c
*/
extern Term TERM_Agent;
extern Term TERM_Function;
extern Term TERM_Hidden;
extern Term TERM_Type;
extern Term TERM_Nonce;
extern Term TERM_Ticket;
extern Term TERM_Claim;
extern Term CLAIM_Secret;
extern Term CLAIM_Nisynch;
extern Term CLAIM_Niagree;
extern Term CLAIM_Empty;
#endif

View File

@ -11,12 +11,12 @@
#include "version.h"
#include "timer.h"
#include "switches.h"
#include "specialterm.h"
#include <limits.h>
struct switchdata switches;
extern struct tacnode *spdltac;
extern Term TERM_Claim;
const char *progname = "scyther";
const char *releasetag = SVNVERSION;

View File

@ -18,10 +18,7 @@
#include "mgu.h"
#include "switches.h"
#include "binding.h"
/* from compiler.o */
extern Term TERM_Type;
extern Term TERM_Agent;
#include "specialterm.h"
//! Global flag that signals LaTeX output.
/**

View File

@ -18,13 +18,13 @@
#include "debug.h"
#include "memory.h"
#include "ctype.h"
#include "specialterm.h"
/* public flag */
int rolelocal_variable;
/* external definitions */
extern Term TERM_Function;
extern int inTermlist (); // suppresses a warning, but at what cost?
extern int globalLatex;

View File

@ -1,16 +1,10 @@
#include <stdlib.h>
#include <stdio.h>
#include "termlist.h"
#include "specialterm.h"
#include "debug.h"
#include "memory.h"
/* system constants.
* declared in compiler.c
*/
extern Term TERM_Function;
extern Term TERM_Hidden;
//! Open termlists code.
void
termlistsInit (void)

View File

@ -11,16 +11,7 @@
#include "system.h"
#include "debug.h"
#include "switches.h"
/*
* Special term definitions from compiler.c
*/
extern Term TERM_Agent;
extern Term TERM_Function;
extern Term TERM_Hidden;
extern Term TERM_Type;
extern Term TERM_Nonce;
extern Term TERM_Ticket;
#include "specialterm.h"
extern Protocol INTRUDER;

View File

@ -18,6 +18,7 @@
#include "binding.h"
#include "arachne.h" // for get_semitrace_length
#include "switches.h"
#include "specialterm.h"
#include "xmlout.h"
@ -25,7 +26,6 @@
* Externally defined
*/
extern Protocol INTRUDER; // from arachne.c
extern Term TERM_Function; // from termlist.c
/*
* Global/static stuff.