Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
join.c
Go to the documentation of this file.
1/*
2 * This file is part of the Fun programming language.
3 * https://fun-lang.xyz/
4 *
5 * Copyright 2025 Johannes Findeisen <you@hanez.org>
6 * Licensed under the terms of the Apache-2.0 license.
7 * https://opensource.org/license/apache-2-0
8 */
9
31
32case OP_JOIN: {
33 Value sep = pop_value(vm);
34 Value arr = pop_value(vm);
35 if (arr.type != VAL_ARRAY || sep.type != VAL_STRING) {
36 fprintf(stderr, "Runtime type error: JOIN expects (array, string)\n");
37 exit(1);
38 }
39 Value out = bi_join(&arr, &sep);
43 break;
44}
Value out
Definition apop.c:38
@ OP_JOIN
Definition bytecode.h:102
array_clear & arr
Definition clear.c:38
free_value(arr)
push_value(vm, out)
Value bi_join(const Value *arr, const Value *sep)
Join an array of strings with a separator into a single string Value.
Definition string.c:56
Tagged union representing a Fun value.
Definition value.h:68
ValueType type
Definition value.h:69
@ VAL_ARRAY
Definition value.h:55
@ VAL_STRING
Definition value.h:53
#define fprintf
Definition vm.c:200
#define exit(code)
Definition vm.c:230