move a bunch of stuff around
This commit is contained in:
parent
83fb20642b
commit
744cd74016
|
|
@ -7,8 +7,9 @@ unsigned calc_damage(unsigned at, unsigned accuracy) {
|
||||||
return at * accuracy / 20 - 3;
|
return at * accuracy / 20 - 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
int main() {
|
||||||
unsigned dmg = calc_damage(AT, accuracy);
|
unsigned dmg = calc_damage(AT, accuracy);
|
||||||
|
|
||||||
printf("%d%s", dmg, msg);
|
printf("%d%s", dmg, msg);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
print((122 - 32)); // prints ascii `Z`
|
|
||||||
16
test/str.ul
16
test/str.ul
|
|
@ -16,17 +16,17 @@ function pln(str string) {
|
||||||
/**
|
/**
|
||||||
* Concatinates 2 strings
|
* Concatinates 2 strings
|
||||||
*/
|
*/
|
||||||
function concat(str src1, str src2) str {
|
function strcat(str src1, str src2) str {
|
||||||
str result = malloc(src1.length + src2.length);
|
str result = malloc(src1.length + src2.length);
|
||||||
memcpy(result[0].ref, src1.ref);
|
memcpy(&result[0], &src1);
|
||||||
memcpy((&result + src1.length), src2.ref);
|
memcpy((&result + src1.length), &src2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds index of string, -1 if not found
|
* finds index of string, -1 if not found
|
||||||
*/
|
*/
|
||||||
function str_index_of(str haystack, byte needle) int {
|
function stridx(str haystack, byte needle) int {
|
||||||
int i = -1;
|
int i = -1;
|
||||||
for (byte c in haystack) {
|
for (byte c in haystack) {
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
|
|
@ -40,7 +40,7 @@ function str_index_of(str haystack, byte needle) int {
|
||||||
/**
|
/**
|
||||||
* checks if 2 strings are equal
|
* checks if 2 strings are equal
|
||||||
*/
|
*/
|
||||||
function str_eq(str src1, str src2) bool {
|
function streq(str src1, str src2) bool {
|
||||||
if (src1.length != src2.length) return false;
|
if (src1.length != src2.length) return false;
|
||||||
for (int i=0; src1.length; i++) {
|
for (int i=0; src1.length; i++) {
|
||||||
if (src1[i] != src2[i]) return false;
|
if (src1[i] != src2[i]) return false;
|
||||||
|
|
@ -51,7 +51,7 @@ function str_eq(str src1, str src2) bool {
|
||||||
/**
|
/**
|
||||||
* Slice string
|
* Slice string
|
||||||
*/
|
*/
|
||||||
function str_slice(str src, int start, int stop) str {
|
function slice(str src, int start, int stop) str {
|
||||||
int len = stop - start;
|
int len = stop - start;
|
||||||
str result = malloc(len);
|
str result = malloc(len);
|
||||||
for (int i=start; i<stop; i++) {
|
for (int i=start; i<stop; i++) {
|
||||||
|
|
@ -78,7 +78,7 @@ function itos(int src) str {
|
||||||
if(neg) buffer[--i] = '-';
|
if(neg) buffer[--i] = '-';
|
||||||
|
|
||||||
str result = malloc(6 - i);
|
str result = malloc(6 - i);
|
||||||
memcpy(result, buffer[0].ref + i, 6 - i);
|
memcpy(result, &buffer[0] + i, 6 - i);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ function ntos(nat src) str {
|
||||||
} while(n > 0);
|
} while(n > 0);
|
||||||
|
|
||||||
str result = malloc(5 - i);
|
str result = malloc(5 - i);
|
||||||
memcpy(result, buffer[0].ref + i, 5 - i);
|
memcpy(result, &buffer[0] + i, 5 - i);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue