/************************************************************************* * * (c) Copyright 1992,1993,1994 by G & A Technical Software, Inc., * 28 Research Drive, Hampton, Virginia, 23666. * * All Rights Reserved. No part of this software or publication may be * reproduced, stored in a retrieval system, or transmitted, in any form * or by any means, electronic, mechanical, photocopying, recording, or * otherwise without the prior written permission of G & A Technical * Software, Inc. * ************************************************************************* * * Filename: * * Purpose: * * Author: John Burton * * Date: 5/31/94 * ************************************************************************* * * Modification History: * * $Log: s3_parser_pct_functions.c,v $ * Revision 2.1 1994/07/08 17:52:25 jcburt * Updated typedefs, defines and function protypes to allow recursive * parsing of pct files. Enabled use of sub-PDT files and scoping of * datasets. Datasets used in a pct must be defined either in the * associated pdt file or the pdt file associated with the direct * ancestors of the current pct file. * * DataSet functions and subroutines now have an additional parameter * passed to them, indicating the number of parameters passed in the * dataset list, i.e. was: function(DataSet **dl) * now: function(int nargs, DataSet **dl) * Parameters passed to the dataset routines from the PCT level are all * still contained in the dataset list, nargs is during the function or * subroutine call from s3_exec_enode * * Revision 2.0.0.1 1994/06/28 18:48:28 jcburt * S3 Version 2.0 Initial Source * * ************************************************************************* * * Revision Control Information: * *************************************************************************/ static char rcsid[] = "$Id: s3_parser_pct_functions.c,v 2.1 1994/07/08 17:52:25 jcburt Exp $"; static char rcsrev[] = "$Revision: 2.1 $"; /************************************************************************* * * Include Files * *************************************************************************/ #include #include #include #include #include #include #include #include "s3_defines.h" #include "s3_typedefs.h" #include "s3_externals.h" #include "s3_globals.h" #include "s3_parser.tab.h" #include "s3_parser_globals.h" /************************************************************************* * * Module: * * Description: * * Syntax: * * Inputs: * * Outputs: * * Returns: * * Modules Called: * *************************************************************************/ void s3_add_elkey(char *label) { if(current_pct->pn.elkey != NULL) { if(strstr(current_pct->pn.elkey,label) != NULL) yyerror("Label %s already used in this PCT",label); current_pct->pn.elkey = stringcat(current_pct->pn.elkey,label); } else current_pct->pn.elkey = strsave(label); } /************************************************************************* * * Module: * * Description: * * Syntax: * * Inputs: * * Outputs: * * Returns: * * Modules Called: * *************************************************************************/ void s3_add_to_elist(ST_entry *entry) { current_pct->pn.NE++; if(current_pct->pn.elist != NULL) current_pct->pn.elist = (ST_entry **)xrealloc(current_pct->pn.elist, current_pct->pn.NE*sizeof(ST_entry *)); else current_pct->pn.elist = (ST_entry **)xrealloc(NULL,sizeof(ST_entry *)); current_pct->pn.elist[current_pct->pn.NE-1] = entry; } /************************************************************************* * * Module: * * Description: * * Syntax: * * Inputs: * * Outputs: * * Returns: * * Modules Called: * *************************************************************************/ ST_entry *s3_initialize_pnode(ST_entry *entry,ST_entry **list,int count) { ST_entry *tmp; int type; int i,j,len,lenn,nlen; char buff[256]; DataSet ds; entry->pn.NDS = count; entry->pn.dslist = list; entry->pn.count = 0; entry->pn.qtime = 0.0; s3_dprint("s3_initialize_pnode: name = %s",entry->pn.name); s3_dprint(" #datasets = %d",entry->pn.NDS); if(count > 0) { for(i=0;i %s, type = %x",i,entry->pn.dslist[i]->ss.name,entry->pn.dslist[i]->ss.type); if(list[i]->ds.d.data == NULL) list[i] = (ST_entry *)s3_allocate_dataset((DataSet *)list[i]); entry->pn.dslist[i] = list[i]; } } return entry; } /************************************************************************* * * Module: * * Description: * * Syntax: * * Inputs: * * Outputs: * * Returns: * * Modules Called: * *************************************************************************/ ST_entry *s3_initialize_enode(ST_entry *entry,ST_entry **list,int count) { ST_entry *tmp; int i,j,len,lenn,nlen; char buff[256]; DataSet ds; extern char *dld_strerror(); s3_dprint("s3_initialize_enode: name = %s",entry->en.name); s3_dprint(" count = %d",count); s3_dprint(" #datasets = %d",entry->en.NDS); if((entry->en.NDS == UNDEFINED)||(entry->en.type == DFUNC)||(entry->en.type == DSUBR)) entry->en.NDS = count; else if(entry->en.NDS != count) s3_parse_warning("Incorrect number of parameters - was %d now %d",entry->en.NDS,count); tmp = (ST_entry *)xmalloc(sizeof(ST_entry)); tmp->en.name = entry->en.name; tmp->en.type = entry->en.type; tmp->en.NDS = entry->en.NDS; tmp->en.debug = FALSE; tmp->en.count = 0; tmp->en.qtime = 0.0; if((Static_Link) || (Link_Method == NORMAL)) tmp->en.function = entry->en.function; else { switch(entry->en.type) { case CFUNC: case CSUBR: case FFUNC: case FSUBR: /* if((tmp->en.function = entry->en.function) == NULL) s3_error(SYS,"s3_initialize_enode: %s",dld_strerror((int)tmp->en.function)); break; */ case DFUNC: case DSUBR: tmp->en.function = entry->en.function; break; } } if((entry->en.type == FFUNC)||(entry->en.type == FSUBR)) CaseSensitive = TRUE; tmp->en.dslist = list; if(count > 0) { s3_dprint("s3_initialize_enode: name = %s",tmp->en.name); s3_dprint(" #datasets = %d",tmp->en.NDS); for(i=0;i %s, type = %x",i,tmp->en.dslist[i]->ss.name,tmp->en.dslist[i]->ss.type); if(list[i]->ds.d.data == NULL) list[i] = (ST_entry *)s3_allocate_dataset((DataSet *)list[i]); tmp->en.dslist[i] = list[i]; } } return tmp; } /************************************************************************* * * Module: * * Description: * * Syntax: * * Inputs: * * Outputs: * * Returns: * * Modules Called: * *************************************************************************/ ST_entry *s3_make_temp_dataset(char *name, int type, int nd, int *dims) { ST_entry *entry,*tmp; int i; char buff[32]; entry = s3_create_ST_entry(name); entry->ss.type = type; entry->ds.NDIMS = nd; s3_dprint("s3_make_temp_dataset: name = %s",entry->ds.name); s3_dprint(" type = %d",entry->ds.type); s3_dprint(" NDIMS = %d",entry->ds.NDIMS); if(nd > 0) entry->ds.dimlist = (ST_entry **)xcalloc(nd,sizeof(ST_entry *)); else entry->ds.dimlist = NULL; for(i=0;ico.type = CONST; tmp->co.value = dims[i]; entry->ds.dimlist[i] = tmp; } entry = (ST_entry *)s3_allocate_dataset((DataSet *)entry); return entry; } /************************************************************************* * * Module: * * Description: * * Syntax: * * Inputs: * * Outputs: * * Returns: * * Modules Called: * *************************************************************************/ ST_entry **s3_make_parameter_list(ST_entry **param_list,ST_entry *param) { int i, size; ST_entry **plist; ST_entry *entry; s3_dprint("s3_make_parameter_list: name = %s",param->ds.name); s3_dprint(" type = %d",param->ds.type); if(param->ss.type == GROUP) s3_dprint(" NDS = %d",param->gr.NDS); if(param_list == NULL) nparams = 0; size = (param->ss.type == GROUP) ? nparams + param->gr.NDS : nparams + 1; s3_dprint("s3_make_parameter_list: size = %d",size); plist = (param_list == NULL) ? (ST_entry **)xrealloc(NULL,size*sizeof(ST_entry *)) : (ST_entry **)xrealloc(param_list,size*sizeof(ST_entry *)); if(param->ss.type == GROUP) for(i=nparams;igr.dslist[i-nparams]; if(entry->ss.type == CONST) { plist[i] = s3_make_temp_dataset(entry->ss.name,INT,0,NULL); plist[i]->ds.d.in[0] = entry->co.value; } else plist[i] = param->gr.dslist[i-nparams]; } else plist[nparams] = param; nparams = size; return plist; }