comparison mc-codegen.c @ 340:0150de6a3244

emit_data moved.
author kono
date Sat, 26 Jun 2004 00:26:01 +0900
parents 375d21a2b845
children ca34f02b2056
comparison
equal deleted inserted replaced
339:375d21a2b845 340:0150de6a3244
2406 str_init_eq() 2406 str_init_eq()
2407 { 2407 {
2408 // error(-1); // duplicate struct field value 2408 // error(-1); // duplicate struct field value
2409 return 2; // allow override keep unique 2409 return 2; // allow override keep unique
2410 } 2410 }
2411
2412 static void
2413 emit_data(int e, int t, NMTBL *n)
2414 {
2415 int l;
2416 char *name;
2417 name = n->nm;
2418 if(mode!=GDECL && mode!=STADECL) {
2419 error(-1); return;
2420 }
2421 if (chk) return;
2422 if (n->dsp != -1) {
2423 n->dsp = -1; /* initialized flag */
2424 emit_global(name,t);
2425 }
2426 switch(t) {
2427 case EMPTY:
2428 if(car(e)!=CONST) error(-1);
2429 emit_space(cadr(e));
2430 return;
2431 case CHAR: case UCHAR:
2432 emit_char(cadr(e));
2433 if (data_alignment>0)
2434 data_alignment++;
2435 return;
2436 case SHORT: case USHORT:
2437 emit_short(cadr(e));
2438 if (data_alignment>0) data_alignment++;
2439 return;
2440 case INT: case UNSIGNED: case ENUM:
2441 emit_int(cadr(e));
2442 return;
2443 case LONGLONG: case ULONGLONG:
2444 emit_longlong(e);
2445 return;
2446 case DOUBLE:
2447 emit_double(e);
2448 return;
2449 case FLOAT:
2450 emit_float(e);
2451 return;
2452 default:
2453 if (t<0) error(-1);
2454 if (car(t)==BIT_FIELD) {
2455 return;
2456 }
2457 if (car(t)!=POINTER&&car(t)!=ARRAY) error(-1);
2458 switch(car(e)) {
2459 case CONST:
2460 emit_int(cadr(e));
2461 return;
2462 case ADDRESS:
2463 if (car(cadr(e))==GVAR)
2464 emit_address(((NMTBL *)cadr(cadr(e)))->nm);
2465 else error(INERR);
2466 return;
2467 case FNAME:
2468 case GVAR:
2469 emit_address(((NMTBL *)cadr(e))->nm);
2470 return;
2471 case STRING:
2472 if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) {
2473 l = emit_string_label();
2474 ascii((char *)cadr(e));
2475 emit_label(l);
2476 } else
2477 ascii((char *)cadr(e));
2478 return;
2479 }
2480 // fprintf(stderr,"# type= %d\n",t);
2481 }
2482 error(INERR);
2483 }
2484
2411 2485
2412 extern int 2486 extern int
2413 assign_data(int e, int t, NMTBL *n,int offset) 2487 assign_data(int e, int t, NMTBL *n,int offset)
2414 { 2488 {
2415 int ass,sz,bfd; 2489 int ass,sz,bfd;