Mercurial > hg > CbC > old > device
diff mc-codegen.c @ 340:0150de6a3244
emit_data moved.
author | kono |
---|---|
date | Sat, 26 Jun 2004 00:26:01 +0900 |
parents | 375d21a2b845 |
children | ca34f02b2056 |
line wrap: on
line diff
--- a/mc-codegen.c Fri Jun 25 21:28:01 2004 +0900 +++ b/mc-codegen.c Sat Jun 26 00:26:01 2004 +0900 @@ -2409,6 +2409,80 @@ return 2; // allow override keep unique } +static void +emit_data(int e, int t, NMTBL *n) +{ + int l; + char *name; + name = n->nm; + if(mode!=GDECL && mode!=STADECL) { + error(-1); return; + } + if (chk) return; + if (n->dsp != -1) { + n->dsp = -1; /* initialized flag */ + emit_global(name,t); + } + switch(t) { + case EMPTY: + if(car(e)!=CONST) error(-1); + emit_space(cadr(e)); + return; + case CHAR: case UCHAR: + emit_char(cadr(e)); + if (data_alignment>0) + data_alignment++; + return; + case SHORT: case USHORT: + emit_short(cadr(e)); + if (data_alignment>0) data_alignment++; + return; + case INT: case UNSIGNED: case ENUM: + emit_int(cadr(e)); + return; + case LONGLONG: case ULONGLONG: + emit_longlong(e); + return; + case DOUBLE: + emit_double(e); + return; + case FLOAT: + emit_float(e); + return; + default: + if (t<0) error(-1); + if (car(t)==BIT_FIELD) { + return; + } + if (car(t)!=POINTER&&car(t)!=ARRAY) error(-1); + switch(car(e)) { + case CONST: + emit_int(cadr(e)); + return; + case ADDRESS: + if (car(cadr(e))==GVAR) + emit_address(((NMTBL *)cadr(cadr(e)))->nm); + else error(INERR); + return; + case FNAME: + case GVAR: + emit_address(((NMTBL *)cadr(e))->nm); + return; + case STRING: + if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) { + l = emit_string_label(); + ascii((char *)cadr(e)); + emit_label(l); + } else + ascii((char *)cadr(e)); + return; + } + // fprintf(stderr,"# type= %d\n",t); + } + error(INERR); +} + + extern int assign_data(int e, int t, NMTBL *n,int offset) {