Mercurial > hg-old > index.cgi
comparison src/pseudo.c @ 104:2ba8f9ef1417
Added ifdef/ifndef conditionals
author | lost |
---|---|
date | Sun, 25 Jan 2009 04:02:50 +0000 |
parents | 26c058fa0bc1 |
children |
comparison
equal
deleted
inserted
replaced
103:26c058fa0bc1 | 104:2ba8f9ef1417 |
---|---|
546 return; | 546 return; |
547 if (!v1) | 547 if (!v1) |
548 { | 548 { |
549 as -> skipcond = 1; | 549 as -> skipcond = 1; |
550 as -> skipcount = 1; | 550 as -> skipcount = 1; |
551 } | |
552 } | |
553 | |
554 OPFUNC(pseudo_ifdef) | |
555 { | |
556 lwasm_symbol_ent_t *se; | |
557 char *sym; | |
558 char *p2; | |
559 | |
560 if (as -> skipcond && !(as -> skipmacro)) | |
561 { | |
562 as -> skipcount++; | |
563 return; | |
564 } | |
565 | |
566 if (as -> passnum != 1) | |
567 { | |
568 if (!(l -> fsize)) | |
569 { | |
570 as -> skipcond = 1; | |
571 as -> skipcount = 1; | |
572 } | |
573 return; | |
574 } | |
575 | |
576 if (!**p) | |
577 { | |
578 register_error(as, l, 1, "Need symbol name"); | |
579 return; | |
580 } | |
581 | |
582 for (p2 = *p; *p2 && !isspace(*p2); p2++) | |
583 /* do nothing */ ; | |
584 | |
585 sym = lwasm_alloc(p2 - *p + 1); | |
586 memcpy(sym, *p, p2 - *p); | |
587 sym[p2 - *p] = '\0'; | |
588 | |
589 *p = p2; | |
590 | |
591 se = lwasm_find_symbol(as, sym, l -> context); | |
592 if (!se) | |
593 se = lwasm_find_symbol(as, sym, -1); | |
594 | |
595 lwasm_free(sym); | |
596 | |
597 if (!se) | |
598 { | |
599 as -> skipcond = 1; | |
600 as -> skipcount = 1; | |
601 l -> fsize = 0; | |
602 } | |
603 else | |
604 { | |
605 l -> fsize = 1; | |
606 } | |
607 } | |
608 | |
609 OPFUNC(pseudo_ifndef) | |
610 { | |
611 lwasm_symbol_ent_t *se; | |
612 char *sym; | |
613 char *p2; | |
614 | |
615 if (as -> skipcond && !(as -> skipmacro)) | |
616 { | |
617 as -> skipcount++; | |
618 return; | |
619 } | |
620 | |
621 if (as -> passnum != 1) | |
622 { | |
623 if (l -> fsize) | |
624 { | |
625 as -> skipcond = 1; | |
626 as -> skipcount = 1; | |
627 } | |
628 return; | |
629 } | |
630 | |
631 if (!**p) | |
632 { | |
633 register_error(as, l, 1, "Need symbol name"); | |
634 return; | |
635 } | |
636 | |
637 for (p2 = *p; *p2 && !isspace(*p2); p2++) | |
638 /* do nothing */ ; | |
639 | |
640 sym = lwasm_alloc(p2 - *p + 1); | |
641 memcpy(sym, *p, p2 - *p); | |
642 sym[p2 - *p] = '\0'; | |
643 | |
644 *p = p2; | |
645 | |
646 se = lwasm_find_symbol(as, sym, l -> context); | |
647 if (!se) | |
648 se = lwasm_find_symbol(as, sym, -1); | |
649 | |
650 lwasm_free(sym); | |
651 | |
652 if (se) | |
653 { | |
654 as -> skipcond = 1; | |
655 as -> skipcount = 1; | |
656 l -> fsize = 0; | |
657 } | |
658 else | |
659 { | |
660 l -> fsize = 1; | |
551 } | 661 } |
552 } | 662 } |
553 | 663 |
554 OPFUNC(pseudo_ifeq) | 664 OPFUNC(pseudo_ifeq) |
555 { | 665 { |