fixed build for clang
This commit is contained in:
@@ -1,284 +1,286 @@
|
||||
/*********************************************************************/
|
||||
/* pC++/Sage++ Copyright (C) 1993 */
|
||||
/* Indiana University University of Oregon University of Rennes */
|
||||
/*********************************************************************/
|
||||
|
||||
/*
|
||||
* hash.c -- hash table routines
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "compatible.h"
|
||||
#ifdef SYS5
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "symb.h"
|
||||
#include "defines.h"
|
||||
#include "bif.h"
|
||||
#include "extern.h"
|
||||
|
||||
extern int parstate;
|
||||
extern PTR_BFND cur_bfnd, pred_bfnd, global_bfnd;
|
||||
extern PTR_TYPE vartype, global_default, impltype[];
|
||||
extern void make_prog_header();
|
||||
PTR_TYPE install_array();
|
||||
PTR_LLND make_llnd();
|
||||
PTR_SYMB make_symb();
|
||||
char *chkalloc();
|
||||
void free();
|
||||
void errstr();
|
||||
|
||||
PTR_HASH hash_table[hashMax];
|
||||
|
||||
|
||||
/*
|
||||
* init_hash -- initialize the hash table
|
||||
*/
|
||||
void
|
||||
init_hash()
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < hashMax; i++)
|
||||
hash_table[i] = HSNULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hash(string) -- compute hash value of string.
|
||||
*/
|
||||
int
|
||||
hash(string)
|
||||
register char *string;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; *string;)
|
||||
i += *string++;
|
||||
return (i % hashMax);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* look_up(string) -- lookup string in the hash table and
|
||||
* install it if not there
|
||||
*/
|
||||
PTR_HASH
|
||||
look_up(string, decl_type)
|
||||
register char *string;
|
||||
int decl_type;
|
||||
{
|
||||
int i;
|
||||
register PTR_HASH entry;
|
||||
PTR_BFND cur_scope(), p;
|
||||
|
||||
i = hash(string);
|
||||
p = cur_scope();
|
||||
for (entry = hash_table[i]; entry; entry = entry->next_entry) {
|
||||
if (!strcmp(string, entry->ident) && (entry->id_attr)) {
|
||||
if ((entry->id_attr->scope == p) ||
|
||||
((entry->id_attr->variant==FUNCTION_NAME) &&
|
||||
(p->variant==FUNC_HEDR) &&
|
||||
(p->entry.Template.symbol==entry->id_attr)))
|
||||
return (entry);
|
||||
if (decl_type == SOFT) {
|
||||
for (p=cur_scope(); NEW_SCOPE(p); p = p->control_parent) {
|
||||
if (entry->id_attr->scope == p)
|
||||
return (entry);
|
||||
}
|
||||
if (entry->id_attr->scope == p)
|
||||
return (entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
entry = (struct hash_entry *) chkalloc(sizeof(struct hash_entry));
|
||||
entry->ident = copys(string);
|
||||
entry->next_entry = hash_table[i];
|
||||
hash_table[i] = entry;
|
||||
return (entry);
|
||||
}
|
||||
|
||||
|
||||
PTR_HASH
|
||||
correct_symtab(h, type)
|
||||
PTR_HASH h;
|
||||
int type;
|
||||
{
|
||||
int i;
|
||||
PTR_HASH entry;
|
||||
|
||||
i = hash(h->ident);
|
||||
for (entry = hash_table[i]; entry; entry = entry->next_entry) {
|
||||
if (!strcmp(h->ident, entry->ident)
|
||||
&& ( !(entry->id_attr)
|
||||
||(entry->id_attr->variant==type))
|
||||
&& (h != entry))
|
||||
break;
|
||||
}
|
||||
if (!entry) return h;
|
||||
if (hash_table[i] != h) {
|
||||
fprintf (stderr, "Bug in correct_symtab\n");
|
||||
return h;
|
||||
}
|
||||
hash_table[i] = hash_table[i]->next_entry;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(h);
|
||||
#endif
|
||||
free((char *)h);
|
||||
return hash_table[i];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Checks whether the "name" is installed and installs as a SOFT
|
||||
* entry if not.
|
||||
*/
|
||||
PTR_LLND
|
||||
check_and_install(h, d, ndim)
|
||||
PTR_HASH h;
|
||||
PTR_LLND d;
|
||||
int ndim;
|
||||
{
|
||||
PTR_BFND cur_scope();
|
||||
PTR_SYMB install_entry();
|
||||
PTR_TYPE p = NULL;
|
||||
PTR_SYMB s;
|
||||
PTR_LLND r;
|
||||
void set_type(), err();
|
||||
|
||||
/* Check if the variable is already declared */
|
||||
if ((s = h->id_attr) && (s->scope == cur_scope()) && s->type) {
|
||||
if (d && s->type->variant != T_ARRAY) {
|
||||
p = install_array(d, s->type, ndim);
|
||||
s->type = p;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (h->id_attr && h->id_attr->type)
|
||||
p = h->id_attr->type;
|
||||
else if (!undeftype)
|
||||
p = impltype[*h->ident - 'a'];
|
||||
else
|
||||
err("Variable type unknown",327);
|
||||
if (d)
|
||||
p = install_array(d, p, ndim);
|
||||
s = install_entry(h, SOFT);
|
||||
set_type(s, p, LOCAL);
|
||||
}
|
||||
if (d) {
|
||||
r = p->entry.ar_decl.ranges
|
||||
= make_llnd(fi,ARRAY_REF, d, LLNULL, s);
|
||||
}
|
||||
else
|
||||
r = make_llnd(fi,VAR_REF, LLNULL, LLNULL, s);
|
||||
return make_llnd(fi,EXPR_LIST, r, LLNULL, SMNULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* install_entry takes a pointer to a hash entry and
|
||||
* makes another symbol table entry for the same id
|
||||
*/
|
||||
PTR_SYMB
|
||||
install_entry(entry, decl_type)
|
||||
PTR_HASH entry;
|
||||
int decl_type;
|
||||
{
|
||||
register PTR_SYMB symb_ptr;
|
||||
PTR_BFND cur_scope();
|
||||
PTR_BFND p;
|
||||
void err();
|
||||
|
||||
if (decl_type == HARD && entry->id_attr &&
|
||||
entry->id_attr->scope != cur_scope())
|
||||
entry = look_up(entry->ident, HARD);
|
||||
if ((entry->id_attr) && ((entry->id_attr->scope == cur_scope()) ||
|
||||
((entry->id_attr->variant==FUNCTION_NAME) &&
|
||||
(entry->id_attr->scope->variant==FUNC_HEDR))))
|
||||
{
|
||||
if (entry->id_attr->decl == SOFT) {
|
||||
entry->id_attr->decl = decl_type;
|
||||
return(entry->id_attr);
|
||||
}
|
||||
if (decl_type == SOFT)
|
||||
return(entry->id_attr);
|
||||
/* else */
|
||||
errstr("Redeclaration of identifier: %s",entry->id_attr->ident,328);
|
||||
/*(void)fprintf(stderr, "id: %s\n", entry->id_attr->ident);*/
|
||||
return (SMNULL);
|
||||
}
|
||||
symb_ptr = make_symb(fi,DEFAULT, entry->ident);
|
||||
for (p=cur_scope();
|
||||
NEW_SCOPE(p) && (decl_type==SOFT);
|
||||
p = p->control_parent)
|
||||
;
|
||||
symb_ptr->scope = p;
|
||||
symb_ptr->outer = entry->id_attr;
|
||||
symb_ptr->parent = entry;
|
||||
symb_ptr->decl = decl_type;
|
||||
entry->id_attr = symb_ptr;
|
||||
symb_ptr->id_list = SMNULL;
|
||||
return (symb_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PTR_SYMB
|
||||
get_proc_symbol(entry)
|
||||
PTR_HASH entry;
|
||||
{
|
||||
register PTR_SYMB symb_ptr;
|
||||
PTR_BFND cur_scope();
|
||||
|
||||
symb_ptr = make_symb(fi, PROCEDURE_NAME, entry->ident);
|
||||
symb_ptr->scope = global_bfnd;
|
||||
symb_ptr->outer = entry->id_attr;
|
||||
symb_ptr->parent = entry;
|
||||
entry->id_attr = symb_ptr;
|
||||
return (symb_ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
PTR_BFND
|
||||
cur_scope()
|
||||
{
|
||||
register PTR_BFND p;
|
||||
*/
|
||||
/* Takes cares of main program unit begining without a PROGRAM
|
||||
statement. After rewrite of statement processing has been done,
|
||||
strengthen ( weaken? ) the test.
|
||||
*/
|
||||
/*
|
||||
if ((pred_bfnd->variant == GLOBAL) && (parstate == OUTSIDE))
|
||||
{
|
||||
make_prog_header();
|
||||
return (pred_bfnd);
|
||||
}
|
||||
|
||||
for (p = pred_bfnd;
|
||||
(p->variant != PROG_HEDR) &&
|
||||
(p->variant != PROC_HEDR) &&
|
||||
(p->variant != PROS_HEDR) &&
|
||||
(p->variant != FUNC_HEDR) &&
|
||||
(p->variant != BLOCK_DATA) &&
|
||||
(p->variant != FORALL_NODE) &&
|
||||
(p->variant != GLOBAL) &&
|
||||
(p->variant != CDOALL_NODE) &&
|
||||
(p->variant != SDOALL_NODE) &&
|
||||
(p->variant != DOACROSS_NODE) &&
|
||||
(p->variant != STRUCT_DECL);
|
||||
p = p->control_parent);
|
||||
;
|
||||
|
||||
return (p);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/* pC++/Sage++ Copyright (C) 1993 */
|
||||
/* Indiana University University of Oregon University of Rennes */
|
||||
/*********************************************************************/
|
||||
|
||||
/*
|
||||
* hash.c -- hash table routines
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "compatible.h"
|
||||
#ifdef SYS5
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "symb.h"
|
||||
#include "defines.h"
|
||||
#include "bif.h"
|
||||
#include "extern.h"
|
||||
|
||||
extern int parstate;
|
||||
extern PTR_BFND cur_bfnd, pred_bfnd, global_bfnd;
|
||||
extern PTR_TYPE vartype, global_default, impltype[];
|
||||
extern void make_prog_header();
|
||||
PTR_TYPE install_array();
|
||||
PTR_LLND make_llnd();
|
||||
PTR_SYMB make_symb();
|
||||
char *chkalloc();
|
||||
void free();
|
||||
void errstr();
|
||||
|
||||
PTR_HASH hash_table[hashMax];
|
||||
|
||||
#ifdef __SPF
|
||||
extern void removeFromCollection(void *pointer);
|
||||
#endif
|
||||
/*
|
||||
* init_hash -- initialize the hash table
|
||||
*/
|
||||
void
|
||||
init_hash()
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < hashMax; i++)
|
||||
hash_table[i] = HSNULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hash(string) -- compute hash value of string.
|
||||
*/
|
||||
int
|
||||
hash(string)
|
||||
register char *string;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; *string;)
|
||||
i += *string++;
|
||||
return (i % hashMax);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* look_up(string) -- lookup string in the hash table and
|
||||
* install it if not there
|
||||
*/
|
||||
PTR_HASH
|
||||
look_up(string, decl_type)
|
||||
register char *string;
|
||||
int decl_type;
|
||||
{
|
||||
int i;
|
||||
register PTR_HASH entry;
|
||||
PTR_BFND cur_scope(), p;
|
||||
|
||||
i = hash(string);
|
||||
p = cur_scope();
|
||||
for (entry = hash_table[i]; entry; entry = entry->next_entry) {
|
||||
if (!strcmp(string, entry->ident) && (entry->id_attr)) {
|
||||
if ((entry->id_attr->scope == p) ||
|
||||
((entry->id_attr->variant==FUNCTION_NAME) &&
|
||||
(p->variant==FUNC_HEDR) &&
|
||||
(p->entry.Template.symbol==entry->id_attr)))
|
||||
return (entry);
|
||||
if (decl_type == SOFT) {
|
||||
for (p=cur_scope(); NEW_SCOPE(p); p = p->control_parent) {
|
||||
if (entry->id_attr->scope == p)
|
||||
return (entry);
|
||||
}
|
||||
if (entry->id_attr->scope == p)
|
||||
return (entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
entry = (struct hash_entry *) chkalloc(sizeof(struct hash_entry));
|
||||
entry->ident = copys(string);
|
||||
entry->next_entry = hash_table[i];
|
||||
hash_table[i] = entry;
|
||||
return (entry);
|
||||
}
|
||||
|
||||
|
||||
PTR_HASH
|
||||
correct_symtab(h, type)
|
||||
PTR_HASH h;
|
||||
int type;
|
||||
{
|
||||
int i;
|
||||
PTR_HASH entry;
|
||||
|
||||
i = hash(h->ident);
|
||||
for (entry = hash_table[i]; entry; entry = entry->next_entry) {
|
||||
if (!strcmp(h->ident, entry->ident)
|
||||
&& ( !(entry->id_attr)
|
||||
||(entry->id_attr->variant==type))
|
||||
&& (h != entry))
|
||||
break;
|
||||
}
|
||||
if (!entry) return h;
|
||||
if (hash_table[i] != h) {
|
||||
fprintf (stderr, "Bug in correct_symtab\n");
|
||||
return h;
|
||||
}
|
||||
hash_table[i] = hash_table[i]->next_entry;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(h);
|
||||
#endif
|
||||
free((char *)h);
|
||||
return hash_table[i];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Checks whether the "name" is installed and installs as a SOFT
|
||||
* entry if not.
|
||||
*/
|
||||
PTR_LLND
|
||||
check_and_install(h, d, ndim)
|
||||
PTR_HASH h;
|
||||
PTR_LLND d;
|
||||
int ndim;
|
||||
{
|
||||
PTR_BFND cur_scope();
|
||||
PTR_SYMB install_entry();
|
||||
PTR_TYPE p = NULL;
|
||||
PTR_SYMB s;
|
||||
PTR_LLND r;
|
||||
void set_type(), err();
|
||||
|
||||
/* Check if the variable is already declared */
|
||||
if ((s = h->id_attr) && (s->scope == cur_scope()) && s->type) {
|
||||
if (d && s->type->variant != T_ARRAY) {
|
||||
p = install_array(d, s->type, ndim);
|
||||
s->type = p;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (h->id_attr && h->id_attr->type)
|
||||
p = h->id_attr->type;
|
||||
else if (!undeftype)
|
||||
p = impltype[*h->ident - 'a'];
|
||||
else
|
||||
err("Variable type unknown",327);
|
||||
if (d)
|
||||
p = install_array(d, p, ndim);
|
||||
s = install_entry(h, SOFT);
|
||||
set_type(s, p, LOCAL);
|
||||
}
|
||||
if (d) {
|
||||
r = p->entry.ar_decl.ranges
|
||||
= make_llnd(fi,ARRAY_REF, d, LLNULL, s);
|
||||
}
|
||||
else
|
||||
r = make_llnd(fi,VAR_REF, LLNULL, LLNULL, s);
|
||||
return make_llnd(fi,EXPR_LIST, r, LLNULL, SMNULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* install_entry takes a pointer to a hash entry and
|
||||
* makes another symbol table entry for the same id
|
||||
*/
|
||||
PTR_SYMB
|
||||
install_entry(entry, decl_type)
|
||||
PTR_HASH entry;
|
||||
int decl_type;
|
||||
{
|
||||
register PTR_SYMB symb_ptr;
|
||||
PTR_BFND cur_scope();
|
||||
PTR_BFND p;
|
||||
void err();
|
||||
|
||||
if (decl_type == HARD && entry->id_attr &&
|
||||
entry->id_attr->scope != cur_scope())
|
||||
entry = look_up(entry->ident, HARD);
|
||||
if ((entry->id_attr) && ((entry->id_attr->scope == cur_scope()) ||
|
||||
((entry->id_attr->variant==FUNCTION_NAME) &&
|
||||
(entry->id_attr->scope->variant==FUNC_HEDR))))
|
||||
{
|
||||
if (entry->id_attr->decl == SOFT) {
|
||||
entry->id_attr->decl = decl_type;
|
||||
return(entry->id_attr);
|
||||
}
|
||||
if (decl_type == SOFT)
|
||||
return(entry->id_attr);
|
||||
/* else */
|
||||
errstr("Redeclaration of identifier: %s",entry->id_attr->ident,328);
|
||||
/*(void)fprintf(stderr, "id: %s\n", entry->id_attr->ident);*/
|
||||
return (SMNULL);
|
||||
}
|
||||
symb_ptr = make_symb(fi,DEFAULT, entry->ident);
|
||||
for (p=cur_scope();
|
||||
NEW_SCOPE(p) && (decl_type==SOFT);
|
||||
p = p->control_parent)
|
||||
;
|
||||
symb_ptr->scope = p;
|
||||
symb_ptr->outer = entry->id_attr;
|
||||
symb_ptr->parent = entry;
|
||||
symb_ptr->decl = decl_type;
|
||||
entry->id_attr = symb_ptr;
|
||||
symb_ptr->id_list = SMNULL;
|
||||
return (symb_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PTR_SYMB
|
||||
get_proc_symbol(entry)
|
||||
PTR_HASH entry;
|
||||
{
|
||||
register PTR_SYMB symb_ptr;
|
||||
PTR_BFND cur_scope();
|
||||
|
||||
symb_ptr = make_symb(fi, PROCEDURE_NAME, entry->ident);
|
||||
symb_ptr->scope = global_bfnd;
|
||||
symb_ptr->outer = entry->id_attr;
|
||||
symb_ptr->parent = entry;
|
||||
entry->id_attr = symb_ptr;
|
||||
return (symb_ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
PTR_BFND
|
||||
cur_scope()
|
||||
{
|
||||
register PTR_BFND p;
|
||||
*/
|
||||
/* Takes cares of main program unit begining without a PROGRAM
|
||||
statement. After rewrite of statement processing has been done,
|
||||
strengthen ( weaken? ) the test.
|
||||
*/
|
||||
/*
|
||||
if ((pred_bfnd->variant == GLOBAL) && (parstate == OUTSIDE))
|
||||
{
|
||||
make_prog_header();
|
||||
return (pred_bfnd);
|
||||
}
|
||||
|
||||
for (p = pred_bfnd;
|
||||
(p->variant != PROG_HEDR) &&
|
||||
(p->variant != PROC_HEDR) &&
|
||||
(p->variant != PROS_HEDR) &&
|
||||
(p->variant != FUNC_HEDR) &&
|
||||
(p->variant != BLOCK_DATA) &&
|
||||
(p->variant != FORALL_NODE) &&
|
||||
(p->variant != GLOBAL) &&
|
||||
(p->variant != CDOALL_NODE) &&
|
||||
(p->variant != SDOALL_NODE) &&
|
||||
(p->variant != DOACROSS_NODE) &&
|
||||
(p->variant != STRUCT_DECL);
|
||||
p = p->control_parent);
|
||||
;
|
||||
|
||||
return (p);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,208 +1,212 @@
|
||||
/*********************************************************************/
|
||||
/* pC++/Sage++ Copyright (C) 1993 */
|
||||
/* Indiana University University of Oregon University of Rennes */
|
||||
/*********************************************************************/
|
||||
|
||||
/*
|
||||
* misc.c
|
||||
*
|
||||
* Misellanious help routines
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
#include "defines.h"
|
||||
#include <ctype.h>
|
||||
#include "db.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int blklevel;
|
||||
extern void warn1();
|
||||
extern PTR_BFND cur_scope();
|
||||
PTR_LABEL make_label();
|
||||
extern PTR_FILE fi;
|
||||
void free();
|
||||
|
||||
extern PTR_CMNT comments;
|
||||
extern PTR_FNAME cur_thread_file;
|
||||
extern PTR_FNAME the_file;
|
||||
extern int yylineno;
|
||||
extern int mod_offset;
|
||||
extern PTR_BFND last_bfnd;
|
||||
extern PTR_BFND head_bfnd, last_bfnd;
|
||||
extern PTR_LLND head_llnd;
|
||||
extern PTR_SYMB head_symb;
|
||||
extern PTR_TYPE head_type;
|
||||
extern PTR_LABEL head_label;
|
||||
|
||||
/*
|
||||
* eqn -- checks if first n characters of two strings are the same
|
||||
*
|
||||
* input:
|
||||
* n - length to be checked
|
||||
* a - string1
|
||||
* b - string2
|
||||
*
|
||||
* output:
|
||||
* YES if the first n characters are same. NO, otherwise.
|
||||
*/
|
||||
int
|
||||
eqn(n, a, b)
|
||||
register int n;
|
||||
register unsigned char *a, *b;
|
||||
{
|
||||
while (--n >= 0)
|
||||
if ((isupper(*a) ? tolower(*a++) : *a++) != *b++)
|
||||
return (NO);
|
||||
return (YES);
|
||||
}
|
||||
|
||||
/*
|
||||
* StringConcatenation -- concatenate strings
|
||||
*/
|
||||
char *StringConcatenation(char *s1, char*s2)
|
||||
{
|
||||
char *res = (char*)malloc(strlen(s1)+strlen(s2)+1);
|
||||
res[0] = '\0';
|
||||
strcat(res, s1);
|
||||
strcat(res, s2);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* convci - converts an ASCII string to binary
|
||||
*
|
||||
* input:
|
||||
* n - length of the string
|
||||
* s - the string to be converted
|
||||
*
|
||||
* output:
|
||||
* the converted long value
|
||||
*/
|
||||
long
|
||||
convci(n, s)
|
||||
register int n;
|
||||
register char *s;
|
||||
{
|
||||
register long sum;
|
||||
|
||||
sum = 0;
|
||||
while (n-- > 0)
|
||||
sum = 10 * sum + (*s++ - '0');
|
||||
return (sum);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* convic -- converts a long integer to ASCII string
|
||||
*
|
||||
* input:
|
||||
* n - the number to be converted
|
||||
*
|
||||
* output:
|
||||
* the converted string
|
||||
*/
|
||||
char *
|
||||
convic(n)
|
||||
long n;
|
||||
{
|
||||
static char s[20];
|
||||
register char *t;
|
||||
|
||||
s[19] = '\0';
|
||||
t = s + 19;
|
||||
|
||||
do {
|
||||
*--t = '0' + n % 10;
|
||||
n /= 10;
|
||||
} while (n > 0);
|
||||
|
||||
return (t);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get a BIF node
|
||||
*/
|
||||
PTR_BFND
|
||||
get_bfnd(fid,node_type, symb_ptr, ll1, ll2, ll3)
|
||||
PTR_FILE fid;
|
||||
int node_type;
|
||||
PTR_SYMB symb_ptr;
|
||||
PTR_LLND ll1, ll2, ll3;
|
||||
{
|
||||
PTR_BFND new_bfnd, make_bfnd();
|
||||
|
||||
new_bfnd = make_bfnd(fid, node_type, symb_ptr, ll1, ll2, ll3);
|
||||
new_bfnd->filename = the_file;
|
||||
/*new_bfnd->filename = cur_thread_file;*/ /*podd 18.04.99*/
|
||||
new_bfnd->entry.Template.cmnt_ptr = comments;
|
||||
new_bfnd->entry.Template.bl_ptr1 = BLNULL;
|
||||
new_bfnd->entry.Template.bl_ptr2 = BLNULL;
|
||||
new_bfnd->g_line = yylineno;
|
||||
new_bfnd->l_line = yylineno - mod_offset;
|
||||
last_bfnd = new_bfnd;
|
||||
return (new_bfnd);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
release_nodes()
|
||||
{
|
||||
register PTR_BFND p1 = head_bfnd;
|
||||
register PTR_LLND p2 = head_llnd;
|
||||
register PTR_SYMB p3 = head_symb;
|
||||
register PTR_TYPE p4 = head_type;
|
||||
register PTR_LABEL p5 =head_label;
|
||||
register PTR_BFND t1;
|
||||
register PTR_LLND t2;
|
||||
register PTR_SYMB t3;
|
||||
register PTR_TYPE t4;
|
||||
register PTR_LABEL t5;
|
||||
|
||||
while (p1) {
|
||||
t1 = p1;
|
||||
p1 = p1->thread;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t1);
|
||||
#endif
|
||||
free ((char *)t1);
|
||||
}
|
||||
|
||||
while (p2) {
|
||||
t2 = p2;
|
||||
p2 = p2->thread;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t2);
|
||||
#endif
|
||||
free ((char *)t2);
|
||||
}
|
||||
|
||||
while (p3) {
|
||||
t3 = p3;
|
||||
p3 = p3->thread;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t3);
|
||||
#endif
|
||||
free ((char *)t3);
|
||||
}
|
||||
|
||||
while (p4) {
|
||||
t4 = p4;
|
||||
p4 = p4->thread;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t4);
|
||||
#endif
|
||||
free ((char *)t4);
|
||||
}
|
||||
|
||||
while (p5) {
|
||||
t5 = p5;
|
||||
p5 = p5->next;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t5);
|
||||
#endif
|
||||
free ((char *)t5);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************/
|
||||
/* pC++/Sage++ Copyright (C) 1993 */
|
||||
/* Indiana University University of Oregon University of Rennes */
|
||||
/*********************************************************************/
|
||||
|
||||
/*
|
||||
* misc.c
|
||||
*
|
||||
* Misellanious help routines
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
#include "defines.h"
|
||||
#include <ctype.h>
|
||||
#include "db.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int blklevel;
|
||||
extern void warn1();
|
||||
extern PTR_BFND cur_scope();
|
||||
PTR_LABEL make_label();
|
||||
extern PTR_FILE fi;
|
||||
void free();
|
||||
|
||||
extern PTR_CMNT comments;
|
||||
extern PTR_FNAME cur_thread_file;
|
||||
extern PTR_FNAME the_file;
|
||||
extern int yylineno;
|
||||
extern int mod_offset;
|
||||
extern PTR_BFND last_bfnd;
|
||||
extern PTR_BFND head_bfnd, last_bfnd;
|
||||
extern PTR_LLND head_llnd;
|
||||
extern PTR_SYMB head_symb;
|
||||
extern PTR_TYPE head_type;
|
||||
extern PTR_LABEL head_label;
|
||||
|
||||
#ifdef __SPF
|
||||
extern void removeFromCollection(void *pointer);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* eqn -- checks if first n characters of two strings are the same
|
||||
*
|
||||
* input:
|
||||
* n - length to be checked
|
||||
* a - string1
|
||||
* b - string2
|
||||
*
|
||||
* output:
|
||||
* YES if the first n characters are same. NO, otherwise.
|
||||
*/
|
||||
int
|
||||
eqn(n, a, b)
|
||||
register int n;
|
||||
register unsigned char *a, *b;
|
||||
{
|
||||
while (--n >= 0)
|
||||
if ((isupper(*a) ? tolower(*a++) : *a++) != *b++)
|
||||
return (NO);
|
||||
return (YES);
|
||||
}
|
||||
|
||||
/*
|
||||
* StringConcatenation -- concatenate strings
|
||||
*/
|
||||
char *StringConcatenation(char *s1, char*s2)
|
||||
{
|
||||
char *res = (char*)malloc(strlen(s1)+strlen(s2)+1);
|
||||
res[0] = '\0';
|
||||
strcat(res, s1);
|
||||
strcat(res, s2);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* convci - converts an ASCII string to binary
|
||||
*
|
||||
* input:
|
||||
* n - length of the string
|
||||
* s - the string to be converted
|
||||
*
|
||||
* output:
|
||||
* the converted long value
|
||||
*/
|
||||
long
|
||||
convci(n, s)
|
||||
register int n;
|
||||
register char *s;
|
||||
{
|
||||
register long sum;
|
||||
|
||||
sum = 0;
|
||||
while (n-- > 0)
|
||||
sum = 10 * sum + (*s++ - '0');
|
||||
return (sum);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* convic -- converts a long integer to ASCII string
|
||||
*
|
||||
* input:
|
||||
* n - the number to be converted
|
||||
*
|
||||
* output:
|
||||
* the converted string
|
||||
*/
|
||||
char *
|
||||
convic(n)
|
||||
long n;
|
||||
{
|
||||
static char s[20];
|
||||
register char *t;
|
||||
|
||||
s[19] = '\0';
|
||||
t = s + 19;
|
||||
|
||||
do {
|
||||
*--t = '0' + n % 10;
|
||||
n /= 10;
|
||||
} while (n > 0);
|
||||
|
||||
return (t);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get a BIF node
|
||||
*/
|
||||
PTR_BFND
|
||||
get_bfnd(fid,node_type, symb_ptr, ll1, ll2, ll3)
|
||||
PTR_FILE fid;
|
||||
int node_type;
|
||||
PTR_SYMB symb_ptr;
|
||||
PTR_LLND ll1, ll2, ll3;
|
||||
{
|
||||
PTR_BFND new_bfnd, make_bfnd();
|
||||
|
||||
new_bfnd = make_bfnd(fid, node_type, symb_ptr, ll1, ll2, ll3);
|
||||
new_bfnd->filename = the_file;
|
||||
/*new_bfnd->filename = cur_thread_file;*/ /*podd 18.04.99*/
|
||||
new_bfnd->entry.Template.cmnt_ptr = comments;
|
||||
new_bfnd->entry.Template.bl_ptr1 = BLNULL;
|
||||
new_bfnd->entry.Template.bl_ptr2 = BLNULL;
|
||||
new_bfnd->g_line = yylineno;
|
||||
new_bfnd->l_line = yylineno - mod_offset;
|
||||
last_bfnd = new_bfnd;
|
||||
return (new_bfnd);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
release_nodes()
|
||||
{
|
||||
register PTR_BFND p1 = head_bfnd;
|
||||
register PTR_LLND p2 = head_llnd;
|
||||
register PTR_SYMB p3 = head_symb;
|
||||
register PTR_TYPE p4 = head_type;
|
||||
register PTR_LABEL p5 =head_label;
|
||||
register PTR_BFND t1;
|
||||
register PTR_LLND t2;
|
||||
register PTR_SYMB t3;
|
||||
register PTR_TYPE t4;
|
||||
register PTR_LABEL t5;
|
||||
|
||||
while (p1) {
|
||||
t1 = p1;
|
||||
p1 = p1->thread;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t1);
|
||||
#endif
|
||||
free ((char *)t1);
|
||||
}
|
||||
|
||||
while (p2) {
|
||||
t2 = p2;
|
||||
p2 = p2->thread;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t2);
|
||||
#endif
|
||||
free ((char *)t2);
|
||||
}
|
||||
|
||||
while (p3) {
|
||||
t3 = p3;
|
||||
p3 = p3->thread;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t3);
|
||||
#endif
|
||||
free ((char *)t3);
|
||||
}
|
||||
|
||||
while (p4) {
|
||||
t4 = p4;
|
||||
p4 = p4->thread;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t4);
|
||||
#endif
|
||||
free ((char *)t4);
|
||||
}
|
||||
|
||||
while (p5) {
|
||||
t5 = p5;
|
||||
p5 = p5->next;
|
||||
#ifdef __SPF
|
||||
removeFromCollection(t5);
|
||||
#endif
|
||||
free ((char *)t5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user