mirror of
https://github.com/sigmasternchen/macrofuck
synced 2025-03-15 07:08:56 +00:00
fix: printing arrays works now
This commit is contained in:
parent
863d2f2e02
commit
8c3c1d1991
4 changed files with 13 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <error.h>
|
||||
#include <alloc.h>
|
||||
|
@ -167,8 +168,10 @@ struct expression* builtin_call_expression_new(void) {
|
|||
}
|
||||
|
||||
void builtin_call_expression_add_argument(struct expression* builtin_call, struct expression* argument) {
|
||||
builtin_call->builtin_call.arguments = safe_realloc(builtin_call->builtin_call.arguments, (++builtin_call->builtin_call.argument_number) * sizeof(struct expression*));
|
||||
builtin_call->builtin_call.arguments[builtin_call->builtin_call.argument_number - 1] = argument;
|
||||
builtin_call->builtin_call.arguments = safe_realloc(builtin_call->builtin_call.arguments, (builtin_call->builtin_call.argument_number + 1) * sizeof(struct expression*));
|
||||
memmove(builtin_call->builtin_call.arguments + 1, builtin_call->builtin_call.arguments, builtin_call->builtin_call.argument_number * sizeof(struct expression*));
|
||||
builtin_call->builtin_call.arguments[0] = argument;
|
||||
builtin_call->builtin_call.argument_number++;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -177,8 +177,8 @@ argumentlist: /* empty */
|
|||
}
|
||||
| expr COMMA argumentlist
|
||||
{
|
||||
$$ = $1;
|
||||
builtin_call_expression_add_argument($$, $3);
|
||||
$$ = $3;
|
||||
builtin_call_expression_add_argument($$, $1);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
5
compiler/test/cases/020a-print-char-array.in
Normal file
5
compiler/test/cases/020a-print-char-array.in
Normal file
|
@ -0,0 +1,5 @@
|
|||
print([]{
|
||||
'f',
|
||||
'o',
|
||||
'o',
|
||||
});
|
1
compiler/test/cases/020a-print-char-array.out
Normal file
1
compiler/test/cases/020a-print-char-array.out
Normal file
|
@ -0,0 +1 @@
|
|||
>>>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<<+>>>>+<]>[-<+>]<[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<+>>>+<]>[-<+>]<[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<+>>+<]>[-<+>]<<<<.>.>.
|
Loading…
Reference in a new issue