forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalg.h
More file actions
168 lines (147 loc) · 5.25 KB
/
alg.h
File metadata and controls
168 lines (147 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef ALGORITHM_H
#define ALGORITHM_H
/** **********************************************************************
** Module: Algorithm \file alg.h
** Description: This module implements the Algorithm abstraction. An
** algorithm can be a procedure, a function, or a rule. It consists
** of a name, a return type (for functions and rules), a list of
** formal parameters, and a list of statements (body).
** Constants:
** ALGORITHM_NULL - the null algorithm
**
************************************************************************/
/*
* This software was developed by U.S. Government employees as part of
* their official duties and is not subject to copyright.
*
* $Log: alg.h,v $
* Revision 1.4 1997/01/21 19:17:11 dar
* made C++ compatible
*
* Revision 1.3 1994/11/22 18:32:39 clark
* Part 11 IS; group reference
*
* Revision 1.2 1993/10/15 18:48:24 libes
* CADDETC certified
*
* Revision 1.4 1993/02/16 03:13:56 libes
* add Where type
*
* Revision 1.3 1992/08/18 17:12:41 libes
* *** empty log message ***
*
* Revision 1.2 1992/06/08 18:06:24 libes
* prettied up interface to print_objects_when_running
*
*/
/*****************/
/* packages used */
/*****************/
#include "expbasic.h" /* get basic definitions */
#include "symbol.h"
#include "scope.h"
#include "type.h"
/************/
/* typedefs */
/************/
typedef struct Scope_ * Procedure;
typedef struct Scope_ * Function;
typedef struct Scope_ * Rule;
typedef struct Where_ * Where;
/***************************/
/* hidden type definitions */
/***************************/
/** each formal tag has one of these structs allocated to it
* As each (real) call is resolved, the tag->type is temporarily borrowed
*/
struct tag {
char * name;
Type type;
};
/** location of fulltext of algorithm in source file */
struct FullText {
const char * filename;
unsigned int start, end;
};
/** 'parameters' are lists of lists of (type) expressions */
struct Procedure_ {
int pcount; /**< # of parameters */
int tag_count; /**< # of different parameter tags */
Linked_List parameters;
Linked_List body;
struct FullText text;
int builtin; /**< builtin if true */
};
struct Function_ {
int pcount; /**< # of parameters */
int tag_count; /**< # of different parameter/return value tags */
Linked_List parameters;
Linked_List body;
Type return_type;
struct FullText text;
int builtin; /**< builtin if true */
};
struct Rule_ {
Linked_List parameters;
Linked_List body;
struct FullText text;
};
/** define a where clause */
struct Where_ {
Symbol * label;
Expression expr;
};
/********************/
/* global variables */
/********************/
extern SC_EXPRESS_EXPORT struct freelist_head ALG_fl;
extern SC_EXPRESS_EXPORT struct freelist_head FUNC_fl;
extern SC_EXPRESS_EXPORT struct freelist_head RULE_fl;
extern SC_EXPRESS_EXPORT struct freelist_head PROC_fl;
extern SC_EXPRESS_EXPORT struct freelist_head WHERE_fl;
/******************************/
/* macro function definitions */
/******************************/
#define ALG_new() (struct Algorithm *)ALLOC_new(&ALG_fl);
#define ALG_destroy(x) ALLOC_destroy(&ALG_fl,(Freelist *)x)
#define FUNC_new() (struct Function_ *)ALLOC_new(&FUNC_fl)
#define FUNC_destroy(x) ALLOC_destroy(&FUNC_fl,(Freelist *)x)
#define RULE_new() (struct Rule_ *)ALLOC_new(&RULE_fl)
#define RULE_destroy(x) ALLOC_destroy(&RULE_fl,(Freelist *)x)
#define PROC_new() (struct Procedure_ *)ALLOC_new(&PROC_fl)
#define PROC_destroy(x) ALLOC_destroy(&PROC_fl,(Freelist *)x)
#define WHERE_new() (struct Where_ *)ALLOC_new(&WHERE_fl)
#define WHERE_destroy(x) ALLOC_destroy(&WHERE_fl,(Freelist *)x)
#define ALGput_name(algorithm, name) SCOPEput_name(algorithm,name)
#define ALGget_name(algorithm) SCOPEget_name(algorithm)
#define ALGget_symbol(a) SCOPEget_symbol(a)
#define FUNCget_name(f) SCOPEget_name(f)
#define PROCget_name(p) SCOPEget_name(p)
#define RULEget_name(r) SCOPEget_name(r)
#define FUNCput_name(f) SCOPEput_name(f,n)
#define PROCput_name(p) SCOPEput_name(p,n)
#define RULEput_name(r) SCOPEput_name(r,n)
#define FUNCget_symbol(f) SCOPEget_symbol(f)
#define PROCget_symbol(r) SCOPEget_symbol(p)
#define RULEget_symbol(r) SCOPEget_symbol(r)
#define FUNCget_parameters(f) ((f)->u.func->parameters)
#define PROCget_parameters(p) ((p)->u.proc->parameters)
#define RULEget_parameters(r) ((r)->u.rule->parameters)
#define FUNCget_body(f) ((f)->u.func->body)
#define PROCget_body(p) ((p)->u.proc->body)
#define RULEget_body(r) ((r)->u.rule->body)
#define FUNCput_body(f,b) ((f)->u.func->body = b)
#define PROCput_body(p,b) ((p)->u.proc->body = b)
#define RULEput_body(r,b) ((r)->u.rule->body = b)
#define FUNCget_return_type(f) ((f)->u.func->return_type)
#define RULEget_where(r) ((r)->where)
#define RULEput_where(r,w) ((r)->where = (w))
#define WHEREget_label(w) ((w)->label)
#define WHEREget_expression(w) ((w)->expr)
/***********************/
/* function prototypes */
/***********************/
extern SC_EXPRESS_EXPORT Scope ALGcreate( char );
extern SC_EXPRESS_EXPORT void ALGinitialize( void );
extern SC_EXPRESS_EXPORT void ALGput_full_text( Scope, int, int );
#endif /* ALGORITHM_H */