diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-03 03:42:41 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-03 03:42:41 -0500 |
| commit | 3a7588e5c5b7718012917b608e2346dc066cecc2 (patch) | |
| tree | aa88655cf4210d5256377ab44ec1915a0bcebcfc /src/builtins.c | |
| parent | Move builtins to a separate file (diff) | |
| download | cup-3a7588e5c5b7718012917b608e2346dc066cecc2.tar.xz cup-3a7588e5c5b7718012917b608e2346dc066cecc2.zip | |
Remove `putc` intrinsic and replace with `write(fd, buf, size)`
`putc`, `puts`, and `putnum` in `std/common.cup` are now implemented
in terms of the `write()` syscall.
Diffstat (limited to 'src/builtins.c')
| -rw-r--r-- | src/builtins.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/builtins.c b/src/builtins.c index 591caeb..3922d54 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -29,11 +29,13 @@ void initialize_builtins() push_builtin(node); node = Node_new(AST_BUILTIN); - node->func.name = "putc"; + node->func.name = "write"; node->func.return_type = type_new(TYPE_INT); - node->func.num_args = 1; - node->func.args = (Variable *)calloc(sizeof(Variable), 2); - node->func.args[0] = (Variable){"arg", type_new(TYPE_INT), 0}; + node->func.num_args = 3; + node->func.args = (Variable *)calloc(sizeof(Variable), 3); + node->func.args[0] = (Variable){"fd", type_new(TYPE_INT), 0}; + node->func.args[1] = (Variable){"buf", type_new_ptr(TYPE_CHAR), 0}; + node->func.args[2] = (Variable){"size", type_new(TYPE_INT), 0}; push_builtin(node); } |