mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
long & int: added binary arithmetic
This commit is contained in:
parent
e777a32309
commit
fba4e8ba5e
@ -13,7 +13,12 @@
|
||||
(register random-between (λ [Int Int] Int))
|
||||
(register str (λ [Int] String))
|
||||
(register from-string (λ [&String] Int))
|
||||
(register mask (λ [Int Int] Bool))
|
||||
(register bit-shift-left (λ [Int Int] Int))
|
||||
(register bit-shift-right (λ [Int Int] Int))
|
||||
(register bit-and (λ [Int Int] Int))
|
||||
(register bit-or (λ [Int Int] Int))
|
||||
(register bit-xor (λ [Int Int] Int))
|
||||
(register bit-not (λ [Int] Int))
|
||||
(register inc (λ [Int] Int))
|
||||
(register dec (λ [Int] Int))
|
||||
(register copy (λ [&Int] Int)) ;; TODO: Should not be needed when refs to value types are auto-converted to non-refs.
|
||||
|
@ -12,7 +12,12 @@
|
||||
(register random-between (λ [Long Long] Long))
|
||||
(register str (λ [Long] String))
|
||||
(register from-string (λ [&String] Long))
|
||||
(register mask (λ [Long Long] Bool))
|
||||
(register bit-shift-left (λ [Int Int] Int))
|
||||
(register bit-shift-right (λ [Int Int] Int))
|
||||
(register bit-and (λ [Int Int] Int))
|
||||
(register bit-or (λ [Int Int] Int))
|
||||
(register bit-xor (λ [Int Int] Int))
|
||||
(register bit-not (λ [Int] Int))
|
||||
(register inc (λ [Long] Long))
|
||||
(register dec (λ [Long] Long))
|
||||
(register to-int (λ [Long] Int))
|
||||
|
21
core/core.h
21
core/core.h
@ -78,6 +78,12 @@ bool Int__GT_(int x, int y) { return x > y; }
|
||||
int Int_inc(int x) { return x + 1; }
|
||||
int Int_dec(int x) { return x - 1; }
|
||||
int Int_abs(int x) { return abs(x); }
|
||||
int Int_bit_shift_MINUS_left(int x, int y) { return x << y; }
|
||||
int Int_bit_shift_MINUS_right(int x, int y) { return x >> y; }
|
||||
int Int_bit_MINUS_and(int x, int y) { return x & y; }
|
||||
int Int_bit_MINUS_or(int x, int y) { return x | y; }
|
||||
int Int_bit_MINUS_xor(int x, int y) { return x ^ y; }
|
||||
int Int_bit_MINUS_not(int x) { return ~x; }
|
||||
|
||||
long Long__PLUS_(long x, long y) { return x + y; }
|
||||
long Long__MINUS_(long x, long y) { return x - y; }
|
||||
@ -93,6 +99,12 @@ bool Long__GT_(long x, long y) { return x > y; }
|
||||
long Long_inc(long x) { return x + 1; }
|
||||
long Long_dec(long x) { return x - 1; }
|
||||
long Long_abs(long x) { return labs(x); }
|
||||
long Long_bit_shift_MINUS_left(long x, long y) { return x << y; }
|
||||
long Long_bit_shift_MINUS_right(long x, long y) { return x >> y; }
|
||||
long Long_bit_MINUS_and(long x, long y) { return x & y; }
|
||||
long Long_bit_MINUS_or(long x, long y) { return x | y; }
|
||||
long Long_bit_MINUS_xor(long x, long y) { return x ^ y; }
|
||||
long Long_bit_MINUS_not(long x) { return ~x; }
|
||||
|
||||
int Int_copy(int *x) { return *x; }
|
||||
int Long_copy(long *x) { return *x; }
|
||||
@ -157,10 +169,6 @@ string Int_str(int x) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool Int_mask(int a, int b) {
|
||||
return a & b;
|
||||
}
|
||||
|
||||
long Long_from_MINUS_string(string *s) {
|
||||
return atol(*s);
|
||||
}
|
||||
@ -188,10 +196,6 @@ string Long_str(long x) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool Long_mask(long a, long b) {
|
||||
return a & b;
|
||||
}
|
||||
|
||||
int Long_to_MINUS_int(long a) {
|
||||
return (int) a;
|
||||
}
|
||||
@ -200,7 +204,6 @@ long Long_from_MINUS_int(int a) {
|
||||
return (long) a;
|
||||
}
|
||||
|
||||
|
||||
void String_delete(string s) {
|
||||
CARP_FREE(s);
|
||||
}
|
||||
|
@ -100,8 +100,8 @@
|
||||
(let [x 0
|
||||
y 0
|
||||
state (SDL_GetMouseState (address x) (address y))
|
||||
l (Int.mask state (SDL_BUTTON SDL_BUTTON_LEFT))
|
||||
r (Int.mask state (SDL_BUTTON SDL_BUTTON_RIGHT))]
|
||||
l (/= 0 (Int.bit-and state (SDL_BUTTON SDL_BUTTON_LEFT)))
|
||||
r (/= 0 (Int.bit-and state (SDL_BUTTON SDL_BUTTON_RIGHT)))]
|
||||
(MouseState.init x y l r)))
|
||||
|
||||
;; Time
|
||||
|
Loading…
Reference in New Issue
Block a user