diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-17 17:43:34 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-17 17:43:34 -0200 |
commit | a84aa11f71be730d554aa208d2b40ad28f2c9e05 (patch) | |
tree | 1d8a0b99fc8df1f87379e5b2f00d558ac39b9d87 /opcode.c | |
parent | 9bee23fd0550e33b2a3f9c8d1b53506b59407e5c (diff) | |
download | lua-a84aa11f71be730d554aa208d2b40ad28f2c9e05.tar.gz lua-a84aa11f71be730d554aa208d2b40ad28f2c9e05.tar.bz2 lua-a84aa11f71be730d554aa208d2b40ad28f2c9e05.zip |
pow operation is defined in mathlib.c
Diffstat (limited to 'opcode.c')
-rw-r--r-- | opcode.c | 34 |
1 files changed, 12 insertions, 22 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.14 1994/11/17 13:58:57 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.15 1994/11/17 16:41:42 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -69,7 +69,7 @@ static void lua_message (char *s) | |||
69 | */ | 69 | */ |
70 | void lua_error (char *s) | 70 | void lua_error (char *s) |
71 | { | 71 | { |
72 | lua_message(s); | 72 | if (s) lua_message(s); |
73 | if (errorJmp) | 73 | if (errorJmp) |
74 | longjmp(*errorJmp, 1); | 74 | longjmp(*errorJmp, 1); |
75 | else | 75 | else |
@@ -877,19 +877,19 @@ static int lua_execute (Byte *pc, int base) | |||
877 | break; | 877 | break; |
878 | 878 | ||
879 | case LTOP: | 879 | case LTOP: |
880 | comparison(LUA_T_NUMBER, LUA_T_NIL, LUA_T_NIL, "<"); | 880 | comparison(LUA_T_NUMBER, LUA_T_NIL, LUA_T_NIL, "lt"); |
881 | break; | 881 | break; |
882 | 882 | ||
883 | case LEOP: | 883 | case LEOP: |
884 | comparison(LUA_T_NUMBER, LUA_T_NUMBER, LUA_T_NIL, "<="); | 884 | comparison(LUA_T_NUMBER, LUA_T_NUMBER, LUA_T_NIL, "le"); |
885 | break; | 885 | break; |
886 | 886 | ||
887 | case GTOP: | 887 | case GTOP: |
888 | comparison(LUA_T_NIL, LUA_T_NIL, LUA_T_NUMBER, ">"); | 888 | comparison(LUA_T_NIL, LUA_T_NIL, LUA_T_NUMBER, "gt"); |
889 | break; | 889 | break; |
890 | 890 | ||
891 | case GEOP: | 891 | case GEOP: |
892 | comparison(LUA_T_NIL, LUA_T_NUMBER, LUA_T_NUMBER, ">="); | 892 | comparison(LUA_T_NIL, LUA_T_NUMBER, LUA_T_NUMBER, "ge"); |
893 | break; | 893 | break; |
894 | 894 | ||
895 | case ADDOP: | 895 | case ADDOP: |
@@ -897,7 +897,7 @@ static int lua_execute (Byte *pc, int base) | |||
897 | Object *l = top-2; | 897 | Object *l = top-2; |
898 | Object *r = top-1; | 898 | Object *r = top-1; |
899 | if (tonumber(r) || tonumber(l)) | 899 | if (tonumber(r) || tonumber(l)) |
900 | call_arith("+"); | 900 | call_arith("add"); |
901 | else | 901 | else |
902 | { | 902 | { |
903 | nvalue(l) += nvalue(r); | 903 | nvalue(l) += nvalue(r); |
@@ -911,7 +911,7 @@ static int lua_execute (Byte *pc, int base) | |||
911 | Object *l = top-2; | 911 | Object *l = top-2; |
912 | Object *r = top-1; | 912 | Object *r = top-1; |
913 | if (tonumber(r) || tonumber(l)) | 913 | if (tonumber(r) || tonumber(l)) |
914 | call_arith("-"); | 914 | call_arith("sub"); |
915 | else | 915 | else |
916 | { | 916 | { |
917 | nvalue(l) -= nvalue(r); | 917 | nvalue(l) -= nvalue(r); |
@@ -925,7 +925,7 @@ static int lua_execute (Byte *pc, int base) | |||
925 | Object *l = top-2; | 925 | Object *l = top-2; |
926 | Object *r = top-1; | 926 | Object *r = top-1; |
927 | if (tonumber(r) || tonumber(l)) | 927 | if (tonumber(r) || tonumber(l)) |
928 | call_arith("*"); | 928 | call_arith("mul"); |
929 | else | 929 | else |
930 | { | 930 | { |
931 | nvalue(l) *= nvalue(r); | 931 | nvalue(l) *= nvalue(r); |
@@ -939,7 +939,7 @@ static int lua_execute (Byte *pc, int base) | |||
939 | Object *l = top-2; | 939 | Object *l = top-2; |
940 | Object *r = top-1; | 940 | Object *r = top-1; |
941 | if (tonumber(r) || tonumber(l)) | 941 | if (tonumber(r) || tonumber(l)) |
942 | call_arith("/"); | 942 | call_arith("div"); |
943 | else | 943 | else |
944 | { | 944 | { |
945 | nvalue(l) /= nvalue(r); | 945 | nvalue(l) /= nvalue(r); |
@@ -949,18 +949,8 @@ static int lua_execute (Byte *pc, int base) | |||
949 | break; | 949 | break; |
950 | 950 | ||
951 | case POWOP: | 951 | case POWOP: |
952 | { | 952 | call_arith("pow"); |
953 | Object *l = top-2; | 953 | break; |
954 | Object *r = top-1; | ||
955 | if (tonumber(r) || tonumber(l)) | ||
956 | call_arith("^"); | ||
957 | else | ||
958 | { | ||
959 | nvalue(l) = pow(nvalue(l), nvalue(r)); | ||
960 | --top; | ||
961 | } | ||
962 | } | ||
963 | break; | ||
964 | 954 | ||
965 | case CONCOP: | 955 | case CONCOP: |
966 | { | 956 | { |