Merge pull request 'Small changes' (#4) from bedohswe/labashki:master into master
Reviewed-on: #4
This commit is contained in:
commit
56a0390be3
10
Makefile
10
Makefile
@ -1,7 +1,11 @@
|
|||||||
CC=clang
|
CC ?= clang
|
||||||
|
CFLAGS ?=
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(CC) -o lbr -O2 -Wall -Wextra -Wpedantic src/*.c
|
$(CC) -o lbr -O2 -Wall -Wextra -Wpedantic $(CFLAGS) src/*.c
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm lbr
|
||||||
|
|
||||||
test:
|
test:
|
||||||
./lbr tests/test.lb
|
./lbr tests/test.lb
|
||||||
|
@ -532,11 +532,7 @@ void execute(Stack *stack, Stack *originstack, char *modname)
|
|||||||
|
|
||||||
if (!strcmp(NAME, "size"))
|
if (!strcmp(NAME, "size"))
|
||||||
{
|
{
|
||||||
int i = 0;
|
stack_push(stack, stack->pointer);
|
||||||
while (i < stack->pointer)
|
|
||||||
i++;
|
|
||||||
|
|
||||||
stack_push(stack, i);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
tests/native_test.c
Normal file
14
tests/native_test.c
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Build with
|
||||||
|
// cc -shared -fPIC native_test.c -o native_test.so
|
||||||
|
// or
|
||||||
|
// cc -shared -fPIC native_test.c -o native_test.dll
|
||||||
|
|
||||||
|
int labashka(unsigned short (*pop)(void), void (*push)(unsigned short), size_t (*len)(void), size_t max_size ) {
|
||||||
|
printf("At %zu, there's %d.\n", len(), pop());
|
||||||
|
push(12);
|
||||||
|
printf("Maximum size is %zu.\n", max_size);
|
||||||
|
return 0;
|
||||||
|
}
|
3
tests/native_test.lb
Normal file
3
tests/native_test.lb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@ 0
|
||||||
|
push -1
|
||||||
|
#native native_test
|
Loading…
Reference in New Issue
Block a user