cleanup and doxify src/express
This commit is contained in:
1 parent
a63ac738af
commit
3e8c11661d
19 files changed
+849
-1684
No files matched your search
+9
-28
@@ -1,10 +1,8 @@
|
||||
#ifndef ERROR_H
|
||||
#define ERROR_H
|
||||
|
||||
/* $Id: error.h,v 1.8 1997/01/21 19:16:55 dar Exp $ */
|
||||
|
||||
/************************************************************************
|
||||
** Module: Error
|
||||
/** **********************************************************************
|
||||
** Module: Error \file error.h
|
||||
** Description: This module implements the ERROR abstraction.
|
||||
************************************************************************/
|
||||
|
||||
@@ -32,7 +30,7 @@
|
||||
|
||||
#include <scl_export.h>
|
||||
#include "basic.h" /* get basic definitions */
|
||||
#include "setjmp.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
/*************/
|
||||
/* constants */
|
||||
@@ -137,31 +135,23 @@ extern SCL_EXPRESS_EXPORT void ERROR_flush_message_buffer PROTO( ( void ) );
|
||||
|
||||
#if supports_inline_functions || defined(ERROR_C)
|
||||
|
||||
static_inline
|
||||
void
|
||||
ERRORdisable( Error error ) {
|
||||
static_inline void ERRORdisable( Error error ) {
|
||||
if( error != ERROR_none ) {
|
||||
error->enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
static_inline
|
||||
void
|
||||
ERRORenable( Error error ) {
|
||||
static_inline void ERRORenable( Error error ) {
|
||||
if( error != ERROR_none ) {
|
||||
error->enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
static_inline
|
||||
bool
|
||||
ERRORis_enabled( Error error ) {
|
||||
static_inline bool ERRORis_enabled( Error error ) {
|
||||
return error->enabled;
|
||||
}
|
||||
|
||||
static_inline
|
||||
void
|
||||
ERRORbuffer_messages( bool flag ) {
|
||||
static_inline void ERRORbuffer_messages( bool flag ) {
|
||||
#if !defined(__MSVC__) && !defined(__BORLAND__)
|
||||
extern void ERROR_start_message_buffer( void ),
|
||||
ERROR_flush_message_buffer( void );
|
||||
@@ -174,9 +164,7 @@ ERRORbuffer_messages( bool flag ) {
|
||||
}
|
||||
}
|
||||
|
||||
static_inline
|
||||
void
|
||||
ERRORflush_messages( void ) {
|
||||
static_inline void ERRORflush_messages( void ) {
|
||||
#if !defined(__MSVC__) && !defined(__BORLAND__)
|
||||
extern void ERROR_start_message_buffer( void ),
|
||||
ERROR_flush_message_buffer( void );
|
||||
@@ -200,8 +188,7 @@ extern SCL_EXPRESS_EXPORT void ERRORnospace PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORabort PROTO( ( int ) );
|
||||
extern SCL_EXPRESS_EXPORT Error ERRORcreate PROTO( ( char *, Severity ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORreport PROTO( ( Error, ... ) );
|
||||
/*SUPPRESS 652*/ /* 1.? */
|
||||
/*SUPPRESS 842*/ /* 4.0.2 */
|
||||
|
||||
struct Symbol_; /* mention Symbol to avoid warning on following line */
|
||||
extern SCL_EXPRESS_EXPORT void ERRORreport_with_symbol PROTO( ( Error, struct Symbol_ *, ... ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORreport_with_line PROTO( ( Error, int, ... ) );
|
||||
@@ -221,10 +208,4 @@ extern SCL_EXPRESS_EXPORT void ERRORset_all_warnings PROTO( ( int ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORsafe PROTO( ( jmp_buf env ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORunsafe PROTO( ( void ) );
|
||||
|
||||
#if deprecated
|
||||
extern void ERRORdisable PROTO( ( Error ) );
|
||||
extern void ERRORenable PROTO( ( Error ) );
|
||||
extern Boolean ERRORis_enabled PROTO( ( Error ) );
|
||||
#endif
|
||||
|
||||
#endif /* ERROR_H */
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef OBJECT_H
|
||||
#define OBJECT_H
|
||||
|
||||
/* $Id: object.h,v 1.9 1997/01/21 19:17:11 dar Exp $ */
|
||||
|
||||
/************************************************************************
|
||||
** Module: Object
|
||||
/** **********************************************************************
|
||||
** Module: Object \file object.h
|
||||
** Description: This module implements the Object abstraction.
|
||||
** Constants:
|
||||
** OBJECT_NULL - the null class
|
||||
@@ -113,15 +111,5 @@ GLOBAL SCL_EXPRESS_EXPORT struct Object * OBJ;
|
||||
extern SCL_EXPRESS_EXPORT void OBJinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void OBJcreate PROTO( ( char, struct Symbol_ * ( * )( Generic ), char *, int ) );
|
||||
extern SCL_EXPRESS_EXPORT Symbol * UNK_get_symbol PROTO( ( Generic x ) );
|
||||
#if 0
|
||||
extern void OBJcreate( char, struct Symbol * ( * )( Generic ), char *, int );
|
||||
#endif
|
||||
|
||||
/********************/
|
||||
/* inline functions */
|
||||
/********************/
|
||||
|
||||
#if supports_inline_functions || defined(OBJECT_C)
|
||||
#endif /* supports_inline_functions || defined(OBJECT_C) */
|
||||
|
||||
#endif /*OBJECT_H*/
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef SYMBOL_H
|
||||
#define SYMBOL_H
|
||||
|
||||
/* $Id: symbol.h,v 1.8 1997/01/21 19:17:11 dar Exp $ */
|
||||
|
||||
/************************************************************************
|
||||
** Module: Symbol
|
||||
/** **********************************************************************
|
||||
** Module: Symbol \file symbol.h
|
||||
** Description: This module implements the Symbol abstraction.
|
||||
** Constants:
|
||||
** SYMBOL_NULL - the null Symbol
|
||||
@@ -45,9 +43,6 @@
|
||||
/* packages used */
|
||||
/*****************/
|
||||
|
||||
#ifdef SYMBOL_C
|
||||
#endif /* SYMBOL_C */
|
||||
|
||||
#include <scl_export.h>
|
||||
#include "basic.h" /* get basic definitions */
|
||||
#include "memory.h"
|
||||
@@ -96,15 +91,13 @@ GLOBAL SCL_EXPRESS_EXPORT struct freelist_head SYMBOL_fl;
|
||||
|
||||
#define SYMBOLset(obj) obj->symbol.line = yylineno; \
|
||||
obj->symbol.filename = current_filename
|
||||
/* for backwards compatibility only, no one should ever need this */
|
||||
#define SYMBOLget_name(sym) ((sym)->name)
|
||||
|
||||
/***********************/
|
||||
/* function prototypes */
|
||||
/***********************/
|
||||
|
||||
extern SCL_EXPRESS_EXPORT void SYMBOLinitialize PROTO( ( void ) );
|
||||
SCL_EXPRESS_EXPORT Symbol * SYMBOLcreate PROTO( ( char *, int, char * ) );
|
||||
extern SCL_EXPRESS_EXPORT void SYMBOLinitialize( void );
|
||||
SCL_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int line, char * filename );
|
||||
|
||||
/********************/
|
||||
/* inline functions */
|
||||
|
||||
+8
-18
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** Module: Algorithm
|
||||
** Description: This module implements the Algorithm abstraction. An
|
||||
/** **********************************************************************
|
||||
** Module: Algorithm \file alg.c
|
||||
** 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).
|
||||
@@ -43,8 +43,7 @@
|
||||
#include "express/object.h"
|
||||
#include "express/schema.h"
|
||||
|
||||
Scope
|
||||
ALGcreate( char type ) {
|
||||
Scope ALGcreate( char type ) {
|
||||
Scope s = SCOPEcreate( type );
|
||||
|
||||
switch( type ) {
|
||||
@@ -61,20 +60,12 @@ ALGcreate( char type ) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ALGinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Algorithm module.
|
||||
*/
|
||||
|
||||
Symbol *
|
||||
WHERE_get_symbol( Generic w ) {
|
||||
Symbol * WHERE_get_symbol( Generic w ) {
|
||||
return( ( ( Where )w )->label );
|
||||
}
|
||||
|
||||
void
|
||||
ALGinitialize( void ) {
|
||||
/** Initialize the Algorithm module. */
|
||||
void ALGinitialize( void ) {
|
||||
MEMinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 );
|
||||
MEMinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 );
|
||||
MEMinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 );
|
||||
@@ -85,8 +76,7 @@ ALGinitialize( void ) {
|
||||
OBJcreate( OBJ_WHERE, WHERE_get_symbol, "where", OBJ_WHERE_BITS );
|
||||
}
|
||||
|
||||
void
|
||||
ALGput_full_text( Scope s, int start, int end ) {
|
||||
void ALGput_full_text( Scope s, int start, int end ) {
|
||||
switch( s->type ) {
|
||||
case OBJ_FUNCTION:
|
||||
s->u.func->text.filename = s->symbol.filename;
|
||||
|
||||
+14
-24
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** Module: Case_Item
|
||||
** Description: This module implements the Case_Item abstraction. A
|
||||
/** **********************************************************************
|
||||
** Module: Case_Item \file caseitem.c
|
||||
** This module implements the Case_Item abstraction. A
|
||||
** case item represents a single branch in a case statement; it
|
||||
** thus consists of a list of labels and a statement to execute
|
||||
** when one of the labels matches the selector.
|
||||
@@ -32,32 +32,22 @@
|
||||
#define CASE_ITEM_C
|
||||
#include "express/caseitem.h"
|
||||
|
||||
/*
|
||||
** Procedure: CASE_ITinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Case Item module.
|
||||
*/
|
||||
|
||||
void
|
||||
CASE_ITinitialize( void ) {
|
||||
/** Initialize the Case Item module. */
|
||||
void CASE_ITinitialize( void ) {
|
||||
MEMinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: CASE_ITcreate
|
||||
** Parameters: Linked_List labels - list of Expressions for case labels
|
||||
** Statement statement - statement associated with this branch
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Case_Item - the case item created
|
||||
** Description: Create and return a new case item.
|
||||
/**
|
||||
** \param labels list of Expressions for case labels
|
||||
** \param statement statement associated with this branch
|
||||
** \return the case item created
|
||||
**
|
||||
** Notes: If the 'labels' parameter is LIST_NULL, a case item
|
||||
** matching in the default case is created.
|
||||
** Create and return a new case item.
|
||||
**
|
||||
** \note If the 'labels' parameter is LIST_NULL, a case item
|
||||
** matching in the default case is created.
|
||||
*/
|
||||
|
||||
Case_Item
|
||||
CASE_ITcreate( Linked_List labels, Statement statement ) {
|
||||
Case_Item CASE_ITcreate( Linked_List labels, Statement statement ) {
|
||||
struct Case_Item_ *s = CASE_IT_new();
|
||||
|
||||
s->labels = labels;
|
||||
|
||||
+21
-31
@@ -41,8 +41,7 @@
|
||||
static Error ERROR_duplicate_decl;
|
||||
static Error ERROR_duplicate_decl_diff_file;
|
||||
|
||||
void
|
||||
DICTprint( Dictionary dict ) {
|
||||
void DICTprint( Dictionary dict ) {
|
||||
Element e;
|
||||
DictionaryEntry de;
|
||||
|
||||
@@ -63,19 +62,15 @@ void DICTinitialize( void ) {
|
||||
"Redeclaration of %s. Previous declaration was on line %d in file %s.", SEVERITY_ERROR );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: DICTcreate
|
||||
** Parameters: int size - estimated (initial) max # of entries
|
||||
** Returns: Dictionary - a new dictionary of the specified size
|
||||
/** \def DICTcreate
|
||||
** \param size - estimated (initial) max # of entries
|
||||
** \return a new dictionary of the specified size
|
||||
** \note now a macro
|
||||
*/
|
||||
/* now a macro */
|
||||
|
||||
/**
|
||||
* Define anything in a dictionary. Generates an
|
||||
* error directly if there is a duplicate value.
|
||||
* \param dictionary dictionary to modify
|
||||
* \param entry entry to be added
|
||||
* \param experrc buffer for error code
|
||||
* \return 0 on success, 1 on failure
|
||||
*/
|
||||
int DICTdefine( Dictionary dict, char * name, Generic obj, Symbol * sym, char type ) {
|
||||
@@ -124,6 +119,7 @@ int DICTdefine( Dictionary dict, char * name, Generic obj, Symbol * sym, char ty
|
||||
* ENUMERATION OF ( A, A ) which has happened!
|
||||
* This is the way DICTdefine used to look before enumerations gained
|
||||
* their unusual behavior with respect to scoping and visibility rules
|
||||
* \sa DICTdefine
|
||||
*/
|
||||
int DICT_define( Dictionary dict, char * name, Generic obj, Symbol * sym, char type ) {
|
||||
struct Element_ e, *e2;
|
||||
@@ -146,32 +142,26 @@ int DICT_define( Dictionary dict, char * name, Generic obj, Symbol * sym, char t
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: DICTundefine
|
||||
** Parameters: Dictionary dictionary - dictionary to modify
|
||||
** char * name - name to remove
|
||||
** Returns: Generic - the entry removed, NULL if not found
|
||||
/**
|
||||
** \param dict dictionary to modify
|
||||
** \param name name to remove
|
||||
** \return the entry removed, NULL if not found
|
||||
Changed to return void, since the hash code frees the element, there
|
||||
is no way to return (without godawful casting) the generic itself.
|
||||
*/
|
||||
|
||||
void
|
||||
DICTundefine( Dictionary dict, char * name ) {
|
||||
void DICTundefine( Dictionary dict, char * name ) {
|
||||
struct Element_ e;
|
||||
|
||||
e.key = name;
|
||||
HASHsearch( dict, &e, HASH_DELETE );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: DICTlookup
|
||||
** Parameters: Dictionary dictionary - dictionary to look in
|
||||
** char * name - name to look up
|
||||
** Returns: Generic - the value found, NULL if not found
|
||||
/**
|
||||
** \param dictionary dictionary to look in
|
||||
** \param name name to look up
|
||||
** \return the value found, NULL if not found
|
||||
*/
|
||||
|
||||
Generic
|
||||
DICTlookup( Dictionary dictionary, char * name ) {
|
||||
Generic DICTlookup( Dictionary dictionary, char * name ) {
|
||||
struct Element_ e, *ep;
|
||||
|
||||
if( !dictionary ) {
|
||||
@@ -187,9 +177,10 @@ DICTlookup( Dictionary dictionary, char * name ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* like DICTlookup but returns symbol, too */
|
||||
Generic
|
||||
DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) {
|
||||
/** like DICTlookup but returns symbol, too
|
||||
* \sa DICTlookup
|
||||
*/
|
||||
Generic DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) {
|
||||
struct Element_ e, *ep;
|
||||
|
||||
if( !dictionary ) {
|
||||
@@ -206,8 +197,7 @@ DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
Generic
|
||||
DICTdo( DictionaryEntry * dict_entry ) {
|
||||
Generic DICTdo( DictionaryEntry * dict_entry ) {
|
||||
if( 0 == HASHlist( dict_entry ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+88
-130
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** Module: Entity
|
||||
** Description: This module is used to represent Express entity definitions.
|
||||
/** **********************************************************************
|
||||
** Module: Entity \file entity.c
|
||||
** This module is used to represent Express entity definitions.
|
||||
** An entity definition consists of a name, a set of attributes, a
|
||||
** collection of uniqueness sets, a specification of the entity's
|
||||
** position in a class hierarchy (i.e., sub- and supertypes), and
|
||||
@@ -116,9 +116,8 @@
|
||||
#include "express/express.h"
|
||||
#include "express/object.h"
|
||||
|
||||
/* returns true if variable is declared (or redeclared) directly by entity */
|
||||
bool
|
||||
ENTITYdeclares_variable( Entity e, Variable v ) {
|
||||
/** returns true if variable is declared (or redeclared) directly by entity */
|
||||
bool ENTITYdeclares_variable( Entity e, Variable v ) {
|
||||
LISTdo( e->u.entity->attributes, attr, Variable )
|
||||
if( attr == v ) {
|
||||
return true;
|
||||
@@ -128,9 +127,7 @@ ENTITYdeclares_variable( Entity e, Variable v ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
Entity
|
||||
ENTITY_find_inherited_entity( Entity entity, char * name, int down ) {
|
||||
static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down ) {
|
||||
Entity result;
|
||||
|
||||
/* avoid searching scopes that we've already searched */
|
||||
@@ -174,8 +171,7 @@ ENTITY_find_inherited_entity( Entity entity, char * name, int down ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct Scope_ *
|
||||
ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) {
|
||||
struct Scope_ * ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) {
|
||||
if( streq( name, entity->symbol.name ) ) {
|
||||
return( entity );
|
||||
}
|
||||
@@ -184,9 +180,8 @@ ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) {
|
||||
return ENTITY_find_inherited_entity( entity, name, down );
|
||||
}
|
||||
|
||||
/* find a (possibly inherited) attribute */
|
||||
Variable
|
||||
ENTITY_find_inherited_attribute( Entity entity, char * name, int * down, struct Symbol_ ** where ) {
|
||||
/** find a (possibly inherited) attribute */
|
||||
Variable ENTITY_find_inherited_attribute( Entity entity, char * name, int * down, struct Symbol_ ** where ) {
|
||||
Variable result;
|
||||
|
||||
/* avoid searching scopes that we've already searched */
|
||||
@@ -231,8 +226,7 @@ ENTITY_find_inherited_attribute( Entity entity, char * name, int * down, struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
Variable
|
||||
ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name,
|
||||
Variable ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name,
|
||||
struct Symbol_ ** down_sym ) {
|
||||
extern int __SCOPE_search_id;
|
||||
int down_flag = 0;
|
||||
@@ -245,10 +239,10 @@ ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name,
|
||||
}
|
||||
}
|
||||
|
||||
/* resolve a (possibly group-qualified) attribute ref. */
|
||||
/* report errors as appropriate */
|
||||
Variable
|
||||
ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) {
|
||||
/** resolve a (possibly group-qualified) attribute ref.
|
||||
* report errors as appropriate
|
||||
*/
|
||||
Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) {
|
||||
extern Error ERROR_unknown_supertype;
|
||||
extern Error ERROR_unknown_attr_in_entity;
|
||||
Entity ref_entity;
|
||||
@@ -287,17 +281,14 @@ ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) {
|
||||
return attr;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITY_create/free/copy/equal
|
||||
** Description: These are the low-level defining functions for Class_Entity
|
||||
/**
|
||||
** low-level function for type Entity
|
||||
**
|
||||
** Notes: The attribute list of a new entity is defined as an
|
||||
** \note The attribute list of a new entity is defined as an
|
||||
** empty list; all other aspects of the entity are initially
|
||||
** undefined (i.e., have appropriate NULL values).
|
||||
*/
|
||||
|
||||
Entity
|
||||
ENTITYcreate( Symbol * sym ) {
|
||||
Entity ENTITYcreate( Symbol * sym ) {
|
||||
Scope s = SCOPEcreate( OBJ_ENTITY );
|
||||
|
||||
s->u.entity = ENTITY_new();
|
||||
@@ -311,40 +302,30 @@ ENTITYcreate( Symbol * sym ) {
|
||||
return( s );
|
||||
}
|
||||
|
||||
/* currently, this is only used by USEresolve */
|
||||
Entity
|
||||
ENTITYcopy( Entity e ) {
|
||||
/**
|
||||
* currently, this is only used by USEresolve
|
||||
* low-level function for type Entity
|
||||
*/
|
||||
Entity ENTITYcopy( Entity e ) {
|
||||
/* for now, do a totally shallow copy */
|
||||
|
||||
Entity e2 = SCOPE_new();
|
||||
*e2 = *e;
|
||||
return e2;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Entity module.
|
||||
*/
|
||||
|
||||
void
|
||||
ENTITYinitialize() {
|
||||
/** Initialize the Entity module. */
|
||||
void ENTITYinitialize() {
|
||||
MEMinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 );
|
||||
OBJcreate( OBJ_ENTITY, SCOPE_get_symbol, "entity",
|
||||
OBJ_ENTITY_BITS );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYadd_attribute
|
||||
** Parameters: Entity entity - entity to modify
|
||||
** Variable attribute - attribute to add
|
||||
** Returns: void
|
||||
** Description: Add an attribute to an entity.
|
||||
/**
|
||||
** \param entity entity to modify
|
||||
** \param attr attribute to add
|
||||
** Add an attribute to an entity.
|
||||
*/
|
||||
|
||||
void
|
||||
ENTITYadd_attribute( Entity entity, Variable attr ) {
|
||||
void ENTITYadd_attribute( Entity entity, Variable attr ) {
|
||||
int rc;
|
||||
|
||||
if( attr->name->type->u.type->body->type != op_ ) {
|
||||
@@ -363,32 +344,25 @@ ENTITYadd_attribute( Entity entity, Variable attr ) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYadd_instance
|
||||
** Parameters: Entity entity - entity to modify
|
||||
** Generic instance - new instance
|
||||
** Returns: void
|
||||
** Description: Add an item to the instance list of an entity.
|
||||
/**
|
||||
** \param entity entity to modify
|
||||
** \param instance new instance
|
||||
** Add an item to the instance list of an entity.
|
||||
*/
|
||||
|
||||
void
|
||||
ENTITYadd_instance( Entity entity, Generic instance ) {
|
||||
void ENTITYadd_instance( Entity entity, Generic instance ) {
|
||||
if( entity->u.entity->instances == LIST_NULL ) {
|
||||
entity->u.entity->instances = LISTcreate();
|
||||
}
|
||||
LISTadd( entity->u.entity->instances, instance );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYhas_supertype
|
||||
** Parameters: Entity child - entity to check parentage of
|
||||
** Entity parent - parent to check for
|
||||
** Returns: Boolean - does child's superclass chain include parent?
|
||||
** Description: Look for a certain entity in the supertype graph of an entity.
|
||||
/**
|
||||
** \param child entity to check parentage of
|
||||
** \param parent parent to check for
|
||||
** \return does child's superclass chain include parent?
|
||||
** Look for a certain entity in the supertype graph of an entity.
|
||||
*/
|
||||
|
||||
bool
|
||||
ENTITYhas_supertype( Entity child, Entity parent ) {
|
||||
bool ENTITYhas_supertype( Entity child, Entity parent ) {
|
||||
LISTdo( child->u.entity->supertypes, entity, Entity )
|
||||
if( entity == parent ) {
|
||||
return true;
|
||||
@@ -400,14 +374,12 @@ ENTITYhas_supertype( Entity child, Entity parent ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYhas_immediate_supertype
|
||||
** Parameters: Entity child - entity to check parentage of
|
||||
** Entity parent - parent to check for
|
||||
** Returns: Boolean - is parent a direct supertype of child?
|
||||
** Description: Check whether an entity has a specific immediate superclass.
|
||||
/**
|
||||
** \param child entity to check parentage of
|
||||
** \param parent parent to check for
|
||||
** \return is parent a direct supertype of child?
|
||||
** Check whether an entity has a specific immediate superclass.
|
||||
*/
|
||||
|
||||
bool ENTITYhas_immediate_supertype( Entity child, Entity parent ) {
|
||||
LISTdo( child->u.entity->supertypes, entity, Entity )
|
||||
if( entity == parent ) {
|
||||
@@ -417,20 +389,8 @@ bool ENTITYhas_immediate_supertype( Entity child, Entity parent ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYget_all_attributes
|
||||
** Parameters: Entity entity - entity to examine
|
||||
** Returns: Linked_List of Variable - all attributes of this entity
|
||||
** Description: Retrieve the attribute list of an entity.
|
||||
**
|
||||
** Notes: If an entity has neither defines nor inherits any
|
||||
** attributes, this call returns an empty list. Note
|
||||
** that this is distinct from the constant LIST_NULL.
|
||||
*/
|
||||
|
||||
static
|
||||
void
|
||||
ENTITY_get_all_attributes( Entity entity, Linked_List result ) {
|
||||
/// called by \sa ENTITYget_all_attributes
|
||||
static void ENTITY_get_all_attributes( Entity entity, Linked_List result ) {
|
||||
LISTdo( entity->u.entity->supertypes, super, Entity )
|
||||
/* if (OBJis_kind_of(super, Class_Entity))*/
|
||||
ENTITY_get_all_attributes( super, result );
|
||||
@@ -441,27 +401,34 @@ ENTITY_get_all_attributes( Entity entity, Linked_List result ) {
|
||||
LISTod;
|
||||
}
|
||||
|
||||
Linked_List
|
||||
ENTITYget_all_attributes( Entity entity ) {
|
||||
/**
|
||||
** \param entity - entity to examine
|
||||
** \return all attributes of this entity
|
||||
**
|
||||
** Retrieve the attribute list of an entity.
|
||||
** \sa ENTITY_get_all_attributes
|
||||
**
|
||||
** Notes: If an entity has neither defines nor inherits any
|
||||
** attributes, this call returns an empty list. Note
|
||||
** that this is distinct from the constant LIST_NULL.
|
||||
*/
|
||||
Linked_List ENTITYget_all_attributes( Entity entity ) {
|
||||
Linked_List result = LISTcreate();
|
||||
|
||||
ENTITY_get_all_attributes( entity, result );
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYget_named_attribute
|
||||
** Parameters: Entity entity - entity to examine
|
||||
** String name - name of attribute to retrieve
|
||||
** Returns: Variable - the named attribute of this entity
|
||||
** Description: Retrieve an entity attribute by name.
|
||||
/**
|
||||
** \param entity - entity to examine
|
||||
** \param name - name of attribute to retrieve
|
||||
** \return the named attribute of this entity
|
||||
** Retrieve an entity attribute by name.
|
||||
**
|
||||
** Notes: If the entity has no attribute with the given name,
|
||||
** VARIABLE_NULL is returned.
|
||||
*/
|
||||
|
||||
Variable
|
||||
ENTITYget_named_attribute( Entity entity, char * name ) {
|
||||
Variable ENTITYget_named_attribute( Entity entity, char * name ) {
|
||||
Variable attribute;
|
||||
|
||||
LISTdo( entity->u.entity->attributes, attr, Variable )
|
||||
@@ -479,19 +446,16 @@ ENTITYget_named_attribute( Entity entity, char * name ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYget_attribute_offset
|
||||
** Parameters: Entity entity - entity to examine
|
||||
** Variable attribute - attribute to retrieve offset for
|
||||
** Returns: int - offset to given attribute
|
||||
** Description: Retrieve offset to an entity attribute.
|
||||
/**
|
||||
** \param entity entity to examine
|
||||
** \param attribute attribute to retrieve offset for
|
||||
** \return offset to given attribute
|
||||
** Retrieve offset to an entity attribute.
|
||||
**
|
||||
** Notes: If the entity does not include the attribute, -1
|
||||
** is returned.
|
||||
*/
|
||||
|
||||
int
|
||||
ENTITYget_attribute_offset( Entity entity, Variable attribute ) {
|
||||
int ENTITYget_attribute_offset( Entity entity, Variable attribute ) {
|
||||
int offset, value;
|
||||
|
||||
LISTdo( entity->u.entity->attributes, attr, Variable )
|
||||
@@ -511,12 +475,11 @@ ENTITYget_attribute_offset( Entity entity, Variable attribute ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYget_named_attribute_offset
|
||||
** Parameters: Entity entity - entity to examine
|
||||
** String name - name of attribute to retrieve
|
||||
** Returns: int - offset to named attribute of this entity
|
||||
** Description: Retrieve offset to an entity attribute by name.
|
||||
/**
|
||||
** \param entity entity to examine
|
||||
** \param name name of attribute to retrieve
|
||||
** \return offset to named attribute of this entity
|
||||
** Retrieve offset to an entity attribute by name.
|
||||
**
|
||||
** Notes: If the entity has no attribute with the given name,
|
||||
** -1 is returned.
|
||||
@@ -542,26 +505,21 @@ int ENTITYget_named_attribute_offset( Entity entity, char * name ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYget_initial_offset
|
||||
** Parameters: Entity entity - entity to examine
|
||||
** Returns: int - number of inherited attributes
|
||||
** Description: Retrieve the initial offset to an entity's local frame.
|
||||
/**
|
||||
** \param entity entity to examine
|
||||
** \return number of inherited attributes
|
||||
** Retrieve the initial offset to an entity's local frame.
|
||||
*/
|
||||
|
||||
int
|
||||
ENTITYget_initial_offset( Entity entity ) {
|
||||
int ENTITYget_initial_offset( Entity entity ) {
|
||||
return entity->u.entity->inheritance;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ENTITYget_size
|
||||
** Parameters: Entity entity - entity to examine
|
||||
** Returns: int - storage size of instantiated entity
|
||||
** Description: Compute the storage size of an entity instance.
|
||||
/** \def ENTITYget_size
|
||||
** \param entity entity to examine
|
||||
** \return storage size of instantiated entity
|
||||
** Compute the storage size of an entity instance.
|
||||
**
|
||||
** Notes: The size is computed in units of Object.
|
||||
** \note The size is computed in units of Object.
|
||||
** \note macroized in entity.h
|
||||
*/
|
||||
|
||||
/* macroized in entity.h */
|
||||
|
||||
+65
-131
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** Module: Error
|
||||
** Description: This module implements the ERROR abstraction
|
||||
/** **********************************************************************
|
||||
** Module: Error \file error.c
|
||||
** This module implements the ERROR abstraction
|
||||
************************************************************************/
|
||||
|
||||
/*
|
||||
@@ -71,42 +71,35 @@
|
||||
|
||||
#include "express/express.h"
|
||||
|
||||
#define ERROR_MAX_ERRORS 100 /* max line-numbered errors */
|
||||
#define ERROR_MAX_SPACE 4000 /* max space for line-numbered errors */
|
||||
#define ERROR_MAX_STRLEN 200 /* assuming all error messages are */
|
||||
/* less than this, if we have less than this much space */
|
||||
/* remaining in the error string buffer, call it a day and */
|
||||
/* dump the buffer */
|
||||
#define ERROR_MAX_ERRORS 100 /**< max line-numbered errors */
|
||||
#define ERROR_MAX_SPACE 4000 /**< max space for line-numbered errors */
|
||||
#define ERROR_MAX_STRLEN 200 /**< assuming all error messages are less than this,
|
||||
* if we have less than this much space remaining
|
||||
* in the error string buffer, call it a day and
|
||||
* dump the buffer */
|
||||
|
||||
extern void exp_pause(); //in fedex.c
|
||||
|
||||
static struct heap_element {
|
||||
unsigned int line;
|
||||
char * msg;
|
||||
} heap[ERROR_MAX_ERRORS + 1]; /* NOTE! element 0 is purposely ignored, and */
|
||||
/* an additional element is at the end. This allows the */
|
||||
/* later heap calculations to be much simpler */
|
||||
} heap[ERROR_MAX_ERRORS + 1]; /**< NOTE! element 0 is purposely ignored, and
|
||||
* an additional element is at the end. This
|
||||
* allows the later heap calculations to be
|
||||
* much simpler */
|
||||
|
||||
static int ERROR_with_lines = 0; /* number of warnings & errors */
|
||||
/* that have occurred with a line number */
|
||||
static int ERROR_with_lines = 0; /**< number of warnings & errors that have occurred with a line number */
|
||||
static char * ERROR_string;
|
||||
static char * ERROR_string_base;
|
||||
|
||||
static bool ERROR_unsafe = false;
|
||||
static jmp_buf ERROR_safe_env;
|
||||
|
||||
/* message buffer file */
|
||||
#define error_file stderr
|
||||
|
||||
/*
|
||||
** Procedure: ERRORinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Error module
|
||||
*/
|
||||
#define error_file stderr /**< message buffer file */
|
||||
|
||||
void
|
||||
ERRORinitialize( void ) {
|
||||
/** Initialize the Error module */
|
||||
void ERRORinitialize( void ) {
|
||||
ERROR_subordinate_failed =
|
||||
ERRORcreate( "A subordinate failed.", SEVERITY_ERROR );
|
||||
ERROR_syntax_expecting =
|
||||
@@ -130,17 +123,14 @@ ERRORinitialize( void ) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Need the LIST routines to complete ERROR initialization */
|
||||
void
|
||||
ERRORinitialize_after_LIST( void ) {
|
||||
/** Need the LIST routines to complete ERROR initialization */
|
||||
void ERRORinitialize_after_LIST( void ) {
|
||||
ERRORwarnings = LISTcreate();
|
||||
|
||||
MEMinitialize( &ERROR_OPT_fl, sizeof( struct Error_Warning_ ), 5, 5 );
|
||||
}
|
||||
|
||||
/*VARARGS*/
|
||||
void
|
||||
ERRORcreate_warning( char * name, Error error ) {
|
||||
void ERRORcreate_warning( char * name, Error error ) {
|
||||
struct Error_Warning_ *o;
|
||||
|
||||
/* first check if we know about this type of error */
|
||||
@@ -159,8 +149,7 @@ ERRORcreate_warning( char * name, Error error ) {
|
||||
LISTadd( ERRORwarnings, ( Generic )o );
|
||||
}
|
||||
|
||||
void
|
||||
ERRORset_warning( char * name, int set ) {
|
||||
void ERRORset_warning( char * name, int set ) {
|
||||
bool found = false;
|
||||
|
||||
if( streq( name, "all" ) ) {
|
||||
@@ -187,8 +176,7 @@ ERRORset_warning( char * name, int set ) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ERRORset_all_warnings( int set ) {
|
||||
void ERRORset_all_warnings( int set ) {
|
||||
LISTdo( ERRORwarnings, opts, Error_Warning )
|
||||
LISTdo( opts->errors, err, Error )
|
||||
err->enabled = set;
|
||||
@@ -196,45 +184,33 @@ ERRORset_all_warnings( int set ) {
|
||||
LISTod
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ERRORdisable
|
||||
** Parameters: Error error - error to disable
|
||||
** Returns: void
|
||||
** Description: Disable an error (ERRORreport*() will ignore it)
|
||||
/** \fn ERRORdisable
|
||||
** \param error error to disable
|
||||
** Disable an error (ERRORreport*() will ignore it)
|
||||
** \note this function is inlined in error.h
|
||||
*/
|
||||
|
||||
/* this function is inlined in error.h */
|
||||
|
||||
/*
|
||||
** Procedure: ERRORenable
|
||||
** Parameters: Error error - error to enable
|
||||
** Returns: void
|
||||
** Description: Enable an error (ERRORreport*() will report it)
|
||||
/** \fn ERRORenable
|
||||
** \param error error to enable
|
||||
** Enable an error (ERRORreport*() will report it)
|
||||
** \note this function is inlined in error.h
|
||||
*/
|
||||
|
||||
/* this function is inlined in error.h */
|
||||
|
||||
/*
|
||||
** Procedure: ERRORis_enabled
|
||||
** Parameters: Error error - error to test
|
||||
** Returns: Boolean - is reporting of the error enabled?
|
||||
** Description: Check whether an error is enabled
|
||||
/** \fn ERRORis_enabled
|
||||
** \param error error to test
|
||||
** \return is reporting of the error enabled?
|
||||
** Check whether an error is enabled
|
||||
** \note this function is inlined in error.h
|
||||
*/
|
||||
|
||||
/* this function is inlined in error.h */
|
||||
|
||||
/*
|
||||
** Procedure: ERRORreport
|
||||
** Parameters: Error what - error to report
|
||||
** ... - arguments for error string
|
||||
** Returns: void
|
||||
** Description: Print a report of an error
|
||||
/** \fn ERRORreport
|
||||
** \param what error to report
|
||||
** \param ... arguments for error string
|
||||
** Print a report of an error
|
||||
**
|
||||
** Notes: The second and subsequent arguments should match the
|
||||
** format fields of the message generated by 'what.'
|
||||
*/
|
||||
|
||||
/*VARARGS*/
|
||||
void
|
||||
#ifdef __STDC__
|
||||
ERRORreport( Error what, ... ) {
|
||||
@@ -279,19 +255,15 @@ va_dcl {
|
||||
va_end( args );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ERRORreport_with_line
|
||||
** Parameters: Error what - error to report
|
||||
** int line - line number of error
|
||||
** ... - arguments for error string
|
||||
** Returns: void
|
||||
** Description: Print a report of an error, including a line number
|
||||
/**
|
||||
** \param what error to report
|
||||
** \param line line number of error
|
||||
** \param ... arguments for error string
|
||||
** Print a report of an error, including a line number
|
||||
**
|
||||
** Notes: The third and subsequent arguments should match the
|
||||
** \note The third and subsequent arguments should match the
|
||||
** format fields of the message generated by 'what.'
|
||||
*/
|
||||
|
||||
/*VARARGS*/
|
||||
void
|
||||
#ifdef __STDC__
|
||||
ERRORreport_with_line( Error what, int line, ... ) {
|
||||
@@ -328,7 +300,6 @@ va_dcl {
|
||||
what->message = savemsg;
|
||||
}
|
||||
|
||||
/*VARARGS*/
|
||||
void
|
||||
#ifdef __STDC__
|
||||
ERRORreport_with_symbol( Error what, Symbol * sym, ... ) {
|
||||
@@ -425,22 +396,18 @@ va_dcl {
|
||||
va_end( args );
|
||||
}
|
||||
|
||||
void
|
||||
ERRORnospace() {
|
||||
void ERRORnospace() {
|
||||
fprintf( stderr, "%s: out of space\n", EXPRESSprogram_name );
|
||||
ERRORabort( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ERRORcreate
|
||||
** Parameters: String message - error message
|
||||
** Severity severity - severity of error
|
||||
** Returns: Error - newly created error
|
||||
** Description: Create a new error
|
||||
/**
|
||||
** \param message error message
|
||||
** \param severity severity of error
|
||||
** \return newly created error
|
||||
** Create a new error
|
||||
*/
|
||||
|
||||
Error
|
||||
ERRORcreate( char * message, Severity severity ) {
|
||||
Error ERRORcreate( char * message, Severity severity ) {
|
||||
Error n;
|
||||
|
||||
n = ( struct Error_ * )malloc( sizeof( struct Error_ ) );
|
||||
@@ -450,49 +417,25 @@ ERRORcreate( char * message, Severity severity ) {
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ERRORbuffer_messages
|
||||
** Parameters: Boolean flag - to buffer or not to buffer
|
||||
** Returns: void
|
||||
** Description: Selects buffering of error messages
|
||||
/** \fn ERRORbuffer_messages
|
||||
** \param flag - to buffer or not to buffer
|
||||
** Selects buffering of error messages
|
||||
** \note this function is inlined in error.h
|
||||
*/
|
||||
|
||||
/* this function is inlined in error.h */
|
||||
|
||||
/*
|
||||
** Procedure: ERRORflush_messages
|
||||
** Parameters: void
|
||||
** Returns: void
|
||||
** Description: Flushes the error message buffer to standard output.
|
||||
/** \fn ERRORflush_messages
|
||||
** Flushes the error message buffer to standard output.
|
||||
** \note this function is inlined in error.h
|
||||
**
|
||||
** Notes: The error messages are sorted by line number (which appears
|
||||
** in the third column).
|
||||
** \note The error messages are sorted by line number (which appears in the third column).
|
||||
*/
|
||||
|
||||
/* this function is inlined in error.h */
|
||||
|
||||
/*
|
||||
** Procedure: ERROR_start_message_buffer
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description:
|
||||
*/
|
||||
|
||||
void
|
||||
ERROR_start_message_buffer( void ) {
|
||||
void ERROR_start_message_buffer( void ) {
|
||||
ERROR_string = ERROR_string_base;
|
||||
ERROR_with_lines = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ERROR_flush_message_buffer
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description:
|
||||
*/
|
||||
|
||||
void
|
||||
ERROR_flush_message_buffer( void ) {
|
||||
void ERROR_flush_message_buffer( void ) {
|
||||
if( __ERROR_buffer_errors == false ) {
|
||||
return;
|
||||
}
|
||||
@@ -522,19 +465,12 @@ ERROR_flush_message_buffer( void ) {
|
||||
break;
|
||||
}
|
||||
heap[parent] = heap[child];
|
||||
#if 0
|
||||
if( replace->line > heap[child].line ) {
|
||||
heap[parent] = heap[child];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
heap[parent] = *replace;
|
||||
}
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
ERRORabort( int sig ) {
|
||||
void ERRORabort( int sig ) {
|
||||
ERRORflush_messages();
|
||||
if( !ERRORdebugging ) {
|
||||
if( ERROR_unsafe ) {
|
||||
@@ -550,12 +486,10 @@ ERRORabort( int sig ) {
|
||||
exp_pause();
|
||||
}
|
||||
|
||||
void
|
||||
ERRORsafe( jmp_buf env ) {
|
||||
void ERRORsafe( jmp_buf env ) {
|
||||
memcpy( ERROR_safe_env, env, sizeof( jmp_buf ) );
|
||||
}
|
||||
|
||||
void
|
||||
ERRORunsafe() {
|
||||
void ERRORunsafe() {
|
||||
ERROR_unsafe = true;
|
||||
}
|
||||
@@ -843,21 +843,6 @@ explicit_attribute : attribute_decl_list TOK_COLON optional
|
||||
LISTod;
|
||||
}
|
||||
;
|
||||
/*
|
||||
if (OBJis_kind_of(attr,Class_Binary_Expression)) {
|
||||
x = BIN_EXPget_second_operand(attr);
|
||||
} else x = attr;
|
||||
if (!OBJis_kind_of(x,Class_Identifier)) {
|
||||
yyerror("illegal attribute name");
|
||||
}
|
||||
v = EXPcreate(...);
|
||||
v->symbol = SYMBOLget_name(
|
||||
IDENTget_identifier(x)),$4,&experrc);
|
||||
VARput_optional(v, true);
|
||||
VARput_reference(v,attr);
|
||||
LISTadd_last(vlist,(Generic)v);
|
||||
*/
|
||||
|
||||
|
||||
express_file : { scope = scopes;
|
||||
/* no need to define scope->this */
|
||||
|
||||
+36
-49
@@ -2,7 +2,7 @@
|
||||
|
||||
/** **********************************************************************
|
||||
** Module: Expression \file expr.c
|
||||
** Description: This module implements the Expression abstraction. Several
|
||||
** This module implements the Expression abstraction. Several
|
||||
** types of expressions are supported: identifiers, literals,
|
||||
** operations (arithmetic, logical, array indexing, etc.), and
|
||||
** function calls. Every expression is marked with a type.
|
||||
@@ -100,8 +100,7 @@ static Error ERROR_enum_no_such_item;
|
||||
static Error ERROR_group_ref_no_such_entity;
|
||||
static Error ERROR_group_ref_unexpected_type;
|
||||
|
||||
Expression
|
||||
EXPcreate( Type type ) {
|
||||
Expression EXPcreate( Type type ) {
|
||||
Expression e;
|
||||
e = EXP_new();
|
||||
SYMBOLset( e );
|
||||
@@ -110,10 +109,11 @@ EXPcreate( Type type ) {
|
||||
return( e );
|
||||
}
|
||||
|
||||
/* use this when the return_type is the same as the type */
|
||||
/* For example, for constant integers */
|
||||
Expression
|
||||
EXPcreate_simple( Type type ) {
|
||||
/**
|
||||
* use this when the return_type is the same as the type
|
||||
* For example, for constant integers
|
||||
*/
|
||||
Expression EXPcreate_simple( Type type ) {
|
||||
Expression e;
|
||||
e = EXP_new();
|
||||
SYMBOLset( e );
|
||||
@@ -121,8 +121,7 @@ EXPcreate_simple( Type type ) {
|
||||
return( e );
|
||||
}
|
||||
|
||||
Expression
|
||||
EXPcreate_from_symbol( Type type, Symbol * symbol ) {
|
||||
Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) {
|
||||
Expression e;
|
||||
e = EXP_new();
|
||||
e->type = type;
|
||||
@@ -131,20 +130,12 @@ EXPcreate_from_symbol( Type type, Symbol * symbol ) {
|
||||
return e;
|
||||
}
|
||||
|
||||
Symbol *
|
||||
EXP_get_symbol( Generic e ) {
|
||||
Symbol * EXP_get_symbol( Generic e ) {
|
||||
return( &( ( Expression )e )->symbol );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: EXPinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Expression module.
|
||||
*/
|
||||
|
||||
void
|
||||
EXPinitialize( void ) {
|
||||
/** Description: Initialize the Expression module. */
|
||||
void EXPinitialize( void ) {
|
||||
MEMinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 );
|
||||
MEMinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 );
|
||||
MEMinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 );
|
||||
@@ -226,11 +217,12 @@ EXPinitialize( void ) {
|
||||
EXPop_init();
|
||||
}
|
||||
|
||||
/* search id is a parameter to avoid colliding with ENTITYfind... */
|
||||
/* there will be no ambiguities, since we're looking at (and marking) */
|
||||
/* only types, and it's marking only entities */
|
||||
static int
|
||||
EXP_resolve_op_dot_fuzzy( Type selection, Symbol ref, Variable * v, char * dt,
|
||||
/**
|
||||
* \param s_id the search id, a parameter to avoid colliding with ENTITYfind...
|
||||
* there will be no ambiguities, since we're looking at (and marking)
|
||||
* only types, and it's marking only entities
|
||||
*/
|
||||
static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol ref, Variable * v, char * dt,
|
||||
struct Symbol_ ** where, int s_id ) {
|
||||
Variable tmp;
|
||||
int options = 0;
|
||||
@@ -279,8 +271,7 @@ EXP_resolve_op_dot_fuzzy( Type selection, Symbol ref, Variable * v, char * dt,
|
||||
}
|
||||
}
|
||||
|
||||
Type
|
||||
EXPresolve_op_dot( Expression expr, Scope scope ) {
|
||||
Type EXPresolve_op_dot( Expression expr, Scope scope ) {
|
||||
Expression op1 = expr->e.op1;
|
||||
Expression op2 = expr->e.op2;
|
||||
Variable v;
|
||||
@@ -423,12 +414,12 @@ EXPresolve_op_dot( Expression expr, Scope scope ) {
|
||||
}
|
||||
}
|
||||
|
||||
/* search id is a parameter to avoid colliding with ENTITYfind... */
|
||||
/* there will be no ambiguities, since we're looking at (and marking) */
|
||||
/* only types, and it's marking only entities */
|
||||
static int
|
||||
EXP_resolve_op_group_fuzzy( Type selection, Symbol ref, Entity * e,
|
||||
int s_id ) {
|
||||
/**
|
||||
* \param s_id the search id, a parameter to avoid colliding with ENTITYfind...
|
||||
* there will be no ambiguities, since we're looking at (and marking)
|
||||
* only types, and it's marking only entities
|
||||
*/
|
||||
static int EXP_resolve_op_group_fuzzy( Type selection, Symbol ref, Entity * e, int s_id ) {
|
||||
Entity tmp;
|
||||
int options = 0;
|
||||
|
||||
@@ -473,8 +464,7 @@ EXP_resolve_op_group_fuzzy( Type selection, Symbol ref, Entity * e,
|
||||
}
|
||||
}
|
||||
|
||||
Type
|
||||
EXPresolve_op_group( Expression expr, Scope scope ) {
|
||||
Type EXPresolve_op_group( Expression expr, Scope scope ) {
|
||||
Expression op1 = expr->e.op1;
|
||||
Expression op2 = expr->e.op2;
|
||||
Entity ent_ref = ENTITY_NULL;
|
||||
@@ -579,8 +569,7 @@ EXPresolve_op_group( Expression expr, Scope scope ) {
|
||||
}
|
||||
}
|
||||
|
||||
Type
|
||||
EXPresolve_op_relational( Expression e, Scope s ) {
|
||||
Type EXPresolve_op_relational( Expression e, Scope s ) {
|
||||
Type t = 0;
|
||||
int failed = 0;
|
||||
Type op1type;
|
||||
@@ -623,8 +612,7 @@ EXPresolve_op_relational( Expression e, Scope s ) {
|
||||
return( Type_Logical );
|
||||
}
|
||||
|
||||
void
|
||||
EXPresolve_op_default( Expression e, Scope s ) {
|
||||
void EXPresolve_op_default( Expression e, Scope s ) {
|
||||
int failed = 0;
|
||||
|
||||
switch( OPget_number_of_operands( e->e.op_code ) ) {
|
||||
@@ -773,12 +761,11 @@ Type EXPresolve_op_unary_minus( Expression e, Scope s ) {
|
||||
return e->e.op1->return_type;
|
||||
}
|
||||
|
||||
/*
|
||||
resolve_func: resolves an expression of this type
|
||||
type_func: returns final type of expression of this type
|
||||
avoids resolution if possible
|
||||
*/
|
||||
|
||||
/**
|
||||
* \param resolve_func resolves an expression of this type
|
||||
* \param type_func returns final type of expression of this type
|
||||
* avoids resolution if possible
|
||||
*/
|
||||
void EXPop_create( int token_number, char * string, Resolve_expr_func * resolve_func ) {
|
||||
EXPop_table[token_number].token = string;
|
||||
EXPop_table[token_number].resolve = resolve_func;
|
||||
@@ -817,7 +804,7 @@ void EXPop_init() {
|
||||
}
|
||||
|
||||
|
||||
/** \fn TERN_EXPcreate
|
||||
/**
|
||||
** \param op operation
|
||||
** \param operand1 - first operand
|
||||
** \param operand2 - second operand
|
||||
@@ -852,7 +839,7 @@ Expression BIN_EXPcreate( Op_Code op, Expression operand1, Expression operand2 )
|
||||
return e;
|
||||
}
|
||||
|
||||
/** \fn UN_EXPcreate
|
||||
/**
|
||||
** \param op operation
|
||||
** \param operand operand
|
||||
** \returns the expression created
|
||||
@@ -866,7 +853,7 @@ Expression UN_EXPcreate( Op_Code op, Expression operand ) {
|
||||
return e;
|
||||
}
|
||||
|
||||
/** \fn QUERYcreate
|
||||
/**
|
||||
** \param local local identifier for source elements
|
||||
** \param aggregate source aggregate to query
|
||||
** \returns the query expression created
|
||||
@@ -888,7 +875,7 @@ Expression QUERYcreate( Symbol * local, Expression aggregate ) {
|
||||
return e;
|
||||
}
|
||||
|
||||
/** \fn EXPget_integer_value
|
||||
/**
|
||||
** \param expression expression to evaluate
|
||||
** \param experrc buffer for error code
|
||||
** \returns value of expression
|
||||
|
||||
+46
-141
@@ -1,6 +1,7 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
/** **********************************************************************
|
||||
** \file express.c
|
||||
** Express package manager.
|
||||
************************************************************************/
|
||||
|
||||
@@ -111,8 +112,7 @@ void exp_pause() {
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
EXPRESS_fail( Express model ) {
|
||||
int EXPRESS_fail( Express model ) {
|
||||
ERRORflush_messages();
|
||||
|
||||
if( EXPRESSfail ) {
|
||||
@@ -123,8 +123,7 @@ EXPRESS_fail( Express model ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
EXPRESS_succeed( Express model ) {
|
||||
int EXPRESS_succeed( Express model ) {
|
||||
if( EXPRESSsucceed ) {
|
||||
return( ( *EXPRESSsucceed )( model ) );
|
||||
}
|
||||
@@ -133,13 +132,11 @@ EXPRESS_succeed( Express model ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Symbol *
|
||||
EXPRESS_get_symbol( Generic e ) {
|
||||
Symbol * EXPRESS_get_symbol( Generic e ) {
|
||||
return( &( ( Express )e )->symbol );
|
||||
}
|
||||
|
||||
Express
|
||||
EXPRESScreate() {
|
||||
Express EXPRESScreate() {
|
||||
Express model = SCOPEcreate( OBJ_EXPRESS );
|
||||
model->u.express = ( struct Express_ * )calloc( 1, sizeof( struct Express_ ) );
|
||||
return model;
|
||||
@@ -151,8 +148,7 @@ typedef struct Dir {
|
||||
char * leaf;
|
||||
} Dir;
|
||||
|
||||
static void
|
||||
EXPRESS_PATHinit() {
|
||||
static void EXPRESS_PATHinit() {
|
||||
char * p;
|
||||
Dir * dir;
|
||||
int done = 0;
|
||||
@@ -224,23 +220,13 @@ EXPRESS_PATHinit() {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PASSinitialize() {
|
||||
/* inform object system about bit representation */
|
||||
/* for handling pass diagnostics */
|
||||
|
||||
/** inform object system about bit representation for handling pass diagnostics */
|
||||
void PASSinitialize() {
|
||||
OBJcreate( OBJ_PASS, UNK_get_symbol, "pass", OBJ_PASS_BITS );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: EXPRESSinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Express package.
|
||||
*/
|
||||
|
||||
void
|
||||
EXPRESSinitialize( void ) {
|
||||
/** Initialize the Express package. */
|
||||
void EXPRESSinitialize( void ) {
|
||||
Function
|
||||
func_abs, func_acos, func_asin, func_atan,
|
||||
func_blength,
|
||||
@@ -331,9 +317,9 @@ EXPRESSinitialize( void ) {
|
||||
funcdef( func_sqrt, KW_SQRT, 1, Type_Real );
|
||||
funcdef( func_tan, KW_TAN, 1, Type_Real );
|
||||
funcdef( func_typeof, KW_TYPEOF, 1, Type_Set_Of_String );
|
||||
funcdef( FUNC_USEDIN, KW_USEDIN, 2, Type_Bag_Of_Generic );
|
||||
funcdef( func_value, KW_VALUE, 1, Type_Number );
|
||||
funcdef( func_value_in, KW_VALUE_IN, 2, Type_Logical );
|
||||
funcdef( FUNC_USEDIN, KW_USEDIN, 2, Type_Bag_Of_Generic );
|
||||
funcdef( func_value, KW_VALUE, 1, Type_Number );
|
||||
funcdef( func_value_in, KW_VALUE_IN, 2, Type_Logical );
|
||||
funcdef( func_value_unique, KW_VALUE_UNIQUE, 1, Type_Logical );
|
||||
|
||||
ERROR_bail_out =
|
||||
@@ -361,14 +347,12 @@ EXPRESSinitialize( void ) {
|
||||
EXPRESS_PATHinit(); /* note, must follow defn of errors it needs! */
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: EXPRESSparse
|
||||
** Parameters: FILE* file - Express source file to parse
|
||||
** Returns: Express - resulting Working Form model
|
||||
** Description: Parse an Express source file into the Working Form.
|
||||
/**
|
||||
** \param file - Express source file to parse
|
||||
** \return resulting Working Form model
|
||||
** Parse an Express source file into the Working Form.
|
||||
*/
|
||||
void
|
||||
EXPRESSparse( Express model, FILE * fp, char * filename ) {
|
||||
void EXPRESSparse( Express model, FILE * fp, char * filename ) {
|
||||
yyexpresult = model;
|
||||
|
||||
if( !fp ) {
|
||||
@@ -418,10 +402,8 @@ EXPRESSparse( Express model, FILE * fp, char * filename ) {
|
||||
PARSERrun( filename, model->u.express->file = fp );
|
||||
}
|
||||
|
||||
static
|
||||
/* start parsing a new schema file */
|
||||
Express
|
||||
PARSERrun( char * filename, FILE * fp ) {
|
||||
/** start parsing a new schema file */
|
||||
static Express PARSERrun( char * filename, FILE * fp ) {
|
||||
extern int yyparse();
|
||||
extern void SCAN_lex_init PROTO( ( char *, FILE * ) );
|
||||
|
||||
@@ -446,12 +428,12 @@ PARSERrun( char * filename, FILE * fp ) {
|
||||
|
||||
static void RENAMEresolve( Rename * r, Schema s );
|
||||
|
||||
/* find the final object to which a rename points */
|
||||
/* i.e., follow chain of USEs or REFs */
|
||||
/* sets DICT_type */
|
||||
static
|
||||
Generic
|
||||
SCOPEfind_for_rename( Scope schema, char * name, enum rename_type type ) {
|
||||
/**
|
||||
* find the final object to which a rename points
|
||||
* i.e., follow chain of USEs or REFs
|
||||
* sets DICT_type
|
||||
*/
|
||||
static Generic SCOPEfind_for_rename( Scope schema, char * name, enum rename_type type ) {
|
||||
Generic result;
|
||||
Rename * rename;
|
||||
|
||||
@@ -519,8 +501,7 @@ SCOPEfind_for_rename( Scope schema, char * name, enum rename_type type ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
RENAMEresolve( Rename * r, Schema s ) {
|
||||
static void RENAMEresolve( Rename * r, Schema s ) {
|
||||
Generic remote;
|
||||
|
||||
/* if (is_resolved_rename_raw(r->old)) return;*/
|
||||
@@ -562,8 +543,7 @@ RENAMEresolve( Rename * r, Schema s ) {
|
||||
}
|
||||
|
||||
#ifdef using_enum_items_is_a_pain
|
||||
static void
|
||||
RENAMEresolve_enum( Type t, Schema s ) {
|
||||
static void RENAMEresolve_enum( Type t, Schema s ) {
|
||||
Dictionary d = TYPEget_enum_tags( t );
|
||||
DictionaryEntry de;
|
||||
Expression x;
|
||||
@@ -576,8 +556,7 @@ RENAMEresolve_enum( Type t, Schema s ) {
|
||||
}
|
||||
#endif
|
||||
|
||||
Schema
|
||||
EXPRESSfind_schema( Dictionary modeldict, char * name ) {
|
||||
Schema EXPRESSfind_schema( Dictionary modeldict, char * name ) {
|
||||
Schema s;
|
||||
FILE * fp;
|
||||
char * src, *dest;
|
||||
@@ -640,12 +619,12 @@ EXPRESSfind_schema( Dictionary modeldict, char * name ) {
|
||||
}
|
||||
|
||||
|
||||
/* make the initial connections from one schema to another */
|
||||
/* dictated by USE/REF clauses that use dictionaries, i.e., */
|
||||
/* because of partial schema references */
|
||||
|
||||
static void
|
||||
connect_lists( Dictionary modeldict, Schema schema, Linked_List list ) {
|
||||
/**
|
||||
* make the initial connections from one schema to another
|
||||
* dictated by USE/REF clauses that use dictionaries, i.e.,
|
||||
* because of partial schema references
|
||||
*/
|
||||
static void connect_lists( Dictionary modeldict, Schema schema, Linked_List list ) {
|
||||
Rename * r;
|
||||
|
||||
/* translate symbols to schemas */
|
||||
@@ -661,9 +640,12 @@ connect_lists( Dictionary modeldict, Schema schema, Linked_List list ) {
|
||||
}
|
||||
LISTod
|
||||
}
|
||||
/* same as above, except for full schemas */
|
||||
static void
|
||||
connect_schema_lists( Dictionary modeldict, Schema schema, Linked_List schema_list ) {
|
||||
|
||||
/**
|
||||
* same as `connect_lists` except for full schemas
|
||||
* \sa connect_lists
|
||||
*/
|
||||
static void connect_schema_lists( Dictionary modeldict, Schema schema, Linked_List schema_list ) {
|
||||
Symbol * sym;
|
||||
Schema ref_schema;
|
||||
|
||||
@@ -681,16 +663,11 @@ connect_schema_lists( Dictionary modeldict, Schema schema, Linked_List schema_li
|
||||
LISTod
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Procedure: EXPRESSresolve
|
||||
** Parameters: Express model - Working Form model to resolve
|
||||
** Returns: void
|
||||
** Description: Perform symbol resolution on a loosely-coupled WF.
|
||||
/**
|
||||
** \param model - Working Form model to resolve
|
||||
** Perform symbol resolution on a loosely-coupled WF.
|
||||
*/
|
||||
|
||||
void
|
||||
EXPRESSresolve( Express model ) {
|
||||
void EXPRESSresolve( Express model ) {
|
||||
/* resolve multiple schemas. Schemas will be resolved here or when */
|
||||
/* they are first encountered by a use/reference clause, whichever */
|
||||
/* comes first - DEL */
|
||||
@@ -854,75 +831,3 @@ EXPRESSresolve( Express model ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
EXPRESSdump_schema( Schema schema ) {
|
||||
Linked_List list, list2, ref;
|
||||
Dictionary dict;
|
||||
DictionaryEntry de;
|
||||
|
||||
printf( "SCHEMA %s\n", SCHEMAget_name( schema ) );
|
||||
list = SCOPEget_types( schema );
|
||||
printf( " Types:\n" );
|
||||
LISTdo( list, s, Symbol * )
|
||||
printf( " %s\n", SYMBOLget_name( s ) );
|
||||
LISTod;
|
||||
list = SCOPEget_entities( schema );
|
||||
printf( " Entities:\n" );
|
||||
LISTdo( list, s, Symbol )
|
||||
printf( " %s\n", SYMBOLget_name( s ) );
|
||||
LISTod;
|
||||
|
||||
/* N14 Dump USE and REFERENCE lists */
|
||||
list = SCOPEget_uses( schema );
|
||||
printf( " Use:\n" );
|
||||
LISTdo( list, use, Linked_List )
|
||||
printf( " Schema: %s\n", SYMBOLget_name( LISTget_first( use ) ) );
|
||||
list2 = LISTget_second( use );
|
||||
LISTdo( list2, use_exp, Expression );
|
||||
printf( " %s AS %s\n",
|
||||
SYMBOLget_name( BIN_EXPget_first_operand( use_exp ) ),
|
||||
SYMBOLget_name( BIN_EXPget_second_operand( use_exp ) ) );
|
||||
LISTod;
|
||||
LISTod;
|
||||
|
||||
dict = SCOPEget_references( schema );
|
||||
printf( " Reference:\n" );
|
||||
DICTdo_init( dict, &de );
|
||||
while( ref = ( Linked_List )DICTdo( &de ) ) {
|
||||
printf( " %s\n", SYMBOLget_name( LISTget_first( ref ) ) );
|
||||
list2 = LISTget_second( ref );
|
||||
LISTdo( list2, ref_exp, Expression );
|
||||
printf( " %s AS %s\n",
|
||||
SYMBOLget_name( BIN_EXPget_first_operand( ref_exp ) ),
|
||||
SYMBOLget_name( BIN_EXPget_second_operand( ref_exp ) ) );
|
||||
LISTod;
|
||||
}
|
||||
|
||||
printf( "END_SCHEMA\n" );
|
||||
|
||||
/* N14 Nested schemas obsolete
|
||||
list = SCOPEget_schemata(schema);
|
||||
LISTdo(list, s, Schema)
|
||||
EXPRESSdump_schema(s);
|
||||
LISTod; */
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: EXPRESSdump_model
|
||||
** Parameters: Express model - Express model to dump
|
||||
** Returns: void
|
||||
** Description: Dumps an Express model to stderr.
|
||||
*/
|
||||
|
||||
/*ARGUSED*/
|
||||
void
|
||||
EXPRESSdump_model( Express model ) {
|
||||
/* should make dump_model and dump_modelS! - DEL */
|
||||
/* EXPRESSdump_schema(model->schema);*/
|
||||
}
|
||||
|
||||
#endif /*0*/
|
||||
|
||||
+4
-14
@@ -25,23 +25,14 @@
|
||||
#include <stdlib.h>
|
||||
#include "express/object.h"
|
||||
|
||||
/*ARGSUSED*/
|
||||
Symbol *
|
||||
UNK_get_symbol( Generic x ) {
|
||||
Symbol * UNK_get_symbol( Generic x ) {
|
||||
fprintf( stderr, "OBJget_symbol called on object of unknown type\n" );
|
||||
ERRORabort( 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: OBJinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Object module
|
||||
*/
|
||||
|
||||
void
|
||||
OBJinitialize() {
|
||||
/** Initialize the Object module */
|
||||
void OBJinitialize() {
|
||||
int i;
|
||||
|
||||
OBJ = ( struct Object * )malloc( MAX_OBJECT_TYPES * sizeof( struct Object ) );
|
||||
@@ -52,8 +43,7 @@ OBJinitialize() {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OBJcreate( char type, struct Symbol_ * ( *get_symbol )( Generic ), char * printable_type, int bits ) {
|
||||
void OBJcreate( char type, struct Symbol_ * ( *get_symbol )( Generic ), char * printable_type, int bits ) {
|
||||
unsigned index = ( unsigned )type;
|
||||
OBJ[index].get_symbol = get_symbol;
|
||||
OBJ[index].type = printable_type;
|
||||
|
||||
+333
-720
File diff suppressed because it is too large.
Load diff
+44
-116
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** Module: Schema
|
||||
** Description: This module implements the Schema abstraction, which
|
||||
/** **********************************************************************
|
||||
** Module: Schema \file schema.c
|
||||
** This module implements the Schema abstraction, which
|
||||
** basically amounts to a named symbol table.
|
||||
** Constants:
|
||||
** SCHEMA_NULL - the null schema
|
||||
@@ -57,94 +57,64 @@
|
||||
|
||||
extern void exp_pause(); //in fedex.c
|
||||
|
||||
Symbol *
|
||||
RENAME_get_symbol( Generic r ) {
|
||||
Symbol * RENAME_get_symbol( Generic r ) {
|
||||
return( ( ( Rename * )r )->old );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: SCHEMAinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Schema module.
|
||||
*/
|
||||
|
||||
void
|
||||
SCHEMAinitialize( void ) {
|
||||
/** Initialize the Schema module. */
|
||||
void SCHEMAinitialize( void ) {
|
||||
OBJcreate( OBJ_RENAME, RENAME_get_symbol, "rename clause", OBJ_UNUSED_BITS );
|
||||
MEMinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 );
|
||||
MEMinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: SCOPEcreate
|
||||
** Parameters: Scope scope - next higher scope
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Scope - the scope created
|
||||
** Description: Create and return an empty scope inside a parent scope.
|
||||
*/
|
||||
|
||||
Scope
|
||||
SCOPEcreate( char type ) {
|
||||
/** Create and return an empty scope inside a parent scope. */
|
||||
Scope SCOPEcreate( char type ) {
|
||||
Scope d = SCOPE_new();
|
||||
d->symbol_table = DICTcreate( 50 );
|
||||
d->type = type;
|
||||
return d;
|
||||
}
|
||||
|
||||
Scope
|
||||
SCOPEcreate_tiny( char type ) {
|
||||
Scope SCOPEcreate_tiny( char type ) {
|
||||
Scope d = SCOPE_new();
|
||||
d->symbol_table = DICTcreate( 1 );
|
||||
d->type = type;
|
||||
return d;
|
||||
}
|
||||
|
||||
/* create a scope without a symbol table */
|
||||
/* used for simple types */
|
||||
Scope
|
||||
SCOPEcreate_nostab( char type ) {
|
||||
/**
|
||||
* create a scope without a symbol table
|
||||
* used for simple types
|
||||
*/
|
||||
Scope SCOPEcreate_nostab( char type ) {
|
||||
Scope d = SCOPE_new();
|
||||
d->type = type;
|
||||
return d;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: SCHEMAcreate
|
||||
** Parameters: String name - name of schema to create
|
||||
** Scope scope - local scope for schema
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Schema - the schema created
|
||||
** Description: Create and return a schema as specified.
|
||||
*/
|
||||
|
||||
Schema
|
||||
SCHEMAcreate( void ) {
|
||||
/** Create and return a schema. */
|
||||
Schema SCHEMAcreate( void ) {
|
||||
Scope s = SCOPEcreate( OBJ_SCHEMA );
|
||||
s->u.schema = SCHEMA_new();
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: SCHEMAget_name
|
||||
** Parameters: Schema schema - schema to examine
|
||||
** Returns: String - schema name
|
||||
** Description: Retrieve the name of a schema.
|
||||
*/
|
||||
|
||||
/* this function is implemented as a macro in schema.h */
|
||||
|
||||
/*
|
||||
** Procedure: SCHEMAdump
|
||||
** Parameters: Schema schema - schema to dump
|
||||
** FILE* file - file to dump to
|
||||
** Returns: void
|
||||
** Description: Dump a schema to a file.
|
||||
**
|
||||
** Notes: This function is provided for debugging purposes.
|
||||
/** SCHEMAget_name
|
||||
** \param schema schema to examine
|
||||
** \return schema name
|
||||
** Retrieve the name of a schema.
|
||||
** \note This function is implemented as a macro in schema.h
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/** \fn SCHEMAdump
|
||||
** \param schema schema to dump
|
||||
** \param file file to dump to
|
||||
** Dump a schema to a file.
|
||||
** \note This function is provided for debugging purposes.
|
||||
*/
|
||||
|
||||
void
|
||||
SCHEMAdump( Schema schema, FILE * file ) {
|
||||
fprintf( file, "SCHEMA %s:\n", SCHEMAget_name( schema ) );
|
||||
@@ -159,8 +129,7 @@ SYMBOLprint( Symbol * s ) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
SCHEMAadd_reference( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * nnew ) {
|
||||
void SCHEMAadd_reference( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * nnew ) {
|
||||
Rename * r = REN_new();
|
||||
r->schema_sym = ref_schema;
|
||||
r->old = old;
|
||||
@@ -173,8 +142,7 @@ SCHEMAadd_reference( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbo
|
||||
LISTadd( cur_schema->u.schema->reflist, ( Generic )r );
|
||||
}
|
||||
|
||||
void
|
||||
SCHEMAadd_use( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * nnew ) {
|
||||
void SCHEMAadd_use( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * nnew ) {
|
||||
Rename * r = REN_new();
|
||||
r->schema_sym = ref_schema;
|
||||
r->old = old;
|
||||
@@ -187,8 +155,7 @@ SCHEMAadd_use( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * nn
|
||||
LISTadd( cur_schema->u.schema->uselist, ( Generic )r );
|
||||
}
|
||||
|
||||
void
|
||||
SCHEMAdefine_reference( Schema schema, Rename * r ) {
|
||||
void SCHEMAdefine_reference( Schema schema, Rename * r ) {
|
||||
Rename * old = 0;
|
||||
char * name = ( r->nnew ? r->nnew : r->old )->name;
|
||||
|
||||
@@ -203,8 +170,7 @@ SCHEMAdefine_reference( Schema schema, Rename * r ) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SCHEMAdefine_use( Schema schema, Rename * r ) {
|
||||
void SCHEMAdefine_use( Schema schema, Rename * r ) {
|
||||
Rename * old = 0;
|
||||
char * name = ( r->nnew ? r->nnew : r->old )->name;
|
||||
|
||||
@@ -219,8 +185,7 @@ SCHEMAdefine_use( Schema schema, Rename * r ) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SCHEMA_get_entities_use( Scope scope, Linked_List result ) {
|
||||
static void SCHEMA_get_entities_use( Scope scope, Linked_List result ) {
|
||||
DictionaryEntry de;
|
||||
Rename * rename;
|
||||
|
||||
@@ -244,9 +209,8 @@ SCHEMA_get_entities_use( Scope scope, Linked_List result ) {
|
||||
}
|
||||
}
|
||||
|
||||
/* return use'd entities */
|
||||
Linked_List
|
||||
SCHEMAget_entities_use( Scope scope ) {
|
||||
/** return use'd entities */
|
||||
Linked_List SCHEMAget_entities_use( Scope scope ) {
|
||||
Linked_List result = LISTcreate();
|
||||
|
||||
__SCOPE_search_id++;
|
||||
@@ -256,10 +220,8 @@ SCHEMAget_entities_use( Scope scope ) {
|
||||
return( result );
|
||||
}
|
||||
|
||||
/* return ref'd entities */
|
||||
static
|
||||
void
|
||||
SCHEMA_get_entities_ref( Scope scope, Linked_List result ) {
|
||||
/** return ref'd entities */
|
||||
static void SCHEMA_get_entities_ref( Scope scope, Linked_List result ) {
|
||||
Rename * rename;
|
||||
DictionaryEntry de;
|
||||
|
||||
@@ -285,9 +247,8 @@ SCHEMA_get_entities_ref( Scope scope, Linked_List result ) {
|
||||
}
|
||||
}
|
||||
|
||||
/* return ref'd entities */
|
||||
Linked_List
|
||||
SCHEMAget_entities_ref( Scope scope ) {
|
||||
/** return ref'd entities */
|
||||
Linked_List SCHEMAget_entities_ref( Scope scope ) {
|
||||
Linked_List result = LISTcreate();
|
||||
|
||||
__SCOPE_search_id++;
|
||||
@@ -298,10 +259,11 @@ SCHEMAget_entities_ref( Scope scope ) {
|
||||
return( result );
|
||||
}
|
||||
|
||||
/* look up an attribute reference */
|
||||
/* if strict false, anything can be returned, not just attributes */
|
||||
Variable
|
||||
VARfind( Scope scope, char * name, int strict ) {
|
||||
/**
|
||||
* look up an attribute reference
|
||||
* if strict false, anything can be returned, not just attributes
|
||||
*/
|
||||
Variable VARfind( Scope scope, char * name, int strict ) {
|
||||
Variable result;
|
||||
|
||||
/* first look up locally */
|
||||
@@ -331,37 +293,3 @@ VARfind( Scope scope, char * name, int strict ) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* look up an attribute reference */
|
||||
/* if strict false, anything can be returned, not just attributes */
|
||||
Variable
|
||||
VARfind( Scope scope, char * name, int strict ) {
|
||||
Variable result;
|
||||
|
||||
/* first look up locally */
|
||||
result = ( Variable )DICTlookup( scope->symbol_table, name );
|
||||
if( result ) {
|
||||
if( strict && ( DICT_type != OBJ_VARIABLE ) ) {
|
||||
printf( "press ^C now to trap to debugger\n" );
|
||||
pause();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
switch( scope->type ) {
|
||||
case OBJ_ENTITY:
|
||||
LISTdo( scope->u.entity->supertypes, e, Entity )
|
||||
result = VARfind( e, name, strict );
|
||||
if( result ) {
|
||||
return( result );
|
||||
}
|
||||
LISTod;
|
||||
break;
|
||||
case OBJ_INCREMENT:
|
||||
case OBJ_QUERY:
|
||||
case OBJ_ALIAS:
|
||||
return( VARfind( scope->superscope, name, strict ) );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
+46
-46
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** Module: Scope
|
||||
** Description: This module implements a hierarchical (i.e., scoped)
|
||||
/** **********************************************************************
|
||||
** Module: Scope \file scope.c
|
||||
** This module implements a hierarchical (i.e., scoped)
|
||||
** symbol table. The symbol table can store definitions of entities,
|
||||
** types, algorithms, and variables, as well as containing a list
|
||||
** of subscopes.
|
||||
@@ -42,30 +42,19 @@
|
||||
#include "express/scope.h"
|
||||
#include "express/resolve.h"
|
||||
|
||||
Symbol *
|
||||
SCOPE_get_symbol( Generic s ) {
|
||||
Symbol * SCOPE_get_symbol( Generic s ) {
|
||||
return( &( ( Scope )s )->symbol );
|
||||
}
|
||||
|
||||
void
|
||||
SCOPEinitialize( void ) {
|
||||
void SCOPEinitialize( void ) {
|
||||
OBJcreate( OBJ_SCHEMA, SCOPE_get_symbol, "schema", OBJ_SCHEMA_BITS );
|
||||
MEMinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: SCOPEget_entities
|
||||
** Parameters: Scope scope - scope to examine
|
||||
** Returns: Linked_List of Entity - entities defined locally
|
||||
** Description: Retrieve a list of the entities defined locally in a scope.
|
||||
**
|
||||
** Notes: This function is considerably faster than
|
||||
** SCOPEget_entities_superclass_order(), and should be used whenever
|
||||
** the order of the entities on the list is not important.
|
||||
*/
|
||||
|
||||
void
|
||||
SCOPE_get_entities( Scope scope, Linked_List result ) {
|
||||
/** SCOPE_get_entities
|
||||
* \sa SCOPEget_entities
|
||||
*/
|
||||
void SCOPE_get_entities( Scope scope, Linked_List result ) {
|
||||
DictionaryEntry de;
|
||||
Generic x;
|
||||
|
||||
@@ -75,25 +64,26 @@ SCOPE_get_entities( Scope scope, Linked_List result ) {
|
||||
}
|
||||
}
|
||||
|
||||
Linked_List
|
||||
SCOPEget_entities( Scope scope ) {
|
||||
/**
|
||||
** \param scope scope to examine
|
||||
** \return entities defined locally
|
||||
**
|
||||
** Retrieve a list of the entities defined locally in a scope.
|
||||
**
|
||||
** \note This function is considerably faster than
|
||||
** SCOPEget_entities_superclass_order(), and should be used whenever
|
||||
** the order of the entities on the list is not important.
|
||||
*/
|
||||
Linked_List SCOPEget_entities( Scope scope ) {
|
||||
Linked_List result = LISTcreate();
|
||||
SCOPE_get_entities( scope, result );
|
||||
return( result );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: SCOPEget_entities_superclass_order
|
||||
** Parameters: Scope scope - scope to examine
|
||||
** Returns: Linked_List of Entity - entities defined locally
|
||||
** Description: Retrieve a list of the entities defined locally in a scope.
|
||||
**
|
||||
** Notes: The list returned is ordered such that an entity appears
|
||||
** before all of its subtypes.
|
||||
*/
|
||||
|
||||
void
|
||||
SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) {
|
||||
/**
|
||||
* \sa SCOPEget_entities_superclass_order
|
||||
*/
|
||||
void SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) {
|
||||
Entity ent;
|
||||
|
||||
if( ( ENTITYget_mark( root ) != ENTITY_MARK ) ) {
|
||||
@@ -109,8 +99,16 @@ SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) {
|
||||
}
|
||||
}
|
||||
|
||||
Linked_List
|
||||
SCOPEget_entities_superclass_order( Scope scope ) {
|
||||
/**
|
||||
** \param scope scope to examine
|
||||
** \return entities defined locally
|
||||
**
|
||||
** Retrieve a list of the entities defined locally in a scope.
|
||||
**
|
||||
** \note The list returned is ordered such that an entity appears before all of its subtypes.
|
||||
** \sa SCOPEget_entities
|
||||
*/
|
||||
Linked_List SCOPEget_entities_superclass_order( Scope scope ) {
|
||||
Linked_List result;
|
||||
DictionaryEntry de;
|
||||
|
||||
@@ -122,11 +120,12 @@ SCOPEget_entities_superclass_order( Scope scope ) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/* find an entity type, return without resolving it */
|
||||
/* note that object found is not actually checked, only because */
|
||||
/* caller is in a better position to describe the error with context */
|
||||
Generic
|
||||
SCOPEfind( Scope scope, char * name, int type ) {
|
||||
/**
|
||||
* find an entity type, return without resolving it
|
||||
* note that object found is not actually checked, only because
|
||||
* caller is in a better position to describe the error with context
|
||||
*/
|
||||
Generic SCOPEfind( Scope scope, char * name, int type ) {
|
||||
extern Generic SCOPE_find( Scope , char *, int );
|
||||
extern Dictionary EXPRESSbuiltins; /* procedures/functions */
|
||||
Generic x;
|
||||
@@ -145,11 +144,12 @@ SCOPEfind( Scope scope, char * name, int type ) {
|
||||
}
|
||||
|
||||
|
||||
/* look up types, functions, etc. anything not inherited through */
|
||||
/* the supertype/subtype hierarchy */
|
||||
/* EH??? -> lookup an object when the current scope is not a schema */
|
||||
Generic
|
||||
SCOPE_find( Scope scope, char * name, int type ) {
|
||||
/**
|
||||
* look up types, functions, etc. anything not inherited through
|
||||
* the supertype/subtype hierarchy
|
||||
* EH??? -> lookup an object when the current scope is not a schema
|
||||
*/
|
||||
Generic SCOPE_find( Scope scope, char * name, int type ) {
|
||||
Generic result;
|
||||
Rename * rename;
|
||||
|
||||
|
||||
+59
-98
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
/** **********************************************************************
|
||||
** Module: Statement
|
||||
** Description: This module implements the Statement abstraction. A
|
||||
** This module implements the Statement abstraction. A
|
||||
** statement is, in effect, a typeless Expression. Due to the
|
||||
** existence of complex language constructs, however, it often is
|
||||
** not practical to implement the abstraction thus. For this reason,
|
||||
@@ -43,8 +43,7 @@
|
||||
#define STATEMENT_C
|
||||
#include "express/stmt.h"
|
||||
|
||||
Statement
|
||||
STMTcreate( int type ) {
|
||||
Statement STMTcreate( int type ) {
|
||||
Statement s;
|
||||
s = STMT_new();
|
||||
SYMBOLset( s );
|
||||
@@ -52,15 +51,8 @@ STMTcreate( int type ) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: STMTinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Statement module.
|
||||
*/
|
||||
|
||||
void
|
||||
STMTinitialize( void ) {
|
||||
/** Initialize the Statement module. */
|
||||
void STMTinitialize( void ) {
|
||||
MEMinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 );
|
||||
|
||||
MEMinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 );
|
||||
@@ -80,17 +72,14 @@ STMTinitialize( void ) {
|
||||
STATEMENT_ESCAPE = STMTcreate( STMT_ESCAPE );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: ASSIGNcreate
|
||||
** Parameters: Expression lhs - the left-hand-side of the assignment
|
||||
** Expression rhs - the right-hand-side of the assignment
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Assignment - the assignment statement created
|
||||
** Description: Create and return an assignment statement.
|
||||
/**
|
||||
** \param lhs the left-hand-side of the assignment
|
||||
** \param rhs the right-hand-side of the assignment
|
||||
** \return the assignment statement created
|
||||
**
|
||||
** Create and return an assignment statement.
|
||||
*/
|
||||
|
||||
Statement
|
||||
ASSIGNcreate( Expression lhs, Expression rhs ) {
|
||||
Statement ASSIGNcreate( Expression lhs, Expression rhs ) {
|
||||
Statement s;
|
||||
s = STMTcreate( STMT_ASSIGN );
|
||||
s->u.assign = ASSIGN_new();
|
||||
@@ -99,17 +88,14 @@ ASSIGNcreate( Expression lhs, Expression rhs ) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: CASEcreate
|
||||
** Parameters: Expression selector - expression to case on
|
||||
** Linked_List cases - list of Case_Items
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Case_Statement - the case statement created
|
||||
** Description: Create and return a case statement.
|
||||
/**
|
||||
** \param selector expression to case on
|
||||
** \param cases list of Case_Items
|
||||
** \return the case statement created
|
||||
**
|
||||
** Create and return a case statement.
|
||||
*/
|
||||
|
||||
Statement
|
||||
CASEcreate( Expression selector, Linked_List cases ) {
|
||||
Statement CASEcreate( Expression selector, Linked_List cases ) {
|
||||
Statement s;
|
||||
|
||||
s = STMTcreate( STMT_CASE );
|
||||
@@ -119,17 +105,13 @@ CASEcreate( Expression selector, Linked_List cases ) {
|
||||
return( s );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: COMP_STMTcreate
|
||||
** Parameters: Linked_List statements - list of Statements making up
|
||||
** the compound statement
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Compound_Statement - the compound statement created
|
||||
** Description: Create and return a compound statement.
|
||||
/**
|
||||
** \param statements - list of Statements making up the compound statement
|
||||
** \return the compound statement created
|
||||
**
|
||||
** Create and return a compound statement.
|
||||
*/
|
||||
|
||||
Statement
|
||||
COMP_STMTcreate( Linked_List statements ) {
|
||||
Statement COMP_STMTcreate( Linked_List statements ) {
|
||||
Statement s;
|
||||
s = STMTcreate( STMT_COMPOUND );
|
||||
s->u.compound = COMP_STMT_new();
|
||||
@@ -137,18 +119,15 @@ COMP_STMTcreate( Linked_List statements ) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: CONDcreate
|
||||
** Parameters: Expression test - the condition for the if
|
||||
** Statement then - code executed for test == true
|
||||
** Statement otherwise - code executed for test == false
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Conditional - the if statement created
|
||||
** Description: Create and return an if statement.
|
||||
/**
|
||||
** \param test the condition for the if
|
||||
** \param then code executed for test == true
|
||||
** \param otherwise code executed for test == false
|
||||
** \return the if statement created
|
||||
**
|
||||
** Create and return an if statement.
|
||||
*/
|
||||
|
||||
Statement
|
||||
CONDcreate( Expression test, Linked_List then, Linked_List otherwise ) {
|
||||
Statement CONDcreate( Expression test, Linked_List then, Linked_List otherwise ) {
|
||||
Statement s;
|
||||
s = STMTcreate( STMT_COND );
|
||||
s->u.cond = COND_new();
|
||||
@@ -158,36 +137,26 @@ CONDcreate( Expression test, Linked_List then, Linked_List otherwise ) {
|
||||
return( s );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: PCALLcreate
|
||||
** Parameters: Procedure procedure - procedure called by statement
|
||||
** Linked_List parameters - list of actual parameter Expressions
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Procedure_Call - the procedure call generated
|
||||
** Description: Create and return a procedure call statement.
|
||||
/**
|
||||
** \param parameters list of actual parameter Expressions
|
||||
** \return the procedure call generated
|
||||
**
|
||||
** Create and return a procedure call statement.
|
||||
*/
|
||||
|
||||
Statement
|
||||
PCALLcreate( Linked_List parameters ) {
|
||||
Statement PCALLcreate( Linked_List parameters ) {
|
||||
Statement s;
|
||||
s = STMTcreate( STMT_PCALL );
|
||||
s->u.proc = PCALL_new();
|
||||
/* s->u.proc->procedure = 0; fill in later during resolution */
|
||||
s->u.proc->parameters = parameters;
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: LOOPcreate
|
||||
** Parameters: Linked_List controls - list of Loop_Controls for the loop
|
||||
** Statement body - statement to be repeated
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Loop - the loop generated
|
||||
** Description: Create and return a loop statement.
|
||||
/**
|
||||
** \return the loop generated
|
||||
**
|
||||
** Create and return a loop statement.
|
||||
*/
|
||||
|
||||
Statement
|
||||
LOOPcreate( Scope scope, Expression while_expr, Expression until_expr, Linked_List statements ) {
|
||||
Statement LOOPcreate( Scope scope, Expression while_expr, Expression until_expr, Linked_List statements ) {
|
||||
Statement s = STMTcreate( STMT_LOOP );
|
||||
s->u.loop = LOOP_new();
|
||||
s->u.loop->scope = scope;
|
||||
@@ -197,8 +166,7 @@ LOOPcreate( Scope scope, Expression while_expr, Expression until_expr, Linked_Li
|
||||
return( s );
|
||||
}
|
||||
|
||||
Statement
|
||||
ALIAScreate( Scope scope, Variable variable, Linked_List statements ) {
|
||||
Statement ALIAScreate( Scope scope, Variable variable, Linked_List statements ) {
|
||||
Statement s = STMTcreate( STMT_ALIAS );
|
||||
s->u.alias = ALIAS_new();
|
||||
s->u.alias->scope = scope;
|
||||
@@ -207,19 +175,16 @@ ALIAScreate( Scope scope, Variable variable, Linked_List statements ) {
|
||||
return( s );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: INCR_CTLcreate
|
||||
** Parameters: Expression control - controlling expression
|
||||
** Expression start - initial value
|
||||
** Expression end - terminal value
|
||||
** Expression increment - value by which to increment
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Increment_Control - increment control created
|
||||
** Description: Create and return an increment control as specified.
|
||||
/**
|
||||
** \param control controlling expression
|
||||
** \param start initial value
|
||||
** \param end terminal value
|
||||
** \param increment value by which to increment
|
||||
** \return increment control created
|
||||
**
|
||||
** Create and return an increment control as specified.
|
||||
*/
|
||||
|
||||
Scope
|
||||
INCR_CTLcreate( Symbol * control, Expression start,
|
||||
Scope INCR_CTLcreate( Symbol * control, Expression start,
|
||||
Expression end, Expression increment ) {
|
||||
Scope s = SCOPEcreate_tiny( OBJ_INCREMENT );
|
||||
Expression e = EXPcreate_from_symbol( Type_Attribute, control );
|
||||
@@ -233,16 +198,12 @@ INCR_CTLcreate( Symbol * control, Expression start,
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: RETcreate
|
||||
** Parameters: Expression expression - value to return
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Return_Statement - the return statement created
|
||||
** Description: Create and return a return statement.
|
||||
/**
|
||||
** \param expression - value to return
|
||||
** \return the return statement created
|
||||
Create and return a return statement.
|
||||
*/
|
||||
|
||||
Statement
|
||||
RETcreate( Expression expression ) {
|
||||
Statement RETcreate( Expression expression ) {
|
||||
Statement s = STMTcreate( STMT_RETURN );
|
||||
s->u.ret = RET_new();
|
||||
s->u.ret->value = expression;
|
||||
|
||||
+12
-21
@@ -1,10 +1,8 @@
|
||||
#if !(defined(__CENTERLINE__) || defined(lint))
|
||||
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
** Module: Symbol
|
||||
** Description: This module implements the Symbol abstraction.
|
||||
/** **********************************************************************
|
||||
** Module: Symbol \file symbol.c
|
||||
** This module implements the Symbol abstraction.
|
||||
** Constants:
|
||||
** SYMBOL_NULL - the null Symbol
|
||||
**
|
||||
@@ -37,27 +35,20 @@
|
||||
#define SYMBOL_C
|
||||
#include "express/symbol.h"
|
||||
|
||||
/*
|
||||
** Procedure: SYMBOLinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Symbol module
|
||||
*/
|
||||
|
||||
void
|
||||
SYMBOLinitialize() {
|
||||
/** Initialize the Symbol module */
|
||||
void SYMBOLinitialize( void ) {
|
||||
MEMinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 );
|
||||
}
|
||||
|
||||
Symbol *
|
||||
SYMBOLcreate( name, line, filename )
|
||||
char * name;
|
||||
int line;
|
||||
char * filename;
|
||||
{
|
||||
Symbol * SYMBOLcreate( char * name, int line, char * filename ) {
|
||||
Symbol * sym = SYMBOL_new();
|
||||
sym->name = name;
|
||||
sym->line = line;
|
||||
sym->filename = current_filename;
|
||||
sym->filename = filename; /* NOTE this used the global 'current_filename',
|
||||
* instead of 'filename'. This func is only
|
||||
* called in two places, and both calls use
|
||||
* 'current_filename'. Changed this to avoid
|
||||
* potential future headaches. (MAP, Jan 12)
|
||||
*/
|
||||
return sym;
|
||||
}
|
||||
+40
-47
@@ -1,22 +1,22 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** Module: Type
|
||||
** Description: This module implements the type abstraction. It is
|
||||
/** **********************************************************************
|
||||
** Module: Type \file type.c
|
||||
This module implements the type abstraction. It is
|
||||
** rather unpleasant, since this abstraction is quite well suited
|
||||
** to an object-oriented environment with inheritance.
|
||||
** Constants:
|
||||
** TYPE_AGGREGATE - generic general aggregate
|
||||
** TYPE_BINARY - binary type
|
||||
** TYPE_BINARY - binary type
|
||||
** TYPE_BOOLEAN - boolean type
|
||||
** TYPE_GENERIC - generic type
|
||||
** TYPE_INTEGER - integer type with default precision
|
||||
** TYPE_LOGICAL - logical type
|
||||
** TYPE_NULL - the null type
|
||||
** TYPE_NUMBER - number type
|
||||
** TYPE_REAL - real type with default precision
|
||||
** TYPE_NULL - the null type
|
||||
** TYPE_NUMBER - number type
|
||||
** TYPE_REAL - real type with default precision
|
||||
** TYPE_SET_OF_GENERIC - type for unconstrained set of generic items
|
||||
** TYPE_STRING - string type with default precision
|
||||
** TYPE_STRING - string type with default precision
|
||||
**
|
||||
************************************************************************/
|
||||
|
||||
@@ -126,9 +126,10 @@
|
||||
#include "express/type.h"
|
||||
|
||||
static Error ERROR_undefined_tag;
|
||||
|
||||
Type
|
||||
TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) {
|
||||
/**
|
||||
* create a type with no symbol table
|
||||
*/
|
||||
Type TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) {
|
||||
Type t = SCOPEcreate_nostab( OBJ_TYPE );
|
||||
TypeHead th = TYPEHEAD_new();
|
||||
|
||||
@@ -139,11 +140,12 @@ TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) {
|
||||
return t;
|
||||
}
|
||||
|
||||
/* create a type but this is just a shell, either to be completed later */
|
||||
/* such as enumerations (which have a symbol table added later) */
|
||||
/* or to be used as a type reference */
|
||||
Type
|
||||
TYPEcreate_name( Symbol * symbol ) {
|
||||
/**
|
||||
* create a type but this is just a shell, either to be completed later
|
||||
* such as enumerations (which have a symbol table added later)
|
||||
* or to be used as a type reference
|
||||
*/
|
||||
Type TYPEcreate_name( Symbol * symbol ) {
|
||||
Scope s = SCOPEcreate_nostab( OBJ_TYPE );
|
||||
TypeHead t = TYPEHEAD_new();
|
||||
|
||||
@@ -152,8 +154,7 @@ TYPEcreate_name( Symbol * symbol ) {
|
||||
return s;
|
||||
}
|
||||
|
||||
Type
|
||||
TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) {
|
||||
Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) {
|
||||
Type t;
|
||||
extern int tag_count;
|
||||
|
||||
@@ -162,24 +163,27 @@ TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) {
|
||||
if( DICT_type == OBJ_TAG ) {
|
||||
return( t );
|
||||
} else {
|
||||
/* easiest to just generate the error this way! */
|
||||
/* following call WILL fail intentionally */
|
||||
/* easiest to just generate the error this way!
|
||||
* following call WILL fail intentionally
|
||||
*/
|
||||
DICTdefine( scope->symbol_table, symbol->name, 0, symbol, OBJ_TAG );
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/* tag is undefined */
|
||||
/* if we are outside a formal parameter list (hack, hack) */
|
||||
/* then we can only refer to existing tags, so produce an error */
|
||||
/* tag is undefined
|
||||
* if we are outside a formal parameter list (hack, hack)
|
||||
* then we can only refer to existing tags, so produce an error
|
||||
*/
|
||||
if( tag_count < 0 ) {
|
||||
ERRORreport_with_symbol( ERROR_undefined_tag, symbol,
|
||||
symbol->name );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* otherwise, we're in a formal parameter list, */
|
||||
/* so it's ok to define it */
|
||||
/* otherwise, we're in a formal parameter list,
|
||||
* so it's ok to define it
|
||||
*/
|
||||
t = TYPEcreate_nostab( symbol, scope, OBJ_TAG );
|
||||
t->u.type->head = base;
|
||||
|
||||
@@ -189,15 +193,13 @@ TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) {
|
||||
return( t );
|
||||
}
|
||||
|
||||
Type
|
||||
TYPEcreate( enum type_enum type ) {
|
||||
Type TYPEcreate( enum type_enum type ) {
|
||||
TypeBody tb = TYPEBODYcreate( type );
|
||||
Type t = TYPEcreate_from_body_anonymously( tb );
|
||||
return( t );
|
||||
}
|
||||
|
||||
Type
|
||||
TYPEcreate_from_body_anonymously( TypeBody tb ) {
|
||||
Type TYPEcreate_from_body_anonymously( TypeBody tb ) {
|
||||
Type t = SCOPEcreate_nostab( OBJ_TYPE );
|
||||
TypeHead th = TYPEHEAD_new();
|
||||
|
||||
@@ -208,19 +210,19 @@ TYPEcreate_from_body_anonymously( TypeBody tb ) {
|
||||
return t;
|
||||
}
|
||||
|
||||
TypeBody
|
||||
TYPEBODYcreate( enum type_enum type ) {
|
||||
TypeBody TYPEBODYcreate( enum type_enum type ) {
|
||||
TypeBody tb = TYPEBODY_new();
|
||||
tb->type = type;
|
||||
return tb;
|
||||
}
|
||||
|
||||
/* return true if "type t" inherits from "enum type_enum" */
|
||||
/* may need to be implemented for more types */
|
||||
/**
|
||||
* return true if "type t" inherits from "enum type_enum"
|
||||
* may need to be implemented for more types
|
||||
*/
|
||||
#define TYPE_inherits_from(t,e) ((t) && TYPEinherits_from((t),(e)))
|
||||
|
||||
bool
|
||||
TYPEinherits_from( Type t, enum type_enum e ) {
|
||||
bool TYPEinherits_from( Type t, enum type_enum e ) {
|
||||
TypeBody tb = t->u.type->body;
|
||||
|
||||
switch( e ) {
|
||||
@@ -268,21 +270,13 @@ return( false );
|
||||
}
|
||||
#endif
|
||||
|
||||
Symbol *
|
||||
TYPE_get_symbol( Generic t ) {
|
||||
Symbol * TYPE_get_symbol( Generic t ) {
|
||||
return( &( ( Type )t )->symbol );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Procedure: TYPEinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Type module.
|
||||
*/
|
||||
|
||||
void
|
||||
TYPEinitialize() {
|
||||
/** Initialize the Type module */
|
||||
void TYPEinitialize() {
|
||||
MEMinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 );
|
||||
MEMinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 );
|
||||
OBJcreate( OBJ_TYPE, TYPE_get_symbol, "type", OBJ_TYPE_BITS );
|
||||
@@ -390,7 +384,6 @@ TYPEinitialize() {
|
||||
ERRORcreate( "Undefined type tag %s", SEVERITY_ERROR );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \param t type to examine
|
||||
* \return the base type of the aggregate type
|
||||
|
||||
+18
-30
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** Module: Variable
|
||||
** Description: This module implements the Variable abstraction. A
|
||||
/** **********************************************************************
|
||||
** Module: Variable \file variable.c
|
||||
** This module implements the Variable abstraction. A
|
||||
** Variable consists of a name, a type, a reference class, and
|
||||
** some flags, e.g. 'optional', 'variable'. It is used to represent
|
||||
** variable attributes, variables, and formal parameters.
|
||||
@@ -89,29 +89,21 @@
|
||||
#include "express/object.h"
|
||||
char * opcode_print( Op_Code o );
|
||||
|
||||
Symbol *
|
||||
VAR_get_symbol( Generic v ) {
|
||||
Symbol * VAR_get_symbol( Generic v ) {
|
||||
return( &( ( Variable )v )->name->symbol );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: VARinitialize
|
||||
** Parameters: -- none --
|
||||
** Returns: void
|
||||
** Description: Initialize the Variable module.
|
||||
*/
|
||||
|
||||
void
|
||||
VARinitialize() {
|
||||
/** Initialize the Variable module. */
|
||||
void VARinitialize() {
|
||||
MEMinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 );
|
||||
/* OBJcreate(OBJ_VARIABLE,VAR_get_symbol,"variable",OBJ_UNUSED_BITS);*/
|
||||
OBJcreate( OBJ_VARIABLE, VAR_get_symbol, "variable", OBJ_VARIABLE_BITS );
|
||||
}
|
||||
|
||||
/* returns simple name of variable */
|
||||
/* for example, if var is named SELF\xxx.yyy, return yyy */
|
||||
extern char *
|
||||
VARget_simple_name( Variable v ) {
|
||||
/** VARget_simple_name
|
||||
* returns simple name of variable
|
||||
* for example, if var is named SELF\xxx.yyy, return yyy
|
||||
*/
|
||||
extern char * VARget_simple_name( Variable v ) {
|
||||
|
||||
Expression e = VARget_name( v );
|
||||
|
||||
@@ -129,21 +121,17 @@ VARget_simple_name( Variable v ) {
|
||||
return EXPget_name( e );
|
||||
}
|
||||
|
||||
/*
|
||||
** Procedure: VARcreate
|
||||
** Parameters: String name - name of variable to create
|
||||
** Type type - type of new variable
|
||||
** Error* experrc - buffer for error code
|
||||
** Returns: Variable - the Variable created
|
||||
** Description: Create and return a new variable.
|
||||
/** VARcreate
|
||||
** \param name name of variable to create
|
||||
** \param type type of new variable
|
||||
** \return the Variable created
|
||||
** Create and return a new variable.
|
||||
**
|
||||
** Notes: The reference class of the variable is, by default,
|
||||
** \note The reference class of the variable is, by default,
|
||||
** dynamic. Special flags associated with the variable
|
||||
** (e.g., optional) are initially false.
|
||||
*/
|
||||
|
||||
Variable
|
||||
VARcreate( Expression name, Type type ) {
|
||||
Variable VARcreate( Expression name, Type type ) {
|
||||
Variable v = VAR_new();
|
||||
v->name = name;
|
||||
v->type = type;
|
||||
|
||||
Reference in new issue
Block a user