version 1.4, 2000/09/21 09:19:27 |
version 1.6, 2003/05/14 06:20:13 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/parse/struct.c,v 1.3 2000/08/22 05:04:28 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/struct.c,v 1.5 2001/10/09 01:36:25 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
struct oSS oLSS; |
struct oSS oLSS; |
SS LSS = &oLSS; |
SS LSS = &oLSS; |
|
|
int structdef(name,member) |
int structdef(char *name,NODE member) |
char *name; |
|
NODE member; |
|
{ |
{ |
int i,j,k,type; |
int i,j; |
SDEF sdef,s; |
SDEF sdef,s; |
NODE n,ms; |
NODE n; |
char *mname,*sname; |
char *mname; |
|
|
/* search the predefined structure */ |
/* search the predefined structure */ |
for ( s = LSS->sa, i = 0; i < LSS->n; i++ ) |
for ( s = LSS->sa, i = 0; i < LSS->n; i++ ) |
|
|
return i; |
return i; |
} |
} |
|
|
void newstruct(type,rp) |
void newstruct(int type,COMP *rp) |
int type; |
|
COMP *rp; |
|
{ |
{ |
NEWCOMP(*rp,LSS->sa[type].n); (*rp)->type = type; |
NEWCOMP(*rp,LSS->sa[type].n); (*rp)->type = type; |
} |
} |
|
|
int structtoindex(name) |
int structtoindex(char *name) |
char *name; |
|
{ |
{ |
SDEF s; |
SDEF s; |
int i; |
int i; |
|
|
return i; |
return i; |
} |
} |
|
|
int membertoindex(type,name) |
int membertoindex(int type,char *name) |
int type; |
|
char *name; |
|
{ |
{ |
SDEF s; |
SDEF s; |
char **member; |
char **member; |
|
|
return i; |
return i; |
} |
} |
|
|
int getcompsize(type) |
int getcompsize(int type) |
int type; |
|
{ |
{ |
return LSS->sa[type].n; |
return LSS->sa[type].n; |
} |
} |
|
|
#if 0 |
Obj memberofstruct(COMP a,char *name) |
void getmember(expr,memp) |
|
FNODE expr; |
|
Obj *memp; |
|
{ |
{ |
int i; |
|
FNODE root; |
|
COMP t; |
|
PV v0; |
|
NODE2 mchain; |
|
|
|
root = (FNODE)FA1(expr); mchain = (NODE2)FA2(expr); |
|
if ( ID(root) == I_PVAR ) { |
|
i = (int)FA0(root); |
|
v0 = i>=0?&CPVS->va[(unsigned int)i]:&GPVS->va[((unsigned int)i)&~MSB]; |
|
t = (COMP)v0->priv; |
|
} else |
|
t = (COMP)eval(root); |
|
for ( ; mchain; mchain = NEXT(mchain) ) |
|
t = (COMP)(t->member[(int)BDY1(mchain)]); |
|
*memp = (Obj)t; |
|
} |
|
|
|
void getmemberp(expr,addrp) |
|
FNODE expr; |
|
Obj **addrp; |
|
{ |
|
int i; |
|
FNODE root; |
|
COMP t; |
|
PV v0; |
|
COMP *addr; |
|
NODE2 mchain; |
|
|
|
root = (FNODE)FA1(expr); mchain = (NODE2)FA2(expr); |
|
if ( ID(root) == I_PVAR ) { |
|
i = (int)FA0(root); |
|
v0 = i>=0?&CPVS->va[(unsigned int)i]:&GPVS->va[((unsigned int)i)&~MSB]; |
|
addr = (COMP *)&v0->priv; |
|
} else { |
|
t = (COMP)eval(root); |
|
addr = (COMP *)&t; |
|
} |
|
for ( ; mchain; mchain = NEXT(mchain) ) |
|
addr = (COMP *)&((*addr)->member[(int)BDY1(mchain)]); |
|
*addrp = (Obj *)addr; |
|
} |
|
|
|
void getarrayp(a,ind,addrp) |
|
Obj a; |
|
NODE ind; |
|
Obj **addrp; |
|
{ |
|
Obj len,row,col; |
|
Obj *addr; |
|
|
|
switch ( OID(a) ) { |
|
case O_VECT: |
|
len = (Obj)BDY(ind); |
|
if ( !rangecheck(len,((VECT)a)->len) ) |
|
error("getarrayp : Out of range"); |
|
else |
|
addr = (Obj *)&(BDY((VECT)a)[QTOS((Q)len)]); |
|
break; |
|
case O_MAT: |
|
row = (Obj)BDY(ind); col = (Obj)BDY(NEXT(ind)); |
|
if ( !rangecheck(row,((MAT)a)->row) |
|
|| !rangecheck(col,((MAT)a)->col) ) |
|
error("getarrayp : Out of range"); |
|
else |
|
addr = (Obj *)&(BDY((MAT)a)[QTOS((Q)row)][QTOS((Q)col)]); |
|
break; |
|
default: |
|
addr = 0; |
|
break; |
|
} |
|
*addrp = addr; |
|
} |
|
#endif |
|
|
|
Obj memberofstruct(a,name) |
|
COMP a; |
|
char *name; |
|
{ |
|
NODE2 n,*np; |
|
int type,ind; |
int type,ind; |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
|
|
|
|
return (Obj)a->member[ind]; |
return (Obj)a->member[ind]; |
} |
} |
|
|
void assign_to_member(a,name,obj) |
void assign_to_member(COMP a,char *name,Obj obj) |
COMP a; |
|
char *name; |
|
Obj obj; |
|
{ |
{ |
NODE2 n,*np; |
|
int type,ind; |
int type,ind; |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
|
|