Mercurial > hg-old > index.cgi
comparison lwasm/pseudo.c @ 236:a58f49a77441
Added os9 target, pragma to control whether $ localizes a symbol, and fixed some condition nesting bugs
author | lost |
---|---|
date | Fri, 14 Aug 2009 03:22:26 +0000 |
parents | aa0056ca7319 |
children | 31231d1c87e6 |
comparison
equal
deleted
inserted
replaced
235:aa0056ca7319 | 236:a58f49a77441 |
---|---|
755 int rval; | 755 int rval; |
756 | 756 |
757 if (as -> skipcond && !(as -> skipmacro)) | 757 if (as -> skipcond && !(as -> skipmacro)) |
758 { | 758 { |
759 as -> skipcount++; | 759 as -> skipcount++; |
760 skip_operand(p); | |
760 return; | 761 return; |
761 } | 762 } |
762 | 763 |
763 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); | 764 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); |
764 if (rval != 0) | 765 if (rval != 0) |
777 char *p2; | 778 char *p2; |
778 | 779 |
779 if (as -> skipcond && !(as -> skipmacro)) | 780 if (as -> skipcond && !(as -> skipmacro)) |
780 { | 781 { |
781 as -> skipcount++; | 782 as -> skipcount++; |
783 skip_operand(p); | |
782 return; | 784 return; |
783 } | 785 } |
784 | 786 |
785 if (as -> passnum != 1) | 787 if (as -> passnum != 1) |
786 { | 788 { |
787 skip_operand(p); | 789 skip_operand(p); |
788 if (!(l -> fsize)) | 790 if (!(l -> fsize)) |
791 { | |
792 as -> skipcond = 1; | |
793 as -> skipcount = 1; | |
794 } | |
795 return; | |
796 } | |
797 | |
798 if (!**p) | |
799 { | |
800 register_error(as, l, 1, "Need symbol name"); | |
801 return; | |
802 } | |
803 | |
804 for (p2 = *p; **p && !isspace(**p); (*p)++) | |
805 /* do nothing */ ; | |
806 | |
807 sym = lwasm_alloc(*p - p2 + 1); | |
808 memcpy(sym, p2, *p - p2); | |
809 sym[*p - p2] = '\0'; | |
810 | |
811 // fprintf(stderr, "STUFF: %s; '%s'; '%s' (%d)\n", p2, *p, sym, as -> passnum); | |
812 se = lwasm_find_symbol(as, sym, l -> context); | |
813 if (!se) | |
814 se = lwasm_find_symbol(as, sym, -1); | |
815 | |
816 lwasm_free(sym); | |
817 | |
818 if (!se) | |
819 { | |
820 as -> skipcond = 1; | |
821 as -> skipcount = 1; | |
822 l -> fsize = 0; | |
823 } | |
824 else | |
825 { | |
826 l -> fsize = 1; | |
827 } | |
828 } | |
829 | |
830 OPFUNC(pseudo_ifndef) | |
831 { | |
832 lwasm_symbol_ent_t *se; | |
833 char *sym; | |
834 char *p2; | |
835 | |
836 if (as -> skipcond && !(as -> skipmacro)) | |
837 { | |
838 as -> skipcount++; | |
839 skip_operand(p); | |
840 return; | |
841 } | |
842 | |
843 if (as -> passnum != 1) | |
844 { | |
845 skip_operand(p); | |
846 if (l -> fsize) | |
789 { | 847 { |
790 as -> skipcond = 1; | 848 as -> skipcond = 1; |
791 as -> skipcount = 1; | 849 as -> skipcount = 1; |
792 } | 850 } |
793 return; | 851 return; |
806 memcpy(sym, *p, p2 - *p); | 864 memcpy(sym, *p, p2 - *p); |
807 sym[p2 - *p] = '\0'; | 865 sym[p2 - *p] = '\0'; |
808 | 866 |
809 *p = p2; | 867 *p = p2; |
810 | 868 |
869 // fprintf(stderr, "STUFF2: %s; '%s'; '%s' (%d)\n", *p, p2, sym, as -> passnum); | |
811 se = lwasm_find_symbol(as, sym, l -> context); | 870 se = lwasm_find_symbol(as, sym, l -> context); |
812 if (!se) | 871 if (!se) |
813 se = lwasm_find_symbol(as, sym, -1); | 872 se = lwasm_find_symbol(as, sym, -1); |
814 | 873 |
815 lwasm_free(sym); | 874 lwasm_free(sym); |
816 | 875 |
817 if (!se) | 876 if (se) |
818 { | 877 { |
819 as -> skipcond = 1; | 878 as -> skipcond = 1; |
820 as -> skipcount = 1; | 879 as -> skipcount = 1; |
821 l -> fsize = 0; | 880 l -> fsize = 0; |
822 } | 881 } |
824 { | 883 { |
825 l -> fsize = 1; | 884 l -> fsize = 1; |
826 } | 885 } |
827 } | 886 } |
828 | 887 |
829 OPFUNC(pseudo_ifndef) | 888 OPFUNC(pseudo_ifp1) |
830 { | 889 { |
831 lwasm_symbol_ent_t *se; | |
832 char *sym; | |
833 char *p2; | |
834 | |
835 if (as -> skipcond && !(as -> skipmacro)) | 890 if (as -> skipcond && !(as -> skipmacro)) |
836 { | 891 { |
837 as -> skipcount++; | 892 as -> skipcount++; |
893 skip_operand(p); | |
838 return; | 894 return; |
839 } | 895 } |
840 | 896 |
841 if (as -> passnum != 1) | 897 if (as -> passnum != 1) |
842 { | |
843 skip_operand(p); | |
844 if (l -> fsize) | |
845 { | |
846 as -> skipcond = 1; | |
847 as -> skipcount = 1; | |
848 } | |
849 return; | |
850 } | |
851 | |
852 if (!**p) | |
853 { | |
854 register_error(as, l, 1, "Need symbol name"); | |
855 return; | |
856 } | |
857 | |
858 for (p2 = *p; *p2 && !isspace(*p2); p2++) | |
859 /* do nothing */ ; | |
860 | |
861 sym = lwasm_alloc(p2 - *p + 1); | |
862 memcpy(sym, *p, p2 - *p); | |
863 sym[p2 - *p] = '\0'; | |
864 | |
865 *p = p2; | |
866 | |
867 se = lwasm_find_symbol(as, sym, l -> context); | |
868 if (!se) | |
869 se = lwasm_find_symbol(as, sym, -1); | |
870 | |
871 lwasm_free(sym); | |
872 | |
873 if (se) | |
874 { | 898 { |
875 as -> skipcond = 1; | 899 as -> skipcond = 1; |
876 as -> skipcount = 1; | 900 as -> skipcount = 1; |
877 l -> fsize = 0; | 901 } |
878 } | 902 } |
879 else | 903 |
880 { | 904 OPFUNC(pseudo_ifp2) |
881 l -> fsize = 1; | 905 { |
882 } | 906 if (as -> skipcond && !(as -> skipmacro)) |
883 } | 907 { |
884 | 908 as -> skipcount++; |
909 skip_operand(p); | |
910 return; | |
911 } | |
912 | |
913 if (as -> passnum != 2) | |
914 { | |
915 as -> skipcond = 1; | |
916 as -> skipcount = 1; | |
917 } | |
918 } | |
919 | |
885 OPFUNC(pseudo_ifeq) | 920 OPFUNC(pseudo_ifeq) |
886 { | 921 { |
887 int v1; | 922 int v1; |
888 int rval; | 923 int rval; |
889 | 924 |
890 if (as -> skipcond && !(as -> skipmacro)) | 925 if (as -> skipcond && !(as -> skipmacro)) |
891 { | 926 { |
892 as -> skipcount++; | 927 as -> skipcount++; |
928 skip_operand(p); | |
893 return; | 929 return; |
894 } | 930 } |
895 | 931 |
896 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); | 932 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); |
897 if (rval != 0) | 933 if (rval != 0) |
909 int rval; | 945 int rval; |
910 | 946 |
911 if (as -> skipcond && !(as -> skipmacro)) | 947 if (as -> skipcond && !(as -> skipmacro)) |
912 { | 948 { |
913 as -> skipcount++; | 949 as -> skipcount++; |
950 skip_operand(p); | |
914 return; | 951 return; |
915 } | 952 } |
916 | 953 |
917 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); | 954 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); |
918 if (rval != 0) | 955 if (rval != 0) |
930 int rval; | 967 int rval; |
931 | 968 |
932 if (as -> skipcond && !(as -> skipmacro)) | 969 if (as -> skipcond && !(as -> skipmacro)) |
933 { | 970 { |
934 as -> skipcount++; | 971 as -> skipcount++; |
972 skip_operand(p); | |
935 return; | 973 return; |
936 } | 974 } |
937 | 975 |
938 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); | 976 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); |
939 if (rval != 0) | 977 if (rval != 0) |
951 int rval; | 989 int rval; |
952 | 990 |
953 if (as -> skipcond && !(as -> skipmacro)) | 991 if (as -> skipcond && !(as -> skipmacro)) |
954 { | 992 { |
955 as -> skipcount++; | 993 as -> skipcount++; |
994 skip_operand(p); | |
956 return; | 995 return; |
957 } | 996 } |
958 | 997 |
959 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); | 998 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); |
960 if (rval != 0) | 999 if (rval != 0) |
972 int rval; | 1011 int rval; |
973 | 1012 |
974 if (as -> skipcond && !(as -> skipmacro)) | 1013 if (as -> skipcond && !(as -> skipmacro)) |
975 { | 1014 { |
976 as -> skipcount++; | 1015 as -> skipcount++; |
1016 skip_operand(p); | |
977 return; | 1017 return; |
978 } | 1018 } |
979 | 1019 |
980 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); | 1020 rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0); |
981 if (rval != 0) | 1021 if (rval != 0) |