comparison lwasm/input.c @ 110:38c1537857ce

Pragma stack at parse stage now works
author lost@l-w.ca
date Sun, 07 Aug 2011 10:37:22 -0600
parents 9960e05cbe3a
children a88b04ba5ab8
comparison
equal deleted inserted replaced
109:6a919c3ca0e9 110:38c1537857ce
335 if (c == EOF) 335 if (c == EOF)
336 { 336 {
337 if (lbloc == 0) 337 if (lbloc == 0)
338 { 338 {
339 struct input_stack *t; 339 struct input_stack *t;
340 struct input_stack_node *n;
340 if (IS -> data) 341 if (IS -> data)
341 fclose(IS -> data); 342 fclose(IS -> data);
342 lw_free(lw_stack_pop(as -> file_dir)); 343 lw_free(lw_stack_pop(as -> file_dir));
343 lw_free(IS -> filespec); 344 lw_free(IS -> filespec);
344 t = IS -> next; 345 t = IS -> next;
346 while (IS -> stack)
347 {
348 n = IS -> stack;
349 IS -> stack = n -> next;
350 lw_free(n -> entry);
351 lw_free(n);
352 }
345 lw_free(IS); 353 lw_free(IS);
346 as -> input_data = t; 354 as -> input_data = t;
347 goto nextfile; 355 goto nextfile;
348 } 356 }
349 linebuff[lbloc] = '\0'; 357 linebuff[lbloc] = '\0';
384 case input_type_string: 392 case input_type_string:
385 /* read from a string */ 393 /* read from a string */
386 if (((char *)(IS -> data))[IS -> data2] == '\0') 394 if (((char *)(IS -> data))[IS -> data2] == '\0')
387 { 395 {
388 struct input_stack *t; 396 struct input_stack *t;
397 struct input_stack_node *n;
389 lw_free(IS -> data); 398 lw_free(IS -> data);
390 lw_free(IS -> filespec); 399 lw_free(IS -> filespec);
391 t = IS -> next; 400 t = IS -> next;
401 while (IS -> stack)
402 {
403 n = IS -> stack;
404 IS -> stack = n -> next;
405 lw_free(n -> entry);
406 lw_free(n);
407 }
392 lw_free(IS); 408 lw_free(IS);
393 as -> input_data = t; 409 as -> input_data = t;
394 goto nextfile; 410 goto nextfile;
395 } 411 }
396 s = (char *)(IS -> data); 412 s = (char *)(IS -> data);
450 struct input_stack_node *n; 466 struct input_stack_node *n;
451 467
452 n = lw_alloc(sizeof(struct input_stack_node)); 468 n = lw_alloc(sizeof(struct input_stack_node));
453 n -> next = IS -> stack; 469 n -> next = IS -> stack;
454 n -> entry = e; 470 n -> entry = e;
471 IS -> stack = n;
455 } 472 }
456 473
457 input_stack_entry *input_stack_pop(asmstate_t *as, int magic, int (*fn)(input_stack_entry *e, void *data), void *data) 474 input_stack_entry *input_stack_pop(asmstate_t *as, int magic, int (*fn)(input_stack_entry *e, void *data), void *data)
458 { 475 {
459 struct input_stack_node *n, *n2; 476 struct input_stack_node *n, *n2;