From b52b42d4da0d45d8aabb094569c0c23406bbf31a Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Tue, 16 Nov 2021 17:19:12 +0100 Subject: [PATCH] Complete transition to fn. Introduce global/threadlocal --- resources/editor_plugins/iro/c3.iro | 6 +- resources/editor_plugins/nano/c3.nanorc | 2 +- resources/examples/base64.c3 | 8 +- resources/examples/factorial_macro.c3 | 4 +- resources/examples/fannkuch-redux.c3 | 4 +- resources/examples/fasta.c3 | 20 ++-- resources/examples/gameoflife.c3 | 18 ++-- resources/examples/hash.c3 | 16 ++-- resources/examples/mandelbrot.c3 | 8 +- resources/examples/nbodies.c3 | 16 ++-- .../examples/notworking/acornvm/avm_array.c3 | 32 +++---- .../examples/notworking/acornvm/avm_memory.c3 | 10 +- .../examples/notworking/acornvm/avm_stack.c3 | 38 ++++---- .../examples/notworking/acornvm/lexer.c3 | 16 ++-- resources/examples/notworking/acornvm/main.c3 | 4 +- .../examples/notworking/acornvm/parser.c3 | 26 ++--- .../examples/notworking/acornvm/parser_ast.c3 | 8 +- .../examples/notworking/acornvm/symbol.c3 | 10 +- .../examples/notworking/acornvm/value.c3 | 16 ++-- resources/examples/notworking/acornvm/vm.c3 | 4 +- resources/examples/notworking/binarydigits.c3 | 4 +- resources/examples/notworking/globals.c3 | 2 +- resources/examples/notworking/http.c3 | 2 +- resources/examples/notworking/levenshtein.c3 | 2 +- resources/examples/notworking/madlibs.c3 | 2 +- resources/examples/notworking/map.c3 | 10 +- resources/examples/notworking/retry.c3 | 2 +- .../examples/notworking/toml_parser_c2.c3 | 96 +++++++++---------- .../examples/notworking/toml_tokenizer_c2.c3 | 36 +++---- resources/examples/notworking/vector.c3 | 16 ++-- resources/examples/notworking/virtuals.c3 | 16 ++-- resources/examples/notworking/window.c3 | 2 +- resources/examples/spectralnorm.c3 | 16 ++-- resources/grammar/c3.l | 2 +- resources/lib/std/hash/adler32.c3 | 10 +- resources/lib/std/hash/crc32.c3 | 10 +- resources/lib/std/hash/crc64.c3 | 10 +- resources/lib/std/io.c3 | 14 +-- resources/lib/std/linkedlist.c3 | 20 ++-- resources/lib/std/list.c3 | 32 +++---- resources/lib/std/mem.c3 | 30 +++--- resources/rosettacode/antiprime.c3 | 6 +- resources/rosettacode/helloworld.c3 | 2 +- resources/testfragments/bigint.c3 | 26 ++--- resources/testfragments/casting.c3 | 6 +- resources/testfragments/comparisons.c3 | 12 +-- resources/testfragments/compilertest2.c3 | 28 +++--- resources/testfragments/compiletest.c3 | 12 +-- resources/testfragments/demo1.c3 | 20 ++-- resources/testfragments/file1.c3 | 2 +- resources/testfragments/file2.c3 | 2 +- resources/testfragments/helloworld.c3 | 4 +- resources/testfragments/lexertest.c3 | 2 +- resources/testfragments/parsertest.c3 | 18 ++-- resources/testfragments/sdl2.c3 | 28 +++--- resources/testfragments/test.c3 | 4 +- resources/testfragments/test_break.c3 | 4 +- resources/testfragments/testdefer.c3 | 26 ++--- resources/testfragments/tmem.c3 | 12 +-- resources/testfragments/toposort.c3 | 6 +- resources/testproject/bar.c3 | 2 +- resources/testproject/foo.c3 | 8 +- resources/testproject/hello_world.c3 | 4 +- src/compiler/compiler_internal.h | 1 + src/compiler/enums.h | 1 + src/compiler/llvm_codegen.c | 3 + src/compiler/parse_global.c | 23 +++-- src/compiler/parse_stmt.c | 1 + src/compiler/sema_expr.c | 1 + src/compiler/tokens.c | 2 + test/test_suite/abi/literal_load.c3t | 4 +- test/test_suite/abi/literal_load_aarch64.c3t | 4 +- test/test_suite/abi/literal_load_mingw.c3t | 4 +- test/test_suite/abi/pass_large_aarch.c3t | 4 +- test/test_suite/abi/test_sret.c3t | 6 +- test/test_suite/abi/union_x64.c3t | 4 +- test/test_suite/abi/vec2_aarch64.c3t | 12 +-- test/test_suite/abi/vec2_x64.c3t | 12 +-- test/test_suite/arrays/array_casts.c3t | 2 +- test/test_suite/arrays/array_invalid_casts.c3 | 4 +- test/test_suite/arrays/array_literal.c3t | 2 +- test/test_suite/arrays/array_struct.c3t | 2 +- .../test_suite/arrays/complex_array_const.c3t | 2 +- .../arrays/global_array_non_const.c3 | 2 +- test/test_suite/arrays/slice.c3 | 2 +- test/test_suite/assert/assert_variants.c3t | 4 +- .../local_static_assert_not_constant.c3 | 8 +- test/test_suite/assert/static_assert.c3 | 2 +- test/test_suite/assert/unreachable.c3t | 4 +- test/test_suite/assignment/int_assign.c3t | 2 +- .../attributes/repeat_of_attributes.c3 | 2 +- test/test_suite/cast/cast_ok.c3 | 4 +- test/test_suite/cast/cast_parse_fails.c3 | 4 +- test/test_suite/cast/cast_parse_fails2.c3 | 2 +- test/test_suite/cast/cast_struct.c3 | 2 +- test/test_suite/cast/cast_struct_fails.c3 | 4 +- test/test_suite/cast/cast_to_failable.c3 | 2 +- test/test_suite/comments/simple_comments.c3 | 2 +- .../compile_time/compile_time_ptr_ref.c3t | 12 +-- test/test_suite/compile_time/ct_if.c3t | 10 +- .../compile_time/cttype_reassign.c3t | 2 +- .../compile_time/not_yet_initialized.c3 | 4 +- .../compile_time/ternary_folding.c3t | 10 +- .../compile_time/typeof_example.c3t | 4 +- .../compile_time/typeof_from_literal.c3 | 4 +- .../compile_time_introspection/alignof.c3t | 48 +++++----- .../compile_time_introspection/defined.c3t | 4 +- .../compile_time_introspection/defined_err.c3 | 6 +- .../compile_time_introspection/nameof.c3t | 4 +- .../compile_time_introspection/nameof_err.c3 | 6 +- .../compile_time_introspection/offsetof.c3t | 32 +++---- .../compile_time_introspection/qnameof.c3t | 4 +- .../compile_time_introspection/sizeof.c3t | 32 +++---- .../sizeof_errors.c3 | 24 ++--- test/test_suite/constants/byte_literals.c3t | 10 +- test/test_suite/constants/char_literals.c3t | 18 ++-- test/test_suite/constants/constants.c3t | 12 +-- test/test_suite/define/common.c3 | 4 +- test/test_suite/distinct/distinct_struct.c3 | 2 +- .../distinct/distinct_struct_array.c3 | 2 +- test/test_suite/distinct/distinct_union.c3 | 2 +- test/test_suite/distinct/test_errors.c3 | 2 +- test/test_suite/distinct/test_ops_on_int.c3 | 2 +- .../test_suite/distinct/test_ops_on_struct.c3 | 2 +- test/test_suite/enumerations/compile_time.c3t | 10 +- .../enumerations/simple_inference.c3t | 2 +- test/test_suite/errors/anyerr_void.c3t | 2 +- test/test_suite/errors/bitshift_failable.c3 | 2 +- test/test_suite/errors/else_checks.c3t | 4 +- test/test_suite/errors/error_throw.c3 | 2 +- test/test_suite/errors/error_union.c3 | 2 +- .../errors/failable_taddr_and_access.c3t | 4 +- .../errors/failable_untyped_list.c3 | 6 +- .../errors/general_error_regression.c3t | 8 +- .../errors/illegal_use_of_failable.c3 | 2 +- test/test_suite/errors/precedence_err.c3 | 2 +- test/test_suite/errors/rethrow.c3t | 2 +- test/test_suite/errors/rethrow_mingw.c3t | 2 +- test/test_suite/errors/rethrow_no_err.c3 | 4 +- .../errors/simple_static_failable.c3t | 2 +- test/test_suite/errors/try_assign.c3t | 6 +- test/test_suite/errors/try_catch_if.c3t | 10 +- .../errors/try_catch_unwrapping_while_if.c3 | 20 ++-- .../errors/try_unwrap_using_assert.c3t | 4 +- .../errors/try_with_assign_to_failable.c3 | 2 +- .../errors/try_with_chained_unwrap.c3t | 8 +- .../errors/try_with_chained_unwrap_errors.c3 | 20 ++-- test/test_suite/errors/try_with_unwrap.c3t | 8 +- test/test_suite/errors/try_with_unwrapper.c3t | 12 +-- .../test_suite/errors/try_with_weird_stuff.c3 | 4 +- test/test_suite/examples/gameoflife.c3 | 18 ++-- .../expression_block_break.c3 | 4 +- test/test_suite/expressions/addr_compiles.c3t | 10 +- test/test_suite/expressions/addr_of_fails.c3 | 16 ++-- test/test_suite/expressions/arithmetics.c3 | 12 +-- .../expressions/arithmetics_sema_fail.c3 | 32 +++---- test/test_suite/expressions/assign.c3 | 2 +- test/test_suite/expressions/assignability.c3 | 14 +-- .../expressions/assignment_precedence.c3t | 2 +- test/test_suite/expressions/call_arg_types.c3 | 4 +- test/test_suite/expressions/call_inline.c3t | 8 +- .../expressions/casts/cast_const.c3 | 2 +- .../expressions/casts/cast_enum_to_various.c3 | 8 +- .../expressions/casts/cast_expr.c3t | 2 +- .../expressions/casts/cast_failable.c3 | 2 +- .../expressions/casts/cast_func_to_various.c3 | 16 ++-- .../expressions/casts/cast_to_nonscalar.c3 | 2 +- .../expressions/casts/cast_unknown.c3 | 6 +- .../expressions/casts/explicit_cast.c3 | 4 +- .../expressions/chained_conditional.c3t | 4 +- ...eck_implict_conversion_signed_unsigned.c3t | 2 +- test/test_suite/expressions/elvis.c3t | 6 +- .../expressions/fail_index_usize.c3 | 2 +- test/test_suite/expressions/incdec.c3t | 2 +- test/test_suite/expressions/negate_int.c3 | 12 +-- .../expressions/no_valid_conversion_minus.c3 | 2 +- .../test_suite/expressions/parsed_numbers.c3t | 8 +- .../test_suite/expressions/pointer_access.c3t | 4 +- test/test_suite/expressions/pointer_arith.c3 | 4 +- .../expressions/pointer_conv_error.c3 | 6 +- .../test_suite/expressions/pointer_to_bool.c3 | 2 +- test/test_suite/expressions/rvalues.c3 | 2 +- .../expressions/simple_float_sub_neg.c3t | 2 +- test/test_suite/expressions/strings.c3t | 2 +- test/test_suite/expressions/ternary_bool.c3t | 4 +- .../expressions/ternary_no_ident.c3 | 6 +- test/test_suite/failable_catch.c3t | 4 +- .../explicit_float_truncation_needed.c3 | 2 +- .../test_suite/floats/float_exceeding_size.c3 | 2 +- test/test_suite/floats/inf_nan.c3t | 2 +- test/test_suite/from_docs/examples_defer.c3t | 4 +- .../from_docs/examples_forswitch.c3t | 4 +- .../from_docs/examples_functionpointer.c3t | 6 +- .../from_docs/examples_if_catch.c3t | 10 +- .../from_docs/examples_macro_function.c3t | 4 +- test/test_suite/from_docs/examples_struct.c3 | 2 +- test/test_suite/functions/assorted_tests.c3t | 12 +-- .../functions/body_argument_fail.c3 | 10 +- test/test_suite/functions/double_return.c3t | 2 +- test/test_suite/functions/macro_arguments.c3 | 10 +- .../functions/missing_first_paren.c3 | 2 +- test/test_suite/functions/missing_return.c3 | 2 +- test/test_suite/functions/naked_function.c3t | 2 +- .../functions/naked_function_fail.c3 | 2 +- test/test_suite/functions/returning_void.c3t | 2 +- test/test_suite/functions/splat.c3t | 4 +- test/test_suite/functions/splat_aarch64.c3t | 4 +- test/test_suite/functions/splat_mingw.c3t | 4 +- test/test_suite/functions/static_vars.c3t | 6 +- test/test_suite/functions/test_regression.c3t | 40 ++++---- .../functions/test_regression_mingw.c3t | 40 ++++---- .../functions/vararg_argument_fails.c3 | 6 +- test/test_suite/functions/varargs.c3t | 4 +- test/test_suite/generic/generic_copy.c3t | 2 +- test/test_suite/generic/generic_idents.c3t | 8 +- test/test_suite/globals/external_global.c3t | 4 +- test/test_suite/globals/global_extname.c3t | 2 +- test/test_suite/import/import_error.c3 | 2 +- .../import/import_error_out_of_order.c3 | 2 +- .../initializer_lists/disallowed_lists.c3 | 2 +- test/test_suite/initializer_lists/fasta.c3t | 26 ++--- .../initializer_lists/general_tests.c3t | 4 +- .../indexing_into_complist.c3 | 10 +- test/test_suite/initializer_lists/statics.c3t | 6 +- .../initializer_lists/subarrays.c3t | 8 +- .../initializer_lists/zero_init.c3t | 2 +- test/test_suite/literals/literal_general.c3t | 16 ++-- test/test_suite/macro_methods/access.c3 | 6 +- .../macro_methods/macro_method_fails.c3 | 14 +-- .../macro_methods_defined_twice.c3 | 2 +- test/test_suite/macros/hash_ident.c3 | 4 +- test/test_suite/macros/macro_body_as_value.c3 | 2 +- test/test_suite/macros/macro_common.c3t | 2 +- .../macros/macro_convert_literal.c3 | 2 +- .../macros/macro_import_resolution.c3 | 4 +- test/test_suite/macros/macro_resolution.c3 | 6 +- test/test_suite/macros/macro_rtype.c3 | 2 +- test/test_suite/macros/macro_with_body.c3t | 6 +- test/test_suite/macros/no_body.c3 | 12 +-- test/test_suite/macros/type_params.c3t | 2 +- test/test_suite/macros/userland_bitcast.c3t | 8 +- test/test_suite/methods/access.c3 | 10 +- .../methods/enum_distinct_err_methods.c3t | 8 +- test/test_suite/methods/extension_method.c3t | 4 +- .../methods/extension_method_already_exist.c3 | 6 +- .../methods/methods_defined_twice.c3 | 6 +- test/test_suite/pointers/const_pointer.c3t | 8 +- test/test_suite/pointers/pointer_index.c3t | 6 +- test/test_suite/precedence/required_parens.c3 | 2 +- test/test_suite/statements/binary_fail.c3 | 2 +- .../statements/call_missing_paren.c3 | 4 +- .../statements/comparison_widening.c3t | 2 +- .../statements/conditional_return.c3 | 2 +- test/test_suite/statements/default_args.c3 | 2 +- test/test_suite/statements/defer_break.c3t | 26 ++--- .../statements/defer_break_simple.c3t | 10 +- .../statements/defer_break_switch.c3t | 6 +- test/test_suite/statements/defer_in_defer.c3t | 12 +-- .../statements/defer_next_switch.c3t | 6 +- test/test_suite/statements/defer_return.c3t | 20 ++-- test/test_suite/statements/defer_test.c3 | 2 +- test/test_suite/statements/for.c3 | 6 +- test/test_suite/statements/for_empty.c3 | 2 +- test/test_suite/statements/for_errors.c3 | 4 +- .../statements/for_with_extra_declarations.c3 | 2 +- test/test_suite/statements/foreach_break.c3t | 2 +- test/test_suite/statements/foreach_common.c3t | 4 +- test/test_suite/statements/foreach_custom.c3t | 8 +- .../statements/foreach_custom_errors.c3 | 24 ++--- .../statements/foreach_custom_macro.c3t | 4 +- test/test_suite/statements/foreach_errors.c3 | 18 ++-- .../statements/foreach_parse_error.c3 | 2 +- .../statements/foreach_with_error.c3 | 2 +- test/test_suite/statements/if_decl.c3 | 2 +- test/test_suite/statements/if_single.c3 | 2 +- test/test_suite/statements/if_tests.c3t | 6 +- .../statements/if_while_do_error.c3 | 6 +- test/test_suite/statements/label_errors.c3 | 4 +- .../statements/labelled_continue_for.c3t | 6 +- test/test_suite/statements/return_stmt.c3 | 4 +- test/test_suite/statements/return_switch.c3t | 2 +- .../statements/return_with_other_at_end.c3 | 2 +- test/test_suite/statements/switch_errors.c3 | 26 ++--- .../statements/various_switching.c3t | 6 +- .../statements/while_statement_placement.c3 | 2 +- test/test_suite/statements/while_switch.c3t | 6 +- .../strings/literal_to_subarray.c3t | 4 +- test/test_suite/strings/string_escape.c3t | 2 +- test/test_suite/struct/func_return_struct.c3 | 4 +- test/test_suite/struct/member_access.c3 | 6 +- test/test_suite/struct/member_expr.c3 | 12 +-- test/test_suite/struct/simple_struct.c3t | 2 +- test/test_suite/struct/struct_as_value.c3t | 2 +- .../struct/struct_as_value_aarch64.c3t | 2 +- test/test_suite/struct/struct_codegen.c3t | 2 +- .../struct/struct_codegen_empty.c3t | 2 +- .../struct/struct_const_construct_simple.c3t | 16 ++-- .../struct/struct_pack_and_align.c3t | 14 +-- test/test_suite/struct/struct_params.c3 | 8 +- .../test_suite/subarrays/slice_comparison.c3t | 4 +- .../subarrays/slice_negative_len.c3 | 22 ++--- test/test_suite/subarrays/slice_offset.c3t | 2 +- .../subarrays/slice_offset_neg_end.c3t | 2 +- .../subarrays/slice_offset_neg_start.c3t | 2 +- test/test_suite/subarrays/slice_start.c3t | 2 +- test/test_suite/subarrays/slice_syntax.c3 | 2 +- test/test_suite/subarrays/sub_array_init.c3 | 2 +- test/test_suite/symbols/various.c3 | 52 +++++----- test/test_suite/types/enum_errors.c3 | 2 +- test/test_suite/types/enum_inference.c3 | 2 +- test/test_suite/types/enum_param.c3 | 4 +- test/test_suite/types/typedefs.c3 | 2 +- test/test_suite/types/various.c3 | 2 +- test/test_suite/union/empty_unions.c3 | 2 +- test/test_suite/union/union_codegen_const.c3t | 8 +- test/test_suite/union/union_codegen_empty.c3t | 2 +- .../union/union_codegen_overwrite_call.c3t | 4 +- test/test_suite/union/union_in_struct.c3t | 14 +-- .../test_suite/union/union_member_voidcast.c3 | 2 +- test/test_suite/variables/consts.c3 | 2 +- test/test_suite/vector/vector_bit.c3t | 6 +- test/test_suite/vector/vector_incdec.c3t | 6 +- test/test_suite/vector/vector_init.c3t | 4 +- test/test_suite/vector/vector_ops.c3t | 8 +- test/test_suite/visibility/ambiguous_var.c3t | 2 +- .../visibility/no_shared_imports.c3t | 6 +- test/test_suite/visibility/not_visible.c3t | 4 +- test/test_suite/visibility/private_import.c3 | 6 +- test/test_suite/visibility/private_module.c3 | 4 +- test/test_suite/visibility/shared_module.c3t | 4 +- .../visibility/simple_visibility.c3t | 4 +- 331 files changed, 1279 insertions(+), 1261 deletions(-) diff --git a/resources/editor_plugins/iro/c3.iro b/resources/editor_plugins/iro/c3.iro index dd1a02590..55af611df 100644 --- a/resources/editor_plugins/iro/c3.iro +++ b/resources/editor_plugins/iro/c3.iro @@ -246,11 +246,11 @@ contexts [] { decls : context { : pattern { - regex \= (func\s+)($${__SCOPE})?($${__USERTYPE})?($${__BUILTIN_TYPE})?(\s+$${__IDENT}) + regex \= (fn\s+)($${__SCOPE})?($${__USERTYPE})?($${__BUILTIN_TYPE})?(\s+$${__IDENT}) styles [] = .declare, .text, .text, .type, .type_builtin, .function_decl; } : pattern { - regex \= (func\s+)($${__SCOPE})?($${__USERTYPE})?($${__BUILTIN_TYPE})?(\s+$${__IDENT}) + regex \= (fn\s+)($${__SCOPE})?($${__USERTYPE})?($${__BUILTIN_TYPE})?(\s+$${__IDENT}) styles [] = .declare, .text, .text, .type, .type_builtin, .function_decl; } : pattern { @@ -289,7 +289,7 @@ main : context { : include "top_level"; : pattern { - regex \= (define|extern|if|module|import|func|struct|while|do|return|union|errtype) + regex \= (define|extern|if|module|import|fn|struct|while|do|return|union|errtype) styles [] = .keyword; } diff --git a/resources/editor_plugins/nano/c3.nanorc b/resources/editor_plugins/nano/c3.nanorc index 7d1fe6689..a24ad8bca 100644 --- a/resources/editor_plugins/nano/c3.nanorc +++ b/resources/editor_plugins/nano/c3.nanorc @@ -18,7 +18,7 @@ color normal "\(|\)" color green "\<(virtual|anyerr|void|bool|quad|double|float|long|ulong|int|uint|short|ushort|ichar|char|isize|usize|iptr|uptr|iptrdiff|uptrdiff|half)\>" # Keywords -color yellow "\<(alias|as|asm|assert|attribute|break|case|catch|const|continue|default|defer|define|do|else|enum|extern|errtype|false|for|foreach|func|generic|if|import|interface|macro|module|nextcase|null|private|return|static|struct|switch|true|try|typeid|typeof|union|while|var|volatile|yield)\>" +color yellow "\<(alias|as|asm|assert|attribute|break|case|catch|const|continue|default|defer|define|do|else|enum|extern|errtype|false|for|foreach|fn|generic|if|import|interface|macro|module|nextcase|null|private|return|static|struct|switch|true|try|typeid|typeof|union|while|var|volatile|yield)\>" # $ Statements color brightyellow "\$\<(assert|case|default|elif|else|endif|endswitch|for|if|switch|unreachable)\>" diff --git a/resources/examples/base64.c3 b/resources/examples/base64.c3 index 0788165ce..6069332cb 100644 --- a/resources/examples/base64.c3 +++ b/resources/examples/base64.c3 @@ -42,7 +42,7 @@ const char PAD = '='; const char FIRST = '+'; const char LAST = 'z'; -func void encode(char[] in, char *out) +fn void encode(char[] in, char *out) { int j = 0; char c = LUT_ENC[1]; @@ -76,7 +76,7 @@ func void encode(char[] in, char *out) } -func int! decode(char[] in, char* out, int* invalid_char_index = null) +fn int! decode(char[] in, char* out, int* invalid_char_index = null) { int j = 0; @@ -118,9 +118,9 @@ func int! decode(char[] in, char* out, int* invalid_char_index = null) return j; } -extern func void printf(char *fmt, ...); +extern fn void printf(char *fmt, ...); -func void main() +fn void main() { char *helloworld = "Hello World\n"; char[1000] buffer; diff --git a/resources/examples/factorial_macro.c3 b/resources/examples/factorial_macro.c3 index 60d8d9209..89bde85d6 100644 --- a/resources/examples/factorial_macro.c3 +++ b/resources/examples/factorial_macro.c3 @@ -7,9 +7,9 @@ macro int factorial($n) $endif; } -extern func void printf(char *fmt, ...); +extern fn void printf(char *fmt, ...); -func void main() +fn void main() { int x = @factorial(12); printf("12! = %d\n", x); diff --git a/resources/examples/fannkuch-redux.c3 b/resources/examples/fannkuch-redux.c3 index e121d7e0c..341edec20 100644 --- a/resources/examples/fannkuch-redux.c3 +++ b/resources/examples/fannkuch-redux.c3 @@ -8,7 +8,7 @@ macro int max(int a, int b) return a > b ? a : b; } -func int fannkuchredux(int n) +fn int fannkuchredux(int n) { int* perm = @array::make(int, n); int* perm1 = @array::make(int, n); @@ -72,7 +72,7 @@ func int fannkuchredux(int n) return 0; } -func int main(int argc, char** argv) +fn int main(int argc, char** argv) { int n = argc > 1 ? libc::atoi(argv[1]) : 7; libc::printf("Pfannkuchen(%d) = %d\n", n, fannkuchredux(n)); diff --git a/resources/examples/fasta.c3 b/resources/examples/fasta.c3 index 015133bdb..3f425e06a 100644 --- a/resources/examples/fasta.c3 +++ b/resources/examples/fasta.c3 @@ -6,15 +6,15 @@ const IA = 3877; const IC = 29573; const SEED = 42; -uint seed = SEED; +global uint seed = SEED; -func float fasta_rand(float max) +fn float fasta_rand(float max) { seed = (seed * IA + IC) % IM; return max * seed / IM; } -private char[] alu = +private global char[] alu = "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" @@ -24,8 +24,8 @@ private char[] alu = "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; -char[] iub = "acgtBDHKMNRSVWY"; -double[] iub_p = { +global char[] iub = "acgtBDHKMNRSVWY"; +global double[] iub_p = { 0.27, 0.12, 0.12, @@ -42,8 +42,8 @@ double[] iub_p = { 0.02, 0.02 }; -char[] homosapiens = "acgt"; -double[] homosapiens_p = { +global char[] homosapiens = "acgt"; +global double[] homosapiens_p = { 0.3029549426680, 0.1979883004921, 0.1975473066391, @@ -53,7 +53,7 @@ double[] homosapiens_p = { const LINELEN = 60; // slowest character-at-a-time output -func void repeat_fasta(char[] seq, int n) +fn void repeat_fasta(char[] seq, int n) { usize len = seq.len; int i = void; @@ -65,7 +65,7 @@ func void repeat_fasta(char[] seq, int n) if (i % LINELEN != 0) libc::putchar('\n'); } -func void random_fasta(char[] symb, double[] probability, int n) +fn void random_fasta(char[] symb, double[] probability, int n) { assert(symb.len == probability.len); int len = probability.len; @@ -86,7 +86,7 @@ func void random_fasta(char[] symb, double[] probability, int n) if (i % LINELEN != 0) libc::putchar('\n'); } -func void main(int argc, char **argv) +fn void main(int argc, char **argv) { int n = 1000; if (argc > 1) n = libc::atoi(argv[1]); diff --git a/resources/examples/gameoflife.c3 b/resources/examples/gameoflife.c3 index a83b87a5f..a8aeb9ecb 100644 --- a/resources/examples/gameoflife.c3 +++ b/resources/examples/gameoflife.c3 @@ -1,12 +1,12 @@ module game_of_life; -extern func void printf(char *fmt, ...); -extern func int atoi(char *val); +extern fn void printf(char *fmt, ...); +extern fn int atoi(char *val); extern void *__stdoutp; -extern func void fflush(void *std); -extern func int rand(); -extern func void* malloc(usize size); -extern func void usleep(int time); +extern fn void fflush(void *std); +extern fn int rand(); +extern fn void* malloc(usize size); +extern fn void usleep(int time); struct GameBoard @@ -17,7 +17,7 @@ struct GameBoard char* temp; } -func void GameBoard.show(GameBoard *board) +fn void GameBoard.show(GameBoard *board) { printf("\e[H"); @@ -34,7 +34,7 @@ func void GameBoard.show(GameBoard *board) fflush(__stdoutp); } -func void GameBoard.evolve(GameBoard *board) +fn void GameBoard.evolve(GameBoard *board) { for (int y = 0; y < board.h; y++) { @@ -61,7 +61,7 @@ func void GameBoard.evolve(GameBoard *board) } -func int main(int c, char** v) +fn int main(int c, char** v) { int w = 0; int h = 0; diff --git a/resources/examples/hash.c3 b/resources/examples/hash.c3 index d05b399cb..98e607573 100644 --- a/resources/examples/hash.c3 +++ b/resources/examples/hash.c3 @@ -5,7 +5,7 @@ import libc; // The code below should not be considered *correct* // They are merely done to illustrate the language syntax. -func void main() +fn void main() { char[] y = "Hello World!"; libc::printf("Adler32 of %s is %x, expected 1c49043e\n", (char*)(y), adler32(y)); @@ -17,7 +17,7 @@ func void main() libc::printf("FNV64a of %s is %llx, expected 8c0ec8d1fb9e6e32\n", (char*)(y), fnv64a(y)); } -func uint adler32(char[] data) +fn uint adler32(char[] data) { const uint ADLER_CONST = 65521; uint a = 1; @@ -30,7 +30,7 @@ func uint adler32(char[] data) return (b << 16) | a; } -func uint crc32(char[] data) +fn uint crc32(char[] data) { uint result = ~(uint)(0); foreach (char x : data) @@ -40,7 +40,7 @@ func uint crc32(char[] data) return ~result; } -func ulong crc64(char[] data) +fn ulong crc64(char[] data) { ulong result = (ulong)(0); foreach (char x : data) @@ -51,7 +51,7 @@ func ulong crc64(char[] data) } -func uint fnv32(char[] data) +fn uint fnv32(char[] data) { uint h = 0x811c9dc5; foreach (char x : data) @@ -61,7 +61,7 @@ func uint fnv32(char[] data) return h; } -func ulong fnv64(char[] data) +fn ulong fnv64(char[] data) { ulong h = 0xcbf29ce484222325; foreach (char x : data) @@ -71,7 +71,7 @@ func ulong fnv64(char[] data) return h; } -func uint fnv32a(char[] data) +fn uint fnv32a(char[] data) { uint h = 0x811c9dc5; foreach (char x : data) @@ -81,7 +81,7 @@ func uint fnv32a(char[] data) return h; } -func ulong fnv64a(char[] data) +fn ulong fnv64a(char[] data) { ulong h = 0xcbf29ce484222325; foreach (char x : data) diff --git a/resources/examples/mandelbrot.c3 b/resources/examples/mandelbrot.c3 index 2c7416a5d..78b5dc929 100644 --- a/resources/examples/mandelbrot.c3 +++ b/resources/examples/mandelbrot.c3 @@ -1,10 +1,10 @@ module mandelbrot; -extern func int atoi(char *s); -extern func int printf(char *s, ...); -extern func void putchar(int c); +extern fn int atoi(char *s); +extern fn int printf(char *s, ...); +extern fn void putchar(int c); -func void main(int argc, char **argv) +fn void main(int argc, char **argv) { int w = atoi(argv[1]); int h = w; diff --git a/resources/examples/nbodies.c3 b/resources/examples/nbodies.c3 index 72c892963..4b4d1baf6 100644 --- a/resources/examples/nbodies.c3 +++ b/resources/examples/nbodies.c3 @@ -13,7 +13,7 @@ struct Planet double mass; } -func void advance(Planet[] bodies) @noinline +fn void advance(Planet[] bodies) @noinline { usize nbodies = bodies.len; foreach (i, Planet* &b : bodies) @@ -42,7 +42,7 @@ func void advance(Planet[] bodies) @noinline } } -func double energy(Planet[] bodies) +fn double energy(Planet[] bodies) { double e; usize nbodies = bodies.len; @@ -63,7 +63,7 @@ func double energy(Planet[] bodies) return e; } -func void offset_momentum(Planet[] bodies) +fn void offset_momentum(Planet[] bodies) { double px; double py; @@ -128,7 +128,7 @@ Planet[*] planet_bodies = { * * When all advances done, rescale bodies back to obtain correct energy. */ -func void scale_bodies(Planet[] bodies, double scale) +fn void scale_bodies(Planet[] bodies, double scale) { foreach (&b : bodies) { @@ -139,11 +139,11 @@ func void scale_bodies(Planet[] bodies, double scale) } } -extern func int atoi(char *s); -extern func int printf(char *s, ...); -extern func double sqrt(double); +extern fn int atoi(char *s); +extern fn int printf(char *s, ...); +extern fn double sqrt(double); -func int main(int argc, char ** argv) +fn int main(int argc, char ** argv) { int n = atoi(argv[1]); diff --git a/resources/examples/notworking/acornvm/avm_array.c3 b/resources/examples/notworking/acornvm/avm_array.c3 index 859531864..a68ed419c 100644 --- a/resources/examples/notworking/acornvm/avm_array.c3 +++ b/resources/examples/notworking/acornvm/avm_array.c3 @@ -10,7 +10,7 @@ module acorn::arr; /* Return a new Array, allocating len slots for Values. */ -func Value new(Value th, Value *dest, Value type, AuintIdx len) +fn Value new(Value th, Value *dest, Value type, AuintIdx len) { // Create an array object ArrInfo* val = (ArrInfo*)(mem::new(th as ArrEnc as sizeof(ArrInfo)); @@ -24,7 +24,7 @@ func Value new(Value th, Value *dest, Value type, AuintIdx len) } /* Return a new Array as allocating len slots for Values. */ -func Value newClosure(Value *th, Value *dest, Value type, AuintIdx len) +fn Value newClosure(Value *th, Value *dest, Value type, AuintIdx len) { // Create an array object ArrInfo* val = (sizeof(ArrInfo), ArrInfo*)(mem::new(th as ArrEnc); @@ -38,25 +38,25 @@ func Value newClosure(Value *th, Value *dest, Value type, AuintIdx len) } /* Return 1 if the value is an Array as otherwise 0 */ -func int Value.isArr(Value* val) +fn int Value.isArr(Value* val) { return val.isEnc(ArrEnc); } /* Return 1 if the value is an Array, otherwise 0 */ -func int Value.isClosure(Value* val) +fn int Value.isClosure(Value* val) { return val.isEnc(ArrEnc) && arr_info(val)->flags1 & TypeClo; } -private func ArrInfo.fill(ArrInfo* a, AuintIdx start, AuintIdx end, Value value) @inline +private fn ArrInfo.fill(ArrInfo* a, AuintIdx start, AuintIdx end, Value value) @inline { for (AuintIdx i = start; i < end; i++) a.arr[i] = value; } /* Ensure array has room for len Values, allocating memory as needed. * Allocated space will not shrink. Changes nothing about array's contents. */ -func void makeRoom(Value th, Value arr, AuintIdx len) +fn void makeRoom(Value th, Value arr, AuintIdx len) { ArrInfo* a = arr_info(arr); if (len > a.avail) @@ -71,7 +71,7 @@ func void makeRoom(Value th, Value arr, AuintIdx len) * Set the number of elements in the array, growing it if needed. * If less than current number array size, array is not shrunk. */ -func void setSize(Value th, Value arr, AuintIdx len) +fn void setSize(Value th, Value arr, AuintIdx len) { ArrInfo* a = arr_info(arr); AuintIdx size = arr_size(arr); @@ -84,7 +84,7 @@ func void setSize(Value th, Value arr, AuintIdx len) * or expanding as needed. Growth space is initialized to aNull. * @require val.isArr() */ -func void forceSize(Value th, Value val, AuintIdx len) +fn void forceSize(Value th, Value val, AuintIdx len) { ArrInfo *arr = arr_info(val); @@ -105,7 +105,7 @@ func void forceSize(Value th, Value val, AuintIdx len) * Retrieve the value in array at specified position. * @require arr.isArr() */ -func Value get(Value th, Value arr, AuintIdx pos) +fn Value get(Value th, Value arr, AuintIdx pos) { ArrInfo* a = arr_info(arr); return pos >= a.size ? aNull : a.arr[pos]; @@ -116,7 +116,7 @@ func Value get(Value th, Value arr, AuintIdx pos) * This can expand the size of the array. * @require arr.isArr() */ -func void set(Value th, Value arr, AuintIdx pos, Value val) +fn void set(Value th, Value arr, AuintIdx pos, Value val) { ArrInfo* a = arr_info(arr); @@ -135,7 +135,7 @@ func void set(Value th, Value arr, AuintIdx pos, Value val) * Append val to the end of the array (increasing array's size). * @require arr.isArr() */ -func void add(Value th, Value arr, Value val) +fn void add(Value th, Value arr, Value val) { ArrInfo *a = arr_info(arr); AuintIdx sz = arr_size(arr); @@ -154,7 +154,7 @@ func void add(Value th, Value arr, Value val) * This can expand the size of the array. * @require arr.isArr() */ -func void repeat(Value th, Value arr, AuintIdx pos, AuintIdx n, Value val) +fn void repeat(Value th, Value arr, AuintIdx pos, AuintIdx n, Value val) { ArrInfo* a = arr_info(arr); @@ -177,7 +177,7 @@ func void repeat(Value th, Value arr, AuintIdx pos, AuintIdx n, Value val) * All values after these are preserved, essentially shrinking the array. * @require arr.isArr() */ -func void del(Value th, Value arr, AuintIdx pos, AuintIdx n) +fn void del(Value th, Value arr, AuintIdx pos, AuintIdx n) { ArrInfo *a = arr_info(arr); @@ -200,7 +200,7 @@ func void del(Value th, Value arr, AuintIdx pos, AuintIdx n) * Insert n copies of val into the array starting at pos, expanding the array's size. * @require arr.isArr() */ -func void ins(Value th, Value arr, AuintIdx pos, AuintIdx n, Value val) +fn void ins(Value th, Value arr, AuintIdx pos, AuintIdx n, Value val) { ArrInfo *a = arr_info(arr); @@ -223,7 +223,7 @@ func void ins(Value th, Value arr, AuintIdx pos, AuintIdx n, Value val) * This can increase or decrease the size of the array. arr and arr2 may be the same array. * @require arr.isArr() */ -func void sub(Value th, Value arr, AuintIdx pos, AuintIdx n, Value arr2, AuintIdx pos2, AuintIdx n2) +fn void sub(Value th, Value arr, AuintIdx pos, AuintIdx n, Value arr2, AuintIdx pos2, AuintIdx n2) { ArrInfo *a = arr_info(arr); @@ -250,7 +250,7 @@ func void sub(Value th, Value arr, AuintIdx pos, AuintIdx n, Value arr2, AuintId } /* Serialize an array's contents to indented text */ -func void serialize(Value th, Value str, int indent, Value arr) +fn void serialize(Value th, Value str, int indent, Value arr) { // TODO ArrInfo *a = arr_info(arr); diff --git a/resources/examples/notworking/acornvm/avm_memory.c3 b/resources/examples/notworking/acornvm/avm_memory.c3 index 15242f731..0bbb0bb5f 100644 --- a/resources/examples/notworking/acornvm/avm_memory.c3 +++ b/resources/examples/notworking/acornvm/avm_memory.c3 @@ -12,7 +12,7 @@ module acorn::mem; * - If ptr==NULL, it allocates a new uninitialized memory block * - Otherwise it changes the size of the memory block (and may move its location) * It returns the location of the new block or NULL (if freed). */ -func void* gcrealloc(Value th, void *block, Auint osize, Auint nsize) +fn void* gcrealloc(Value th, void *block, Auint osize, Auint nsize) { // Check consistency of block and osize (both must be null or specified) Auint realosize = block ? osize : 0; @@ -51,7 +51,7 @@ func void* gcrealloc(Value th, void *block, Auint osize, Auint nsize) return newblock; } -func void* gcreallocv(Value th, void* block, Auint osize, Auint nsize, Auint esize) +fn void* gcreallocv(Value th, void* block, Auint osize, Auint nsize, Auint esize) { // Ensure we are not asking for more memory than available in address space // If we do not do this, calculating the needed memory will overflow @@ -68,7 +68,7 @@ func void* gcreallocv(Value th, void* block, Auint osize, Auint nsize, Auint esi * - Otherwise it changes the size of the memory block (and may move its location) * It returns the location of the new block or NULL (if freed). **/ -func void* frealloc(void* block, Auint size) +fn void* frealloc(void* block, Auint size) { if (!size) { @@ -113,7 +113,7 @@ MemInfo* new(Value th as int enc, Auint sz) * Create a new pointer object (with given encoding and size). * Caller must add itself to its own private list */ -func MemInfo* newnolink(Value th, int enc, Auint sz) +fn MemInfo* newnolink(Value th, int enc, Auint sz) { // Perform garbage collection before a memory allocation $if (defined(AVM_GCHARDMEMTEST)) @@ -134,7 +134,7 @@ func MemInfo* newnolink(Value th, int enc, Auint sz) } /* double size of vector array, up to limits */ -func void growaux_(Value th, void *block, AuintIdx *size, AuintIdx size_elems, AuintIdx limit) +fn void growaux_(Value th, void *block, AuintIdx *size, AuintIdx size_elems, AuintIdx limit) { void* newblock; AuintIdx newsize = void; diff --git a/resources/examples/notworking/acornvm/avm_stack.c3 b/resources/examples/notworking/acornvm/avm_stack.c3 index 7124d5be7..9f3e3a530 100644 --- a/resources/examples/notworking/acornvm/avm_stack.c3 +++ b/resources/examples/notworking/acornvm/avm_stack.c3 @@ -25,7 +25,7 @@ import acorn::sym; ***************************************/ /** Size of the method's stack area: base to top */ -func AintIdx stkSz(Value th) @inline +fn AintIdx stkSz(Value th) @inline { return th(th).stk_top - th(th).curmethod.begin; } @@ -35,7 +35,7 @@ func AintIdx stkSz(Value th) @inline /** Point to current method's stack value at position i. * For a method: i=0 is self, i=1 is first parameter, etc. */ -func void Value.at(Value* th, AintIdx i) @inline +fn void Value.at(Value* th, AintIdx i) @inline { @assert_exp(i >= 0 && i < stkSz(th), "invalid stack index"); return &th(*th).curmethod.begin[i]; @@ -47,20 +47,20 @@ func void Value.at(Value* th, AintIdx i) @inline /* Retrieve the stack value at the index. Be sure 0<= idx < top. * Good for getting method's parameters: 0=self, 1=parm 1, etc. */ -func Value Value.getLocal(Value *th, AintIdx idx) +fn Value Value.getLocal(Value *th, AintIdx idx) { return *th.at(idx); } /* Put the value on the stack at the designated position. Be sure 0<= idx < top. */ -func void Value.setLocal(Value th, AintIdx idx, Value val) +fn void Value.setLocal(Value th, AintIdx idx, Value val) { *th.at(idx) = val; mem::markChk(th, th, val); } /* Copy the stack value at fromidx into toidx */ -func void Value.copyLocal(Value* th, AintIdx toidx, AintIdx fromidx) +fn void Value.copyLocal(Value* th, AintIdx toidx, AintIdx fromidx) { *th.at(toidx) = *th.at(fromidx); } @@ -69,7 +69,7 @@ func void Value.copyLocal(Value* th, AintIdx toidx, AintIdx fromidx) * Remove the value at index (shifting down all values above it to top) * @require stkSz(th) > 0 */ -func void Value.deleteLocal(Value* th, AintIdx idx) +fn void Value.deleteLocal(Value* th, AintIdx idx) { Value* p = th.at(idx); memmove(p, p + 1, sizeof(Value)*(stkSz(th) - idx - 1)); @@ -80,7 +80,7 @@ func void Value.deleteLocal(Value* th, AintIdx idx) * Insert the popped value into index (shifting up all values above it) * @require stkSz(th) > 0 */ -func void Value.insertLocal(Value *th, AintIdx idx) +fn void Value.insertLocal(Value *th, AintIdx idx) { Value *p = th.at(idx); Value val = *(th(*th).stk_top - 1); @@ -94,7 +94,7 @@ func void Value.insertLocal(Value *th, AintIdx idx) ***************************************/ /* Push a value on the stack's top */ -func Value Value.pushValue(Value* th, Value val) +fn Value Value.pushValue(Value* th, Value val) { stkCanIncTop(th); /* Check if there is room */ *th(*th).stk_top++ = val; @@ -103,14 +103,14 @@ func Value Value.pushValue(Value* th, Value val) } /* Push and return the corresponding Symbol value for a 0-terminated c-string */ -func Value Value.pushSym(Value* th, string str) +fn Value Value.pushSym(Value* th, string str) { stkCanIncTop(th); /* Check if there is room */ return sym::newSym(*th, th(*th).stk_top++, str); } /* Push and return the corresponding Symbol value for a byte sequence of specified length */ -func Value Value.pushSyml(Value th, string str) +fn Value Value.pushSyml(Value th, string str) { stkCanIncTop(th); /* Check if there is room */ return sym::newSym(*th, th(*th).stk_top++, str); @@ -319,7 +319,7 @@ void popSetActProp(Value th, AintIdx selfidx, const char *mbrnm) { } /* Push a copy of a stack's value at index onto the stack's top */ -func Value Value.pushLocal(Value* th, AintIdx idx) +fn Value Value.pushLocal(Value* th, AintIdx idx) { stkCanIncTop(th); /* Check if there is room */ return *th(*th).stk_top++ = th.getLocal(idx); @@ -329,7 +329,7 @@ func Value Value.pushLocal(Value* th, AintIdx idx) * Pop a value off the top of the stack * @require stkSz(th) > 0 */ -func Value Value.popValue() +fn Value Value.popValue() { return *--th(*th).stk_top; } @@ -338,7 +338,7 @@ func Value Value.popValue() * Pops the top value and writes it at idx. Often used to set return value * @require stkSz(th) > 0, idx >= 0, idx < stkSz(th) - 1 */ -func void Value.popLocal(Value* th, AintIdx idx) +fn void Value.popLocal(Value* th, AintIdx idx) { th.setLocal(idx, *(th(*th).stk_top - 1)); // Pop after value is safely in Global @@ -349,7 +349,7 @@ func void Value.popLocal(Value* th, AintIdx idx) * Retrieve the stack value at the index from top. Be sure 0<= idx < top. * @require idx >= 0, idx < stkSz(th) */ -func Value Value.getFromTop(Value* th, AintIdx idx) +fn Value Value.getFromTop(Value* th, AintIdx idx) { return *th.at(stkSz(th) - idx - 1); } @@ -357,7 +357,7 @@ func Value Value.getFromTop(Value* th, AintIdx idx) /** * Return number of values on the current method's stack */ -func AuintIdx Value.getTop(Value* th) +fn AuintIdx Value.getTop(Value* th) { return (AuintIdx)(stkSz(th)); } @@ -367,7 +367,7 @@ func AuintIdx Value.getTop(Value* th) * This can shrink the stack or grow it (padding with 'null's). * A negative index removes that number of values off the top. */ -func void Value.setTop(Value* th as AintIdx idx) +fn void Value.setTop(Value* th as AintIdx idx) { // TODO Value *base = th(*th).curmethod.begin; @@ -395,7 +395,7 @@ func void Value.setTop(Value* th as AintIdx idx) * Push and return the symbolically-named global variable's value * @require vm(*th).global.isTbl() **/ -func Value Value.pushGloVar(Value* th, string var) +fn Value Value.pushGloVar(Value* th, string var) { // Check if there is room stkCanIncTop(th); @@ -408,7 +408,7 @@ func Value Value.pushGloVar(Value* th, string var) * Alter the symbolically-named global variable to have the value popped off the local stack * @require stkSz(th) > 0, vm(th).global.isTbl() **/ -func void Value.popGloVar(Value* th, string var) +fn void Value.popGloVar(Value* th, string var) { // Check if there is room stkCanIncTop(th); @@ -428,7 +428,7 @@ Value pushGlobal(Value th) * Internal function to re-allocate stack's size * @require newsize <= STACK_MAXSIZE || newsize == STACK_ERRORSIZE **/ -func void realloc(Value th, int newsize) +fn void realloc(Value th, int newsize) { // Incremental GC before memory allocation events mem::gccheck(th); diff --git a/resources/examples/notworking/acornvm/lexer.c3 b/resources/examples/notworking/acornvm/lexer.c3 index fcae0d435..8052ff493 100644 --- a/resources/examples/notworking/acornvm/lexer.c3 +++ b/resources/examples/notworking/acornvm/lexer.c3 @@ -11,7 +11,7 @@ module acorn::lex; /** * Crude algorithm for determining if character is a Unicode letter */ -func bool isualpha(Auchar c) @inline +fn bool isualpha(Auchar c) @inline { return c > 0xA0 || isalpha(c); } @@ -20,7 +20,7 @@ func bool isualpha(Auchar c) @inline /** * Algorithm for determining if character is a digit 0-9 */ -func bool isudigit(Auchar c) @inline +fn bool isudigit(Auchar c) @inline { return c >= '0' && c <= '9'; } @@ -28,7 +28,7 @@ func bool isudigit(Auchar c) @inline /** * Return a new LexInfo value, lexer context for a source program */ -func Value new(Value th, Value *dest, Value src, Value url) +fn Value new(Value th, Value *dest, Value src, Value url) { LexInfo *lex; @@ -60,7 +60,7 @@ func Value new(Value th, Value *dest, Value src, Value url) } /** Return the current unicode character whose UTF-8 bytes start at lex->bytepos */ -func Auchar LexInfo.thischar(LexInfo* lex) +fn Auchar LexInfo.thischar(LexInfo* lex) { byte *src = &toStr(lex.source)[lex.bytepos]; int nbytes; @@ -83,7 +83,7 @@ func Auchar LexInfo.thischar(LexInfo* lex) } /** Return the current unicode character whose UTF-8 bytes start at lex->bytepos */ -func Auchar LexInfo.nextchar(LexInfo* lex) +fn Auchar LexInfo.nextchar(LexInfo* lex) { const char *src = &toStr(lex->source)[lex->bytepos]; int nbytes; @@ -114,7 +114,7 @@ func Auchar LexInfo.nextchar(LexInfo* lex) } /** Skip lex->bytepos past the unicode character whose UTF-8 bytes start at lex->bytepos */ -func void LexInfo.skipchar(LexInfo* lex) +fn void LexInfo.skipchar(LexInfo* lex) { const char *src = &toStr(lex->source)[lex->bytepos]; int nbytes; @@ -137,7 +137,7 @@ func void LexInfo.skipchar(LexInfo* lex) /** Scan past non-tokenized white space. * Handle line indentation and continuation */ -func bool LexInfo.scanWhite(LexInfo *lex) +fn bool LexInfo.scanWhite(LexInfo *lex) { Value th = lex.th; // for vmlit @@ -628,7 +628,7 @@ bool lexScanOp(LexInfo *lex) { } /* Get the next token */ -func void LexInfo.getNextToken(LexInfo *lex) +fn void LexInfo.getNextToken(LexInfo *lex) { // Scan until we find a token diff --git a/resources/examples/notworking/acornvm/main.c3 b/resources/examples/notworking/acornvm/main.c3 index 21f8479cc..9cf63f8a4 100644 --- a/resources/examples/notworking/acornvm/main.c3 +++ b/resources/examples/notworking/acornvm/main.c3 @@ -2,7 +2,7 @@ module acornvm::compiler; /* Return a new CompInfo value, compiler state for an Acorn method */ -func Value new_compiler(Value th, Value *dest, Value src, Value url) +fn Value new_compiler(Value th, Value *dest, Value src, Value url) { CompInfo *comp; @@ -53,7 +53,7 @@ func Value new_compiler(Value th, Value *dest, Value src, Value url) - pgmsrc: CompInfo or Text string containing the program source - baseurl: a symbol or null It returns the compiled byte-code method. */ -func int acn_newmethod(Value th) +fn int acn_newmethod(Value th) { // Retrieve pgmsrc and baseurl from parameters Value pgmsrc as baseurl; diff --git a/resources/examples/notworking/acornvm/parser.c3 b/resources/examples/notworking/acornvm/parser.c3 index aae251d97..9fc6bcb0d 100644 --- a/resources/examples/notworking/acornvm/parser.c3 +++ b/resources/examples/notworking/acornvm/parser.c3 @@ -29,7 +29,7 @@ int genAddUrlLit(CompInfo *comp, Value val) { } /* Add a method literal and return its index */ -func int CompInfo.genAddMethodLit(CompInfo *comp, Value val) +fn int CompInfo.genAddMethodLit(CompInfo *comp, Value val) { BMethodInfo* f = comp.method; mem_growvector(comp->th, f->lits, f->nbrlits, f->litsz, Value, INT_MAX); @@ -50,7 +50,7 @@ int findBlockVar(Value th, Value locvars, Value varnm) } /* Look for local variable. Returns idx if found, -1 otherwise. */ -func int CompInfo.findLocalVar(CompInfo *comp, Value varnm) throws SearchError +fn int CompInfo.findLocalVar(CompInfo *comp, Value varnm) throws SearchError { assert(varnm.isSym()); @@ -72,7 +72,7 @@ func int CompInfo.findLocalVar(CompInfo *comp, Value varnm) throws SearchError } /* Look for closure variable. Returns idx if found, -1 otherwise. */ -func int CompInfo.findClosureVar(CompInfo *comp, Value varnm) +fn int CompInfo.findClosureVar(CompInfo *comp, Value varnm) { assert(varnm.isSym()); @@ -112,7 +112,7 @@ void CompInfo.declareLocal(CompInfo *comp, Value varnm) /** Create and return new Closure AST segment Modifies comp->clovarseg and -> newcloseg */ -func Value parseNewClo(CompInfo* comp, Value astseg) +fn Value parseNewClo(CompInfo* comp, Value astseg) { Value th = comp->th; // ('Closure', clovars, ('callprop', Closure, New, getmethod, setmethod)) @@ -289,7 +289,7 @@ void parseValue(CompInfo* comp, Value astseg) } /** Add a list of parameters to a AST propseg */ -func void CompInfo.parseParams(CompInfo* comp, Value propseg, const char *closeparen) +fn void CompInfo.parseParams(CompInfo* comp, Value propseg, const char *closeparen) { bool saveforcelocal = comp->forcelocal; comp->forcelocal = false; @@ -434,7 +434,7 @@ void parsePrefixExp(CompInfo* comp, Value astseg) { } /** Parse the '**' operator */ -func void CompInfo.parsePowerExp(CompInfo* comp, Value astseg) +fn void CompInfo.parsePowerExp(CompInfo* comp, Value astseg) { Value th = comp.th; comp.parsePrefixExp(astseg); @@ -448,7 +448,7 @@ func void CompInfo.parsePowerExp(CompInfo* comp, Value astseg) } /** Parse the '*', '/' or '%' binary operator */ -func void CompInfo.parseMultDivExp(CompInfo* comp inline, Value astseg) +fn void CompInfo.parseMultDivExp(CompInfo* comp inline, Value astseg) { Value th = comp.th; parsePowerExp(astseg); @@ -461,7 +461,7 @@ func void CompInfo.parseMultDivExp(CompInfo* comp inline, Value astseg) } /** Parse the '+' or '-' binary operator */ -func void CompInfo.parseAddSubExp(CompInfo* comp, Value astseg) +fn void CompInfo.parseAddSubExp(CompInfo* comp, Value astseg) { Value th = comp.th; comp.parseMultDivExp(astseg); @@ -474,7 +474,7 @@ func void CompInfo.parseAddSubExp(CompInfo* comp, Value astseg) } /** Parse the range .. constructor operator */ -func void CompInfo.parseRangeExp(CompInfo* comp, Value astseg) +fn void CompInfo.parseRangeExp(CompInfo* comp, Value astseg) { Value th = comp.th; comp.parseAddSubExp(astseg); @@ -494,7 +494,7 @@ func void CompInfo.parseRangeExp(CompInfo* comp, Value astseg) } /** Parse the comparison operators */ -func void CompInfo.parseCompExp(CompInfo* comp, Value astseg) { +fn void CompInfo.parseCompExp(CompInfo* comp, Value astseg) { Value th = comp.th; comp.parseRangeExp(astseg); Value op = comp.lex->token; @@ -514,7 +514,7 @@ func void CompInfo.parseCompExp(CompInfo* comp, Value astseg) { } /* Parse 'not' conditional logic operator */ -func void CompInfo.parseNotExp(CompInfo* comp, Value astseg) +fn void CompInfo.parseNotExp(CompInfo* comp, Value astseg) { Value th = comp.th; bool takenot = false; @@ -530,13 +530,13 @@ func void CompInfo.parseNotExp(CompInfo* comp, Value astseg) } } -func bool CompInfo.matchNext(CompInfo *comp, string s) @inline +fn bool CompInfo.matchNext(CompInfo *comp, string s) @inline { return comp.lex.matchNext(s); } /* Parse 'and' conditional logic operator */ -func void CompInfo.parseAndExp(CompInfo* comp, Value astseg) +fn void CompInfo.parseAndExp(CompInfo* comp, Value astseg) { Value th = comp.th; comp.parseNotExp(astseg); diff --git a/resources/examples/notworking/acornvm/parser_ast.c3 b/resources/examples/notworking/acornvm/parser_ast.c3 index 25a334093..eccabab9c 100644 --- a/resources/examples/notworking/acornvm/parser_ast.c3 +++ b/resources/examples/notworking/acornvm/parser_ast.c3 @@ -16,19 +16,19 @@ import acorn::arr; * **********************/ /** Append a value to AST segment - growing as needed */ -func void addValue(Value th, Value astseg, Value val) @inline +fn void addValue(Value th, Value astseg, Value val) @inline { arr::add(th, astseg, val); } /** Get a value within the AST segment */ -func Value get(Value th, Value astseg, AuintIdx idx) @inline +fn Value get(Value th, Value astseg, AuintIdx idx) @inline { return arr::get(th, astseg, idx); } /** Set a value within the AST segment */ -func void set(Value th, Value astseg, AuintIdx idx, Value val) +fn void set(Value th, Value astseg, AuintIdx idx, Value val) { arr::set(th, astseg, idx, val); } @@ -123,7 +123,7 @@ void popNew(Value th, Value oldseg, Value newseg) } /** Return true if ast segment can be assigned a value: variable or settable property/method */ -func bool isLval(Value th, Value astseg) +fn bool isLval(Value th, Value astseg) { if (!astseg.isArr()) return false; Value op = get(th, astseg, 0); diff --git a/resources/examples/notworking/acornvm/symbol.c3 b/resources/examples/notworking/acornvm/symbol.c3 index 4d64c7819..c2c0b467b 100644 --- a/resources/examples/notworking/acornvm/symbol.c3 +++ b/resources/examples/notworking/acornvm/symbol.c3 @@ -8,7 +8,7 @@ macro @hash_binmod(s, size) } /** Resize the symbol table */ -func void resizeTable(Value th as Auint newsize) +fn void resizeTable(Value th as Auint newsize) { SymTable* sym_tbl = &vm(th)->sym_table; Auint i; @@ -48,7 +48,7 @@ func void resizeTable(Value th as Auint newsize) } /** Initialize the symbol table that hash indexes all symbols */ -func void init(Value th) +fn void init(Value th) { SymTable* sym_tbl = &vm(th).sym_table; sym_tbl.nbrAvail = 0; @@ -67,7 +67,7 @@ void free(Value th) /* If symbol exists in symbol table, reuse it. Otherwise, add it. Anchor (store) symbol value in dest and return it. */ -func Value newSym(Value th, Value* dest, string str, AuintIdx len) +fn Value newSym(Value th, Value* dest, string str, AuintIdx len) { SymInfo* sym; SymTable* sym_tbl = &vm(th)->sym_table; @@ -101,7 +101,7 @@ func Value newSym(Value th, Value* dest, string str, AuintIdx len) } /* Return 1 if the value is a Symbol, otherwise 0 */ -func int Value.isSym(Value *sym) @inline +fn int Value.isSym(Value *sym) @inline { return sym.isEnc(SymEnc); } @@ -120,7 +120,7 @@ int isGlobal(Value sym) * This can be used to sequentially iterate through the symbol table. * Results may be inaccurate if the symbol table is changed during iteration. */ -func Value next(Value th, Value key) +fn Value next(Value th, Value key) { SymTable *sym_tbl = &th(th)->vm->sym_table; SymInfo *sym; diff --git a/resources/examples/notworking/acornvm/value.c3 b/resources/examples/notworking/acornvm/value.c3 index b43bd4815..4a4152c3c 100644 --- a/resources/examples/notworking/acornvm/value.c3 +++ b/resources/examples/notworking/acornvm/value.c3 @@ -48,7 +48,7 @@ typedef void* as distinct Value /** Prototype for a C method callable by the VM. It is passed the thread, through which it obtains parameters via the data stack. When done, it returns how many return values it has placed on the stack. */ -typedef func int(Value) as AcMethodp; +typedef fn int(Value) as AcMethodp; /** Quick, exact equivalence check between two values ('===') * Great for null, false, true, integers and symbols. @@ -73,7 +73,7 @@ const int VAL_MASK = 0x3; const int VAL_SHIFT = 2; -func bool Value.isEnc(Value *value, EncType type) @inline +fn bool Value.isEnc(Value *value, EncType type) @inline { return value.isPtr() && @cast(value as MemInfo*).enctyp == type; } @@ -93,7 +93,7 @@ macro isType(v, ValBits e) /** Is v an Integer? */ -func bool Value.isInt(Value *v) +fn bool Value.isInt(Value *v) { return @isType(*v as INT); } @@ -116,7 +116,7 @@ macro toAint(v) // Float value functions /** Is v a Float? */ -func Value.isFloat(Value *v) +fn Value.isFloat(Value *v) { return @isType(*v as FLOAT); } @@ -157,7 +157,7 @@ macro aTrue() * Is value null? * @require value != null */ -func bool Value.isNull(Value *value) @inline +fn bool Value.isNull(Value *value) @inline { return *v == aNull; } @@ -166,7 +166,7 @@ func bool Value.isNull(Value *value) @inline * Is value false or null? * @require value != null */ -func bool Value.isFalse(Value *value) @inline +fn bool Value.isFalse(Value *value) @inline { return *v == aFalse || *v == aNull; } @@ -174,7 +174,7 @@ func bool Value.isFalse(Value *value) @inline /** * Is value true or false? */ -func bool Value.isBool(Value *value) @inline +fn bool Value.isBool(Value *value) @inline { return *v >= aFalse; } @@ -183,7 +183,7 @@ func bool Value.isBool(Value *value) @inline // Pointer functions. /** Is value a pointer? */ -func bool Value.isPtr(Value *value) @inline +fn bool Value.isPtr(Value *value) @inline { return @isType(*v as POINTER); } diff --git a/resources/examples/notworking/acornvm/vm.c3 b/resources/examples/notworking/acornvm/vm.c3 index 86e8bdc71..7ac1daeb3 100644 --- a/resources/examples/notworking/acornvm/vm.c3 +++ b/resources/examples/notworking/acornvm/vm.c3 @@ -255,7 +255,7 @@ macro memcpy_Auint(i, val) * - The main thread is started up, initializing its global namespace. * - All core types are progressively loaded, establishing the default types for * each encoding. This includes the resource types and Acorn compiler. */ -func Value new(void) +fn Value new(void) { logInfo(AVM_RELEASE " started."); @@ -352,7 +352,7 @@ float vmEndTimer(int64_t starttime) } $else { -func int64_t vmStartTimer() +fn int64_t vmStartTimer() { TimeVal start; start.gettimeofday(); diff --git a/resources/examples/notworking/binarydigits.c3 b/resources/examples/notworking/binarydigits.c3 index ca1ec8a5c..edf053129 100644 --- a/resources/examples/notworking/binarydigits.c3 +++ b/resources/examples/notworking/binarydigits.c3 @@ -1,6 +1,6 @@ module binarydigits; -func int main() +fn int main() { fot (int i = 0; i < 20; i++) { @@ -8,7 +8,7 @@ func int main() } } -func string bin(int x) +fn string bin(int x) { int bits = (x == 0) ? 1 : log10((double)(x)) / log10(2); string ret = str.make_repeat('0' as bits); diff --git a/resources/examples/notworking/globals.c3 b/resources/examples/notworking/globals.c3 index 884ded3e5..23ab78b40 100644 --- a/resources/examples/notworking/globals.c3 +++ b/resources/examples/notworking/globals.c3 @@ -4,7 +4,7 @@ module globals; const string CLICK_ME = "Click Me"; var uint counter = 0; -func void clickedme(GtkButton *o, void *d) +fn void clickedme(GtkButton *o, void *d) { (GtkLabel*)(d).set_text(string.format("You clicked me %d times", ++counter)); } diff --git a/resources/examples/notworking/http.c3 b/resources/examples/notworking/http.c3 index 5a34b6ffc..1ccd084b7 100644 --- a/resources/examples/notworking/http.c3 +++ b/resources/examples/notworking/http.c3 @@ -1,6 +1,6 @@ import curl; -func int main(void) +fn int main(void) { Curl curl; diff --git a/resources/examples/notworking/levenshtein.c3 b/resources/examples/notworking/levenshtein.c3 index 14309c8ae..25321e48a 100644 --- a/resources/examples/notworking/levenshtein.c3 +++ b/resources/examples/notworking/levenshtein.c3 @@ -1,6 +1,6 @@ module levenshtein; -func int levenshtein(String s, String t) +fn int levenshtein(String s, String t) { // if either string is empty, difference is inserting all chars // from the other diff --git a/resources/examples/notworking/madlibs.c3 b/resources/examples/notworking/madlibs.c3 index b6884cf10..a78da432f 100644 --- a/resources/examples/notworking/madlibs.c3 +++ b/resources/examples/notworking/madlibs.c3 @@ -1,7 +1,7 @@ module madlibs; import regex, stdio; -func void main() +fn void main() { println("Enter a story template, terminated by an empty line:"); String story = ""; diff --git a/resources/examples/notworking/map.c3 b/resources/examples/notworking/map.c3 index e112b0313..5f10fb207 100644 --- a/resources/examples/notworking/map.c3 +++ b/resources/examples/notworking/map.c3 @@ -15,13 +15,13 @@ public struct Map uint mod; } -public func Map* Map.init(Map *map) +public fn Map* Map.init(Map *map) { *map = { }; return map; } -public func Type* Map.valueForKey(Map *map, Key key) +public fn Type* Map.valueForKey(Map *map, Key key) { if (!map.map) return nil; usize hash = key.hash(); @@ -36,7 +36,7 @@ public func Type* Map.valueForKey(Map *map, Key key) return nil; } -public func Type *Map.setValueForKey(Map *map, Key key, Type *value) +public fn Type *Map.setValueForKey(Map *map, Key key, Type *value) { if (!map.map) { @@ -71,12 +71,12 @@ public func Type *Map.setValueForKey(Map *map, Key key, Type *value) } } -public func usize Map.size(Vector *vector) +public fn usize Map.size(Vector *vector) { return vector.array.size; } -public func void Map.removeLast(Vector *vector) +public fn void Map.removeLast(Vector *vector) { vector.array.pop(); } diff --git a/resources/examples/notworking/retry.c3 b/resources/examples/notworking/retry.c3 index 8d8cf6aae..07829a273 100644 --- a/resources/examples/notworking/retry.c3 +++ b/resources/examples/notworking/retry.c3 @@ -13,7 +13,7 @@ public macro retry(#function, int retries = 3) return e!; } -func void main() +fn void main() { int! result = @retry(eventually_succeed()); } \ No newline at end of file diff --git a/resources/examples/notworking/toml_parser_c2.c3 b/resources/examples/notworking/toml_parser_c2.c3 index 902b340f0..c32c338e2 100644 --- a/resources/examples/notworking/toml_parser_c2.c3 +++ b/resources/examples/notworking/toml_parser_c2.c3 @@ -18,7 +18,7 @@ const uint MaxDepth = 8; $if (DEBUG_NODES): -func void Blocks.dump(Blocks* b) +fn void Blocks.dump(Blocks* b) { printf("Nodes (%u/%u) (%u bytes)\n", b.nodeCount, b.maxNodes, b.nodeCount * sizeof(Node)); for (uint i = 0; i < b.nodeCount; i++) @@ -82,7 +82,7 @@ $endif; /** * @ensure const(a), const(b) */ -func bool same(char* a, char* b) +fn bool same(char* a, char* b) { uint i = 0; while (a[i] == b[i]) @@ -110,7 +110,7 @@ struct Parser /** * @ensure const(input) */ -func void! Parser.parse(Parser* p, char* input, char* diagMsg, Blocks* blocks) +fn void! Parser.parse(Parser* p, char* input, char* diagMsg, Blocks* blocks) { p.tokenizer.init(input); p.tok.init(); @@ -127,7 +127,7 @@ func void! Parser.parse(Parser* p, char* input, char* diagMsg, Blocks* blocks) try p.parseTopLevel(); } -func void! Parser.parseTopLevel(Parser* p) +fn void! Parser.parseTopLevel(Parser* p) { // key = value // | [[array]] @@ -149,22 +149,22 @@ func void! Parser.parseTopLevel(Parser* p) } } -func uint getRawValue(uint raw) @(inline) +fn uint getRawValue(uint raw) @(inline) { return raw & ~RawValueMask; } -func ValueType getRawType(uint raw) @(inline) +fn ValueType getRawType(uint raw) @(inline) { return (ValueType)((raw >> ValueTypeOffset) & 0x3); } -func uint addType(uint raw, ValueType t) @(inline) +fn uint addType(uint raw, ValueType t) @(inline) { return raw | (t << ValueTypeOffset); } -func void! Parser.parseKeyValue(Parser* p) +fn void! Parser.parseKeyValue(Parser* p) { //printf("parseKeyValue()\n"); char[MaxText] key; @@ -187,7 +187,7 @@ func void! Parser.parseKeyValue(Parser* p) p.lastChild[p.numParents] = node; } -func void! Parser.parseTable(Parser* p) +fn void! Parser.parseTable(Parser* p) { //printf("parseTable()\n"); try p.consumeToken(); @@ -211,7 +211,7 @@ func void! Parser.parseTable(Parser* p) p.expectAndConsume(TokenKind.Rbrace); } -func void Parser.parseTableArray(Parser* p) +fn void Parser.parseTableArray(Parser* p) { //printf("parseTableArray()\n"); p.consumeToken(); @@ -234,7 +234,7 @@ func void Parser.parseTableArray(Parser* p) p.expectAndConsume(TokenKind.Rbrace2); } -func u32 Parser.parseValue(Parser* p) { +fn u32 Parser.parseValue(Parser* p) { //printf("parseValue()\n"); u32 value = 0; switch (p.tok.kind) { @@ -266,7 +266,7 @@ func u32 Parser.parseValue(Parser* p) { return value; } -func u32 Parser.parseArrayValues(Parser* p) { +fn u32 Parser.parseArrayValues(Parser* p) { //printf("parseArrayValues()\n"); p.consumeToken(); u32 value = p.parseValue() | ValueIsArray; @@ -280,7 +280,7 @@ func u32 Parser.parseArrayValues(Parser* p) { return value; } -func u32 Parser.addTable(Parser* p, const char* name, u32 depth, bool isTop, NodeKind kind) { +fn u32 Parser.addTable(Parser* p, const char* name, u32 depth, bool isTop, NodeKind kind) { //printf("addTable %s\n", name); Blocks* blocks = p.blocks; if (!isTop && p.numParents > depth && same(blocks.getName(p.parents[depth]), name)) { @@ -342,18 +342,18 @@ func u32 Parser.addTable(Parser* p, const char* name, u32 depth, bool isTop, Nod return 0; } -func Location! Parser.consumeToken(Parser* p) +fn Location! Parser.consumeToken(Parser* p) { Location prev = p.tok.loc; try p.tokenizer.lex(&p.tok); return prev; } -func Token* Parser.nextToken(Parser* p) { +fn Token* Parser.nextToken(Parser* p) { return p.tokenizer.lookahead(); } -func void! Parser.expectAndConsume(Parser* p, TokenKind k) { +fn void! Parser.expectAndConsume(Parser* p, TokenKind k) { if (p.tok.isNot(k)) { sprintf(p.errorMsg, "expected '%s' at %s", token2str(k), p.tok.loc.str()); @@ -362,7 +362,7 @@ func void! Parser.expectAndConsume(Parser* p, TokenKind k) { try p.consumeToken(); } -func void Parser.expect(Parser* p, TokenKind k) +fn void Parser.expect(Parser* p, TokenKind k) { if (p.tok.isNot(k)) { @@ -379,7 +379,7 @@ public struct TomlReader @opaque Blocks* blocks; } -public func TomlReader* new_toml() +public fn TomlReader* new_toml() { TomlReader* r = @malloc(TomlReader); r.blocks = @malloc(Blocks); @@ -387,21 +387,21 @@ public func TomlReader* new_toml() return r; } -public func void TomlReader.destroy(TomlReader* r) +public fn void TomlReader.destroy(TomlReader* r) { r.blocks.destroy(); free(r.blocks); free(r); } -public func const char* TomlReader.getMsg(const TomlReader* r) +public fn const char* TomlReader.getMsg(const TomlReader* r) { return r.message; } error EmptyFileError; -public func void! TomlReader.parse(TomlReader* r, string filename) +public fn void! TomlReader.parse(TomlReader* r, string filename) { Reader file; @@ -427,7 +427,7 @@ $endif // -------------------------------------------------------------- // Getters+iters -func const Node* Reader.findNode(const Reader* r, const char* key) +fn const Node* Reader.findNode(const Reader* r, const char* key) { char[MaxText] name; const char* cp = key; @@ -459,7 +459,7 @@ func const Node* Reader.findNode(const Reader* r, const char* key) return nil; } -public func const char* Reader.getValue(const Reader* r, const char* key) { +public fn const char* Reader.getValue(const Reader* r, const char* key) { const Node* node = r.findNode(key); if (!node) return nil; if (getKind(node.nameOffset) != NodeKind.Value) return nil; @@ -468,7 +468,7 @@ public func const char* Reader.getValue(const Reader* r, const char* key) { return &r.blocks.values[getRawValue(node.rawValue)]; } -public func bool Reader.getNumber(const Reader* r, const char* key, u32* result) { +public fn bool Reader.getNumber(const Reader* r, const char* key, u32* result) { const Node* node = r.findNode(key); if (!node) return false; if (getKind(node.nameOffset) != NodeKind.Value) return false; @@ -478,7 +478,7 @@ public func bool Reader.getNumber(const Reader* r, const char* key, u32* result) return true; } -public func bool Reader.getBool(const Reader* r, const char* key, bool* result) { +public fn bool Reader.getBool(const Reader* r, const char* key, bool* result) { const Node* node = r.findNode(key); if (!node) return false; if (getKind(node.nameOffset) != NodeKind.Value) return false; @@ -493,18 +493,18 @@ public type NodeIter struct { const Node* node; } -public func bool NodeIter.done(const NodeIter* i) { +public fn bool NodeIter.done(const NodeIter* i) { return i.node == nil; } -public func void NodeIter.next(NodeIter* i) { +public fn void NodeIter.next(NodeIter* i) { if (i.node == nil) return; u32 next = i.node.nextNode; if (next == 0) i.node = nil; else i.node = &i.blocks.nodes[next]; } -public func const char* NodeIter.getValue(const NodeIter* i, const char* key) { +public fn const char* NodeIter.getValue(const NodeIter* i, const char* key) { const Node* child = i.blocks.findNode(key, i.node); if (!child) return nil; if (getKind(child.nameOffset) != NodeKind.Value) return nil; @@ -513,7 +513,7 @@ public func const char* NodeIter.getValue(const NodeIter* i, const char* key) { return &i.blocks.values[getRawValue(child.rawValue)]; } -public func bool NodeIter.getNumber(const NodeIter* i, const char* key, u32* result) { +public fn bool NodeIter.getNumber(const NodeIter* i, const char* key, u32* result) { const Node* child = i.blocks.findNode(key, i.node); if (!child) return false; if (getKind(child.nameOffset) != NodeKind.Value) return false; @@ -523,7 +523,7 @@ public func bool NodeIter.getNumber(const NodeIter* i, const char* key, u32* res return true; } -public func bool NodeIter.getBool(const NodeIter* i, const char* key, bool* result) { +public fn bool NodeIter.getBool(const NodeIter* i, const char* key, bool* result) { const Node* child = i.blocks.findNode(key, i.node); if (!child) return false; if (getKind(child.nameOffset) != NodeKind.Value) return false; @@ -533,7 +533,7 @@ public func bool NodeIter.getBool(const NodeIter* i, const char* key, bool* resu return true; } -public func NodeIter Reader.getNodeIter(const Reader* r, const char* key) { +public fn NodeIter Reader.getNodeIter(const Reader* r, const char* key) { const Node* node = r.findNode(key); if (node && getKind(node.nameOffset) == NodeKind.TableArray) { node = &r.blocks.nodes[node.child]; @@ -548,26 +548,26 @@ public type ValueIter struct { bool isArray; } -func ValueIter ValueIter.create(const char* values, bool isArray) { +fn ValueIter ValueIter.create(const char* values, bool isArray) { ValueIter iter = { values, isArray } return iter; } -public func bool ValueIter.done(const ValueIter* i) { +public fn bool ValueIter.done(const ValueIter* i) { return i.values[0] == 0; } -public func void ValueIter.next(ValueIter* i) { +public fn void ValueIter.next(ValueIter* i) { if (i.values[0] == 0) return; while (i.values[0] != 0) i.values++; if (i.isArray) i.values++; // skip 0-terminator } -public func const char* ValueIter.getValue(const ValueIter* i) { +public fn const char* ValueIter.getValue(const ValueIter* i) { return i.values; } -public func ValueIter Reader.getValueIter(const Reader* r, const char* key) { +public fn ValueIter Reader.getValueIter(const Reader* r, const char* key) { const Node* node = r.findNode(key); if (node) { switch (getKind(node.nameOffset)) { @@ -608,7 +608,7 @@ const u32 ValueIsArray = (1 << 31); const u32 ValueTypeOffset = 29; const u32 RawValueMask = (0x7 << 29); -func const char* type2str(ValueType t) { +fn const char* type2str(ValueType t) { switch (t) { case ValueType.Text: return "T"; case ValueType.Number: return "N"; @@ -643,7 +643,7 @@ public type Blocks struct { u32 valuesSize; } @(opaque) -func void Blocks.init(Blocks* b) { +fn void Blocks.init(Blocks* b) { memset(b, 0, sizeof(Blocks)); b.nodes = calloc(MaxNodes, sizeof(Node)); @@ -662,13 +662,13 @@ func void Blocks.init(Blocks* b) { memset(b.namesCache, 0, sizeof(u32)*NamesCacheSize); } -func void Blocks.destroy(Blocks* b) { +fn void Blocks.destroy(Blocks* b) { free(b.values); free(b.names); free(b.nodes); } -func u32 Blocks.searchNameCache(Blocks* b, const char* name) { +fn u32 Blocks.searchNameCache(Blocks* b, const char* name) { for (u32 i=0; i(strlen(value)) + 1; @@ -721,12 +721,12 @@ func u32 Blocks.addValue(Blocks* b, const char* value) { return off; } -func void Blocks.addNull(Blocks* b) { +fn void Blocks.addNull(Blocks* b) { b.values[b.valuesOffset] = 0; b.valuesOffset++; } -func Node* Blocks.findNode(const Blocks* b, const char* name, const Node* parent) { +fn Node* Blocks.findNode(const Blocks* b, const char* name, const Node* parent) { if (b.nodeCount == 0) return nil; Node* node = &b.nodes[0]; if (parent) { @@ -746,14 +746,14 @@ func Node* Blocks.findNode(const Blocks* b, const char* name, const Node* parent const u32 NodeKindOffset = 29; -func u32 addKind(u32 value, NodeKind k) @(inline) { +fn u32 addKind(u32 value, NodeKind k) @(inline) { return value | (k << NodeKindOffset); } -func NodeKind getKind(u32 value) @(inline) { +fn NodeKind getKind(u32 value) @(inline) { return cast(value >> NodeKindOffset); } -func u32 getValue(u32 value) @(inline) { +fn u32 getValue(u32 value) @(inline) { return value & ~(0x7 << NodeKindOffset); } diff --git a/resources/examples/notworking/toml_tokenizer_c2.c3 b/resources/examples/notworking/toml_tokenizer_c2.c3 index a35656691..fcec7e945 100644 --- a/resources/examples/notworking/toml_tokenizer_c2.c3 +++ b/resources/examples/notworking/toml_tokenizer_c2.c3 @@ -25,13 +25,13 @@ enum TokenKind : char (String name) ERROR("error"), } -func void Location.init(Location* l, uint line = 0, uint col = 0) +fn void Location.init(Location* l, uint line = 0, uint col = 0) { l.line = line; l.column = col; } -func string Location.str(Location* l) +fn string Location.str(Location* l) { static char[32] msg; sprintf(msg, "line %u:%u", l.line, l.column); @@ -50,7 +50,7 @@ struct Token } } -func void Token.init(Token* t) +fn void Token.init(Token* t) { t.loc.init(0, 0); t.kind = TokenKind.EOF; @@ -58,28 +58,28 @@ func void Token.init(Token* t) t.number = 0; } -func void Token.clear(Token* t) +fn void Token.clear(Token* t) { t.text = nil; t.number = 0; } -func void Token.setLocation(Token* t, Location l) +fn void Token.setLocation(Token* t, Location l) { t.loc = l; } -func bool Token.is(Token* t, TokenKind k) +fn bool Token.is(Token* t, TokenKind k) { return t.kind == k; } -func bool Token.isNot(Token* t, TokenKind k) +fn bool Token.isNot(Token* t, TokenKind k) { return t.kind != k; } -func string Token.getName(Token* t) +fn string Token.getName(Token* t) { return t.kind.name; } @@ -94,7 +94,7 @@ struct Tokenizer bool haveNext; } -func void Tokenizer.init(Tokenizer* t, char* input) +fn void Tokenizer.init(Tokenizer* t, char* input) { t.dataStart = input; t.current = input; @@ -109,7 +109,7 @@ error LexError string error_message; } -func void! Tokenizer.lex(Tokenizer* t, Token* result) +fn void! Tokenizer.lex(Tokenizer* t, Token* result) { if (t.haveNext) { @@ -221,7 +221,7 @@ func void! Tokenizer.lex(Tokenizer* t, Token* result) } } -func Token*! Tokenizer.lookahead(Tokenizer* t) +fn Token*! Tokenizer.lookahead(Tokenizer* t) { if (!t.haveNext) { @@ -231,13 +231,13 @@ func Token*! Tokenizer.lookahead(Tokenizer* t) return &t.nextToken; } -func void Tokenizer.advance(Tokenizer* t, uint amount) +fn void Tokenizer.advance(Tokenizer* t, uint amount) { t.loc.column += amount; t.current += amount; } -func void Tokenizer.parseComment(Tokenizer* t) +fn void Tokenizer.parseComment(Tokenizer* t) { while (1) { @@ -258,7 +258,7 @@ func void Tokenizer.parseComment(Tokenizer* t) } } -func void Tokenizer.parseText(Tokenizer* t, Token* result) +fn void Tokenizer.parseText(Tokenizer* t, Token* result) { // TODO handle literal strings ' .. ' -> no escaping // TODO handle escape chars for normal strings " .. \" \r \n " @@ -277,7 +277,7 @@ func void Tokenizer.parseText(Tokenizer* t, Token* result) t.advance(1); } -func void! Tokenizer.parseMultiText(Tokenizer* t, Token* result) +fn void! Tokenizer.parseMultiText(Tokenizer* t, Token* result) { t.advance(3); if (t.current[0] == '\n') @@ -317,7 +317,7 @@ func void! Tokenizer.parseMultiText(Tokenizer* t, Token* result) t.advance(3); } -func void Tokenizer.parseNumber(Tokenizer* t, Token* result) +fn void Tokenizer.parseNumber(Tokenizer* t, Token* result) { // TODO handle prefix +/- // handle hexadecimal/ocal/binary number @@ -333,7 +333,7 @@ func void Tokenizer.parseNumber(Tokenizer* t, Token* result) } } -func bool isKeyChar(u8 c) +fn bool isKeyChar(u8 c) { if (c >= 128) return true; if (isalpha(c)) return true; @@ -342,7 +342,7 @@ func bool isKeyChar(u8 c) return false; } -func void Tokenizer.parseKey(Tokenizer* t, Token* result) +fn void Tokenizer.parseKey(Tokenizer* t, Token* result) { char* start = t.current; while (t.current[0] && isKeyChar((char)(t.current[0]))) t.current++; diff --git a/resources/examples/notworking/vector.c3 b/resources/examples/notworking/vector.c3 index 56ee0c063..47e1c7faf 100644 --- a/resources/examples/notworking/vector.c3 +++ b/resources/examples/notworking/vector.c3 @@ -5,42 +5,42 @@ public struct Vector Type[] array; } -public func void Vector.init() +public fn void Vector.init() { array = nil; } -public func void Vector.add(Vector *vector, Type type) +public fn void Vector.add(Vector *vector, Type type) { vector.array += type; } -public func usize Vector.size(Vector *vector) +public fn usize Vector.size(Vector *vector) { return vector.array.size; } -public func void Vector.removeLast(Vector *vector) +public fn void Vector.removeLast(Vector *vector) { vector.array.pop(); } -public func void Vector.removefirst(Vector *vector) +public fn void Vector.removefirst(Vector *vector) { vector.array.removeAt(0); } -public func void Type *Vector.first(Vector *vector) +public fn void Type *Vector.first(Vector *vector) { return &vector.array.first; } -public func void Type *Vector.last(Vector *vector) +public fn void Type *Vector.last(Vector *vector) { return &vector.array.last(); } -public func bool Vector.empty(Vector *vector) +public fn bool Vector.empty(Vector *vector) { return !vector.array.size; } diff --git a/resources/examples/notworking/virtuals.c3 b/resources/examples/notworking/virtuals.c3 index cb21b7c25..ffbe622f8 100644 --- a/resources/examples/notworking/virtuals.c3 +++ b/resources/examples/notworking/virtuals.c3 @@ -3,8 +3,8 @@ import std::math; interface Geometry { - func double area(); - func double perim(); + fn double area(); + fn double perim(); } struct Rect @@ -17,32 +17,32 @@ struct Circle double radius; } -func double Rect.area(Rect *r) +fn double Rect.area(Rect *r) { return r.width * r.height; } -func double Rect.perim(Rect *r) +fn double Rect.perim(Rect *r) { return 2 * r.width + 2 * r.height; } -func double Circle.area(Circle *c) +fn double Circle.area(Circle *c) { return math::PI * c.radius * c.radius } -func double Circle.perim(Circle *c) +fn double Circle.perim(Circle *c) { return math::PI * c.radius * 2; } -func void measure(virtual Geometry g) +fn void measure(virtual Geometry g) { printf("area: %f, perimeter: %f\n", g.area(), g.perim()); } -func void main() +fn void main() { Rect r = { 3, 4 }; Circle c = { 5 }; diff --git a/resources/examples/notworking/window.c3 b/resources/examples/notworking/window.c3 index d6f028d22..d3d32fce3 100644 --- a/resources/examples/notworking/window.c3 +++ b/resources/examples/notworking/window.c3 @@ -3,7 +3,7 @@ import gtk; const string CLICK_ME = "Click Me"; uint counter = 0; -func void clickedme(GtkButton *o, void *d) +fn void clickedme(GtkButton *o, void *d) { (GtkLabel*)(d).set_text(string.format("You clicked me %d times", ++counter)); } diff --git a/resources/examples/spectralnorm.c3 b/resources/examples/spectralnorm.c3 index 14a8f756d..78060983a 100644 --- a/resources/examples/spectralnorm.c3 +++ b/resources/examples/spectralnorm.c3 @@ -2,18 +2,18 @@ module spectralnorm; import std::mem; import std::array; -extern func int atoi(char *s); -extern func int printf(char *s, ...); -extern func double sqrt(double); +extern fn int atoi(char *s); +extern fn int printf(char *s, ...); +extern fn double sqrt(double); double[] temparr; -func double eval_A(int i, int j) +fn double eval_A(int i, int j) { return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1); } -func void eval_A_times_u(double[] u, double[] au) +fn void eval_A_times_u(double[] u, double[] au) { foreach (i, &val : au) { @@ -25,7 +25,7 @@ func void eval_A_times_u(double[] u, double[] au) } } -func void eval_At_times_u(double[] u, double[] au) +fn void eval_At_times_u(double[] u, double[] au) { foreach (i, &val : au) { @@ -37,13 +37,13 @@ func void eval_At_times_u(double[] u, double[] au) } } -func void eval_AtA_times_u(double[] u, double[] atau) @noinline +fn void eval_AtA_times_u(double[] u, double[] atau) @noinline { eval_A_times_u(u, temparr); eval_At_times_u(temparr, atau); } -func int main(int argc, char **argv) +fn int main(int argc, char **argv) { int n = (argc == 2) ? atoi(argv[1]) : 2000; temparr = @array::make(double, n); diff --git a/resources/grammar/c3.l b/resources/grammar/c3.l index fe7cf24cb..0aaeb9a37 100644 --- a/resources/grammar/c3.l +++ b/resources/grammar/c3.l @@ -56,7 +56,7 @@ void comment(void); "void" { count(); return(VOID); } "volatile" { count(); return(VOLATILE); } "while" { count(); return(WHILE); } -"func" { count(); return(FUNC); } +"fn" { count(); return(FUNC); } "nil" { count(); return(NIL); } "next" { count(); return(NEXT); } "in" { count(); return(IN); } diff --git a/resources/lib/std/hash/adler32.c3 b/resources/lib/std/hash/adler32.c3 index f960e67f1..43e160a95 100644 --- a/resources/lib/std/hash/adler32.c3 +++ b/resources/lib/std/hash/adler32.c3 @@ -8,18 +8,18 @@ struct Adler32 uint b; } -func void Adler32.init(Adler32 *this) +fn void Adler32.init(Adler32 *this) { *this = { 1, 0 }; } -func void Adler32.updatec(Adler32* this, char c) +fn void Adler32.updatec(Adler32* this, char c) { this.a = (this.a + c) % ADLER_CONST; this.b = (this.b + this.a) % ADLER_CONST; } -func void Adler32.update(Adler32* this, char[] data) +fn void Adler32.update(Adler32* this, char[] data) { uint a = this.a; uint b = this.b; @@ -31,12 +31,12 @@ func void Adler32.update(Adler32* this, char[] data) *this = { a, b }; } -func uint Adler32.final(Adler32* this) +fn uint Adler32.final(Adler32* this) { return (this.b << 16) | this.a; } -func uint encode(char[] data) +fn uint encode(char[] data) { uint a = 1; uint b = 0; diff --git a/resources/lib/std/hash/crc32.c3 b/resources/lib/std/hash/crc32.c3 index 38e2338a6..6e4e9c496 100644 --- a/resources/lib/std/hash/crc32.c3 +++ b/resources/lib/std/hash/crc32.c3 @@ -5,17 +5,17 @@ struct Crc32 uint result; } -func void Crc32.init(Crc32* this, uint seed = 0) +fn void Crc32.init(Crc32* this, uint seed = 0) { this.result = ~seed; } -func void Crc32.updatec(Crc32* this, char c) +fn void Crc32.updatec(Crc32* this, char c) { this.result = (this.result >> 8) ^ CRC32_TABLE[(this.result ^ c) & 0xFF]; } -func void Crc32.update(Crc32* this, char[] data) +fn void Crc32.update(Crc32* this, char[] data) { uint result = this.result; foreach (char x : data) @@ -25,12 +25,12 @@ func void Crc32.update(Crc32* this, char[] data) this.result = result; } -func uint Crc32.final(Crc32* this) +fn uint Crc32.final(Crc32* this) { return ~this.result; } -func uint encode(char[] data) +fn uint encode(char[] data) { uint result = ~(uint)(0); foreach (char x : data) diff --git a/resources/lib/std/hash/crc64.c3 b/resources/lib/std/hash/crc64.c3 index eafb4ef96..a8cf76786 100644 --- a/resources/lib/std/hash/crc64.c3 +++ b/resources/lib/std/hash/crc64.c3 @@ -5,17 +5,17 @@ struct Crc64 ulong result; } -func void Crc64.init(Crc64* this, uint seed = 0) +fn void Crc64.init(Crc64* this, uint seed = 0) { this.result = seed; } -func void Crc64.updatec(Crc64* this, char c) +fn void Crc64.updatec(Crc64* this, char c) { this.result = (this.result << 8) ^ CRC64_TABLE[(char)((this.result >> 56) ^ c)]; } -func void Crc64.update(Crc64* this, char[] data) +fn void Crc64.update(Crc64* this, char[] data) { ulong result = this.result; foreach (char x : data) @@ -25,12 +25,12 @@ func void Crc64.update(Crc64* this, char[] data) this.result = result; } -func ulong Crc64.final(Crc64* this) +fn ulong Crc64.final(Crc64* this) { return this.result; } -func ulong encode(char[] data) +fn ulong encode(char[] data) { ulong result = (ulong)(0); foreach (char x : data) diff --git a/resources/lib/std/io.c3 b/resources/lib/std/io.c3 index 9764463f4..9d6f3f3f9 100644 --- a/resources/lib/std/io.c3 +++ b/resources/lib/std/io.c3 @@ -29,18 +29,18 @@ struct File void *file; } -extern func int _puts(char* message) @extname("puts"); -extern func int printf(char* message, ...); -extern func int _putchar(char c) @extname("putchar"); +extern fn int _puts(char* message) @extname("puts"); +extern fn int printf(char* message, ...); +extern fn int _putchar(char c) @extname("putchar"); extern File *__stdinp; -func int putchar(char c) @inline +fn int putchar(char c) @inline { return _putchar(c); } -func int print(char *message) +fn int print(char *message) { char* pointer = message; while (*pointer != '\0') @@ -51,13 +51,13 @@ func int print(char *message) return 1; } -func int println(char *message = "") @inline +fn int println(char *message = "") @inline { return _puts(message); } -func void! File.open(File* file, char[] filename, char[] mode) +fn void! File.open(File* file, char[] filename, char[] mode) { char* filename_copy = mem::talloc(filename.len + 1)!!; diff --git a/resources/lib/std/linkedlist.c3 b/resources/lib/std/linkedlist.c3 index 25ab88bfa..c77f20474 100644 --- a/resources/lib/std/linkedlist.c3 +++ b/resources/lib/std/linkedlist.c3 @@ -15,12 +15,12 @@ struct LinkedList Node *last; } -func void LinkedList.push(LinkedList *list, Type value) +fn void LinkedList.push(LinkedList *list, Type value) { list.linkLast(value); } -private func void LinkedList.linkFirst(LinkedList *list, Type value) +private fn void LinkedList.linkFirst(LinkedList *list, Type value) { Node *first = list.first; Node *new_node = @mem::malloc(Node); @@ -37,7 +37,7 @@ private func void LinkedList.linkFirst(LinkedList *list, Type value) list.size++; } -private func void LinkedList.linkLast(LinkedList *list, Type value) +private fn void LinkedList.linkLast(LinkedList *list, Type value) { Node *last = list.last; Node *new_node = mem::alloc($sizeof(Node)); @@ -54,7 +54,7 @@ private func void LinkedList.linkLast(LinkedList *list, Type value) list.size++; } -func void LinkedList.free(LinkedList *list) +fn void LinkedList.free(LinkedList *list) { for (Node* node = list.first; node != null;) { @@ -67,12 +67,12 @@ func void LinkedList.free(LinkedList *list) list.size = 0; } -func usize LinkedList.len(LinkedList* list) @inline +fn usize LinkedList.len(LinkedList* list) @inline { return list.size; } -func Type LinkedList.get(LinkedList* list, usize index) +fn Type LinkedList.get(LinkedList* list, usize index) { Node* node = list.first; while (index--) @@ -84,7 +84,7 @@ func Type LinkedList.get(LinkedList* list, usize index) /** * @require succ != null **/ -private func void LinkedList.linkBefore(LinkedList *list, Node *succ, Type value) +private fn void LinkedList.linkBefore(LinkedList *list, Node *succ, Type value) { Node* pred = succ.prev; Node* new_node = @mem::malloc(Node); @@ -104,7 +104,7 @@ private func void LinkedList.linkBefore(LinkedList *list, Node *succ, Type value /** * @require f == list.first && f != null **/ -private func void unlinkFirst(LinkedList* list, Node* f) +private fn void unlinkFirst(LinkedList* list, Node* f) { Node* next = f.next; mem::free(f); @@ -123,7 +123,7 @@ private func void unlinkFirst(LinkedList* list, Node* f) /** * @require l == list.last && l != null **/ -private func void LinkedList.unlinkLast(LinkedList *list, Node* l) +private fn void LinkedList.unlinkLast(LinkedList *list, Node* l) { Node* prev = l.prev; list.last = prev; @@ -142,7 +142,7 @@ private func void LinkedList.unlinkLast(LinkedList *list, Node* l) /** * @require x != null **/ -private func void LinkedList.unlink(LinkedList* list, Node* x) +private fn void LinkedList.unlink(LinkedList* list, Node* x) { Node* next = x.next; Node* prev = x.prev; diff --git a/resources/lib/std/list.c3 b/resources/lib/std/list.c3 index a34902cea..89cf3400a 100644 --- a/resources/lib/std/list.c3 +++ b/resources/lib/std/list.c3 @@ -8,7 +8,7 @@ struct List Type *entries; } -private func void List.ensureCapacity(List *list) @inline +private fn void List.ensureCapacity(List *list) @inline { if (list.capacity == list.size) { @@ -17,12 +17,12 @@ private func void List.ensureCapacity(List *list) @inline } } -func void List.push(List *list, Type element) @inline +fn void List.push(List *list, Type element) @inline { list.append(element); } -func void List.append(List *list, Type element) +fn void List.append(List *list, Type element) { list.ensureCapacity(); list.entries[list.size++] = element; @@ -31,7 +31,7 @@ func void List.append(List *list, Type element) /** * @require list.size > 0 */ -func Type List.pop(List *list) +fn Type List.pop(List *list) { return list.entries[--list.size]; } @@ -39,14 +39,14 @@ func Type List.pop(List *list) /** * @require list.size > 0 */ -func Type List.popFirst(List *list) +fn Type List.popFirst(List *list) { Type value = list.entries[0]; list.removeAt(0); return value; } -func void List.removeAt(List *list, usize index) +fn void List.removeAt(List *list, usize index) { for (usize i = index + 1; i < list.size; i++) { @@ -55,12 +55,12 @@ func void List.removeAt(List *list, usize index) list.size--; } -func void List.pushFront(List *list, Type type) @inline +fn void List.pushFront(List *list, Type type) @inline { list.insertAt(0, type); } -func void List.insertAt(List *list, usize index, Type type) +fn void List.insertAt(List *list, usize index, Type type) { list.ensureCapacity(); for (usize i = list.size; i > index; i--) @@ -71,42 +71,42 @@ func void List.insertAt(List *list, usize index, Type type) list.entries[index] = type; } -func void List.removeLast(List *list) +fn void List.removeLast(List *list) { list.size--; } -func void List.removeFirst(List *list) +fn void List.removeFirst(List *list) { list.removeAt(0); } -func Type* List.first(List *list) +fn Type* List.first(List *list) { return list.size ? &list.entries[0] : null; } -func Type* List.last(List *list) +fn Type* List.last(List *list) { return list.size ? &list.entries[list.size - 1] : null; } -func bool List.isEmpty(List *list) +fn bool List.isEmpty(List *list) { return list.size; } -func usize List.len(List *list) +fn usize List.len(List *list) { return list.size; } -func Type List.get(List *list, usize index) +fn Type List.get(List *list, usize index) { return list.entries[index]; } -func void List.free(List *list) +fn void List.free(List *list) { mem::free(list.entries); list.capacity = 0; diff --git a/resources/lib/std/mem.c3 b/resources/lib/std/mem.c3 index 044be0b9e..7e058a07d 100644 --- a/resources/lib/std/mem.c3 +++ b/resources/lib/std/mem.c3 @@ -1,9 +1,9 @@ module std::mem; -extern func void* _malloc(usize bytes) @extname("malloc"); -extern func void* _realloc(void* ptr, usize bytes) @extname("realloc"); -extern func void* _calloc(usize bytes, usize elements) @extname("calloc"); -extern func void _free(void* ptr) @extname("free"); +extern fn void* _malloc(usize bytes) @extname("malloc"); +extern fn void* _realloc(void* ptr, usize bytes) @extname("realloc"); +extern fn void* _calloc(usize bytes, usize elements) @extname("calloc"); +extern fn void _free(void* ptr) @extname("free"); macro volatile_load(&x) { @@ -27,7 +27,7 @@ errtype AllocationFailure OUT_OF_MEMORY } -define AllocatorFunction = func void!(void *data, void** pointer, usize bytes, usize alignment, AllocationKind kind); +define AllocatorFunction = fn void!(void *data, void** pointer, usize bytes, usize alignment, AllocationKind kind); struct Allocator { @@ -35,12 +35,12 @@ struct Allocator void *data; } -func void copy(char* dst, char* src, usize size) +fn void copy(char* dst, char* src, usize size) { for (usize i = 0; i < size; i++) dst[i] = src[i]; } -func void! system_malloc_function(void *unused, void** pointer, usize bytes, usize alignment, AllocationKind kind) @inline +fn void! system_malloc_function(void *unused, void** pointer, usize bytes, usize alignment, AllocationKind kind) @inline { switch (kind) { @@ -72,7 +72,7 @@ struct SlotAllocator usize current_page; } -func void*! SlotAllocator.alloc(SlotAllocator *allocator, usize size) +fn void*! SlotAllocator.alloc(SlotAllocator *allocator, usize size) { void* active_page = (char*)(allocator.pages) + allocator.current_page * allocator.page_size; void** page_pointer = (void**)(active_page); @@ -101,7 +101,7 @@ struct RingAllocator } -func void* RingAllocator.alloc(RingAllocator *allocator, usize size) +fn void* RingAllocator.alloc(RingAllocator *allocator, usize size) { if (size > allocator.size) return null; // Wraparound? If so, start at the beginning. @@ -115,7 +115,7 @@ func void* RingAllocator.alloc(RingAllocator *allocator, usize size) return data; } -func void* RingAllocator.realloc(RingAllocator *allocator, void* ptr, usize size) +fn void* RingAllocator.realloc(RingAllocator *allocator, void* ptr, usize size) { if (size > allocator.size) return null; assert(allocator.data >= ptr && ptr < allocator.data + size, "Realloc on other allocator."); @@ -159,22 +159,22 @@ macro malloc($Type) return ($Type*)(mem::alloc($sizeof($Type))); } -func void* alloc(usize size, usize count = 1) @inline +fn void* alloc(usize size, usize count = 1) @inline { return _malloc(size * count); } -func void* calloc(usize size, usize elements = 1) @inline +fn void* calloc(usize size, usize elements = 1) @inline { return _calloc(size, elements); } -func void* realloc(void *ptr, usize size) @inline +fn void* realloc(void *ptr, usize size) @inline { return _realloc(ptr, size); } -func void free(void* ptr) @inline +fn void free(void* ptr) @inline { _free(ptr); } @@ -194,7 +194,7 @@ SlotAllocator default_allocator = { .current_page = 0, }; -func void*! talloc(usize size) +fn void*! talloc(usize size) { return default_allocator.alloc(size); } \ No newline at end of file diff --git a/resources/rosettacode/antiprime.c3 b/resources/rosettacode/antiprime.c3 index 92322a3cc..1f7f52551 100644 --- a/resources/rosettacode/antiprime.c3 +++ b/resources/rosettacode/antiprime.c3 @@ -1,9 +1,9 @@ module antiprime; import std::io; -extern func int printf(char* message, ...); +extern fn int printf(char* message, ...); -func int countDivisors(int n) +fn int countDivisors(int n) { if (n < 2) return 1; int count = 2; @@ -14,7 +14,7 @@ func int countDivisors(int n) return count; } -func int main() +fn int main() { int maxDiv; int count; diff --git a/resources/rosettacode/helloworld.c3 b/resources/rosettacode/helloworld.c3 index c5a97c3de..c5cf38e46 100644 --- a/resources/rosettacode/helloworld.c3 +++ b/resources/rosettacode/helloworld.c3 @@ -1,6 +1,6 @@ import std::io; -func int main() +fn int main() { io::println("Hello world"); return 0; diff --git a/resources/testfragments/bigint.c3 b/resources/testfragments/bigint.c3 index cfa8174a7..870487ca0 100644 --- a/resources/testfragments/bigint.c3 +++ b/resources/testfragments/bigint.c3 @@ -13,7 +13,7 @@ public struct BigInt @opaque char sign; } -public func void BigInt.init(BigInt* bigInt) +public fn void BigInt.init(BigInt* bigInt) { bigInt.number = malloc(1); bigInt.number[0] = 0; @@ -21,7 +21,7 @@ public func void BigInt.init(BigInt* bigInt) bigInt.sign = 1; } -public func void BigInt.initFromString(BigInt* bigInt, char* str) +public fn void BigInt.initFromString(BigInt* bigInt, char* str) { uint size = strlen(str); bigInt.sign = 1; @@ -46,7 +46,7 @@ public func void BigInt.initFromString(BigInt* bigInt, char* str) bigInt.length = size; } -public func void BigInt.copyTo(BigInt* source, BigInt* target) +public fn void BigInt.copyTo(BigInt* source, BigInt* target) { target.number = realloc(target.number, source.length); target.sign = source.sign; @@ -54,12 +54,12 @@ public func void BigInt.copyTo(BigInt* source, BigInt* target) for (uint i = 0; i < target.length; i++) target.number[i] = source.number[i]; } -public func void BigInt.destroy(BigInt* bigInt) +public fn void BigInt.destroy(BigInt* bigInt) { free(bigInt.number); } -func void BigInt.addIgnoreSign(BigInt* a, BigInt* b, BigInt* result) +fn void BigInt.addIgnoreSign(BigInt* a, BigInt* b, BigInt* result) { uint length = @max(a.length, b.length) + 1; byte* res = malloc(length); @@ -98,7 +98,7 @@ func void BigInt.addIgnoreSign(BigInt* a, BigInt* b, BigInt* result) result.length = length; } -public func void BigInt.getMaxVal(BigInt* bigInt, uint* pos, int* val) +public fn void BigInt.getMaxVal(BigInt* bigInt, uint* pos, int* val) { for (uint i = bigInt.length; i > 0; i++) { @@ -113,7 +113,7 @@ public func void BigInt.getMaxVal(BigInt* bigInt, uint* pos, int* val) *val = 0; } -public func char BigInt.compare(BigInt* a, BigInt* b) +public fn char BigInt.compare(BigInt* a, BigInt* b) { if (a.sign != b.sign) return a.sign; byte aMax; @@ -130,7 +130,7 @@ public func char BigInt.compare(BigInt* a, BigInt* b) return 0; } -public func char BigInt.compareNoSign(BigInt* a, BigInt* b) +public fn char BigInt.compareNoSign(BigInt* a, BigInt* b) { byte aMax; uint aMaxPos; @@ -146,7 +146,7 @@ public func char BigInt.compareNoSign(BigInt* a, BigInt* b) return 0; } -func void BigInt.subIgnoreSign(BigInt* a, BigInt* b, BigInt* result) +fn void BigInt.subIgnoreSign(BigInt* a, BigInt* b, BigInt* result) { uint length = @max(a.length, b.length); byte* res = malloc(length); @@ -187,7 +187,7 @@ func void BigInt.subIgnoreSign(BigInt* a, BigInt* b, BigInt* result) result.length = length; } -public func void BigInt.add(BigInt* a, BigInt* b, BigInt* result) +public fn void BigInt.add(BigInt* a, BigInt* b, BigInt* result) { if (a.sign == b.sign) { @@ -205,7 +205,7 @@ public func void BigInt.add(BigInt* a, BigInt* b, BigInt* result) } } -public func char* BigInt.toCharArray(BigInt* bigInt) +public fn char* BigInt.toCharArray(BigInt* bigInt) { uint charLen = bigInt.length + 1 + (bigInt.sign < 0 ? 1 : 0); byte* out = malloc(charLen); @@ -227,7 +227,7 @@ public func char* BigInt.toCharArray(BigInt* bigInt) return out; } -public func void BigInt.print(BigInt* bigInt) +public fn void BigInt.print(BigInt* bigInt) { char* chars = bigInt.toCharArray(); puts(chars); @@ -244,7 +244,7 @@ public func void BigInt.fprint(BigInt* bigInt, FILE* file) }*/ -public func int main(int size, char** args) +public fn int main(int size, char** args) { BigInt minus2; BigInt minus1; diff --git a/resources/testfragments/casting.c3 b/resources/testfragments/casting.c3 index 144ef8562..3e04eeb7a 100644 --- a/resources/testfragments/casting.c3 +++ b/resources/testfragments/casting.c3 @@ -6,7 +6,7 @@ struct Pixmap int bpp; } -func void readpgm(char* name, Pixmap* p) +fn void readpgm(char* name, Pixmap* p) { /* ... */ pnm_readpaminit(fp, &inpam); @@ -28,7 +28,7 @@ func void readpgm(char* name, Pixmap* p) } } -func void getComm(uint len, char* src) +fn void getComm(uint len, char* src) { uint size; size = len - 2; @@ -36,7 +36,7 @@ func void getComm(uint len, char* src) memcpy(comm, src, size); } -func uint* decode_fh(uint* p, SvcFh* fhp) +fn uint* decode_fh(uint* p, SvcFh* fhp) { int size; fh_init(fhp, NFS3_FHSIZE); diff --git a/resources/testfragments/comparisons.c3 b/resources/testfragments/comparisons.c3 index 9356036e6..de4934cfd 100644 --- a/resources/testfragments/comparisons.c3 +++ b/resources/testfragments/comparisons.c3 @@ -1,6 +1,6 @@ module comparisons; -func void test_signed() +fn void test_signed() { int a = 0; int b = 1; @@ -14,7 +14,7 @@ func void test_signed() } -func void test_unsigned() +fn void test_unsigned() { uint a = 0; uint b = 1; @@ -28,9 +28,9 @@ func void test_unsigned() } -extern func void printf(char *s); +extern fn void printf(char *s); -func void test_signedunsigned() +fn void test_signedunsigned() { char a = 0 - 1; byte b = (byte)(a); @@ -100,7 +100,7 @@ func void test_signedunsigned() } -func void test_unsignedsigned() +fn void test_unsignedsigned() { int b = -1; uint a = (uint)(b); @@ -170,7 +170,7 @@ func void test_unsignedsigned() } -func void main() +fn void main() { test_signedunsigned(); test_unsignedsigned(); diff --git a/resources/testfragments/compilertest2.c3 b/resources/testfragments/compilertest2.c3 index 6a7c6951c..1176ff157 100644 --- a/resources/testfragments/compilertest2.c3 +++ b/resources/testfragments/compilertest2.c3 @@ -13,7 +13,7 @@ public struct BigInt @opaque char sign; } -public func void BigInt.init(BigInt& bigInt) +public fn void BigInt.init(BigInt& bigInt) { bigInt.number = malloc(1); bigInt.number[0] = 0; @@ -21,7 +21,7 @@ public func void BigInt.init(BigInt& bigInt) bigInt.sign = 1; } -public func void BigInt.initFromString(BigInt& bigInt, char& str) +public fn void BigInt.initFromString(BigInt& bigInt, char& str) { uint size = strlen(str); bigInt.sign = 1; @@ -46,14 +46,14 @@ public func void BigInt.initFromString(BigInt& bigInt, char& str) bigInt.length = size; } -public func BigInt& BigInt.newFromString(char& str) +public fn BigInt& BigInt.newFromString(char& str) { BigInt& bigInt = malloc(sizeof(BigInt)); bigInt.initFromString(str); return bigInt; } -public func void BigInt.copyTo(BigInt& source, BigInt& target) +public fn void BigInt.copyTo(BigInt& source, BigInt& target) { target.number = realloc(target.number, source.length); target.sign = source.sign; @@ -61,12 +61,12 @@ public func void BigInt.copyTo(BigInt& source, BigInt& target) for (uint i = 0; i < target.length; i++) target.number[i] = source.number[i]; } -public func void BigInt.destroy(BigInt& bigInt) +public fn void BigInt.destroy(BigInt& bigInt) { free(bigInt.number); } -func void BigInt.addIgnoreSign(BigInt& a, BigInt& b, BigInt& result) +fn void BigInt.addIgnoreSign(BigInt& a, BigInt& b, BigInt& result) { uint length = @max(a.length, b.length) + 1; byte* res = malloc(length); @@ -105,7 +105,7 @@ func void BigInt.addIgnoreSign(BigInt& a, BigInt& b, BigInt& result) result.length = length; } -public func void BigInt.getMaxVal(BigInt &bigInt, uint& pos, int& val) +public fn void BigInt.getMaxVal(BigInt &bigInt, uint& pos, int& val) { for (uint i = bigInt.length; i > 0; i++) { @@ -120,7 +120,7 @@ public func void BigInt.getMaxVal(BigInt &bigInt, uint& pos, int& val) *val = 0; } -public func char BigInt.compare(BigInt& a, BigInt& b) +public fn char BigInt.compare(BigInt& a, BigInt& b) { if (a.sign != b.sign) return a.sign; byte aMax; @@ -137,7 +137,7 @@ public func char BigInt.compare(BigInt& a, BigInt& b) return 0; } -public func char BigInt.compareNoSign(BigInt& a, BigInt& b) +public fn char BigInt.compareNoSign(BigInt& a, BigInt& b) { byte aMax; uint aMaxPos; @@ -153,7 +153,7 @@ public func char BigInt.compareNoSign(BigInt& a, BigInt& b) return 0; } -func void BigInt.subIgnoreSign(BigInt& a, BigInt& b, BigInt& result) +fn void BigInt.subIgnoreSign(BigInt& a, BigInt& b, BigInt& result) { uint length = @max(a.length, b.length); byte& res = malloc(length); @@ -194,7 +194,7 @@ func void BigInt.subIgnoreSign(BigInt& a, BigInt& b, BigInt& result) result.length = length; } -public func void BigInt.add(BigInt& a, BigInt& b, BigInt& result) +public fn void BigInt.add(BigInt& a, BigInt& b, BigInt& result) { if (a.sign == b.sign) { @@ -212,7 +212,7 @@ public func void BigInt.add(BigInt& a, BigInt& b, BigInt& result) } } -public func char* BigInt.toCharArray(BigInt* bigInt) +public fn char* BigInt.toCharArray(BigInt* bigInt) { uint charLen = bigInt.length + 1 + (bigInt.sign < 0 ? 1 : 0); byte* out = malloc(charLen); @@ -234,7 +234,7 @@ public func char* BigInt.toCharArray(BigInt* bigInt) return out; } -public func void BigInt.print(BigInt& bigInt) +public fn void BigInt.print(BigInt& bigInt) { char* chars = bigInt.toCharArray(); puts(chars); @@ -251,7 +251,7 @@ public func void BigInt.fprint(BigInt* bigInt, FILE* file) }*/ -public func int main(int size, char*& args) +public fn int main(int size, char*& args) { BigInt minus2; BigInt minus1; diff --git a/resources/testfragments/compiletest.c3 b/resources/testfragments/compiletest.c3 index a39232ba3..fbb264b44 100644 --- a/resources/testfragments/compiletest.c3 +++ b/resources/testfragments/compiletest.c3 @@ -5,7 +5,7 @@ int bob = 'HELO'; typedef Foo* as Bob; -func void testdefer(int x) +fn void testdefer(int x) { defer printf("A"); defer @@ -67,7 +67,7 @@ struct Simple int i; double j; } -func int boo() +fn int boo() { Zed zfe; Simple s = { 1 }; @@ -148,11 +148,11 @@ func int boo() return 1; } -func int helo(int i) +fn int helo(int i) { return i + 1; } -func void while_test() +fn void while_test() { int a = 10; @@ -164,7 +164,7 @@ func void while_test() } } -func void test() +fn void test() { int a = 10; while (1) @@ -183,7 +183,7 @@ func void test() return; } -func void main() +fn void main() { helo(2); printf("Helo\n"); diff --git a/resources/testfragments/demo1.c3 b/resources/testfragments/demo1.c3 index 2ad90856c..d0f68f83a 100644 --- a/resources/testfragments/demo1.c3 +++ b/resources/testfragments/demo1.c3 @@ -1,8 +1,8 @@ module demo1; // Use C functions directly. -extern func int printf(char *, ...); -extern func void puts(char *); +extern fn int printf(char *, ...); +extern fn void puts(char *); struct Foo { @@ -10,7 +10,7 @@ struct Foo int b; } -func Foo createFoo(int a, int b = 10) +fn Foo createFoo(int a, int b = 10) { // Compound initializer return Foo({a, b}); @@ -23,7 +23,7 @@ struct Bar } -func void testStruct() +fn void testStruct() { // Default arguments Foo foo = createFoo(100); @@ -47,17 +47,17 @@ func void testStruct() } -func int Bar.add(Bar* b) +fn int Bar.add(Bar* b) { return b.x + b.y; } -func int Foo.mult(Foo* f) +fn int Foo.mult(Foo* f) { return f.a * f.b; } -func void printArray(int[] array) +fn void printArray(int[] array) { printf("["); foreach (i, a : array) @@ -69,7 +69,7 @@ func void printArray(int[] array) } -func void testArrays() +fn void testArrays() { int[5] x = { [0] = 100, [1..2] = 4 }; puts("Testing arrays---"); @@ -118,7 +118,7 @@ func void testArrays() printf("Pointer to array: %p\nPointer to slice: %p\nPointer to first element of slice: %p\n", z, &y, &y[0]); } -func void testExpressionBlocks() +fn void testExpressionBlocks() { int x = {| int j = 0; @@ -144,7 +144,7 @@ func void testExpressionBlocks() } } -func void main() +fn void main() { testStruct(); testArrays(); diff --git a/resources/testfragments/file1.c3 b/resources/testfragments/file1.c3 index 355e8ed3f..aee7ad3bd 100644 --- a/resources/testfragments/file1.c3 +++ b/resources/testfragments/file1.c3 @@ -11,7 +11,7 @@ struct Foo //define bar::blub(Foo, 1) as fooblub; -public func void main() +public fn void main() { Foo f = { 3, 4 }; //Foo g = fooblub(&f); diff --git a/resources/testfragments/file2.c3 b/resources/testfragments/file2.c3 index 95a078c2f..04f9711d0 100644 --- a/resources/testfragments/file2.c3 +++ b/resources/testfragments/file2.c3 @@ -1,6 +1,6 @@ module bar(Type, i); -public func Type blub(Type type) +public fn Type blub(Type type) { type.x = i; return type; diff --git a/resources/testfragments/helloworld.c3 b/resources/testfragments/helloworld.c3 index 72003c07d..c90954156 100644 --- a/resources/testfragments/helloworld.c3 +++ b/resources/testfragments/helloworld.c3 @@ -1,8 +1,8 @@ module helloworld; -extern func void printf(char *str, ...); +extern fn void printf(char *str, ...); -func void main() +fn void main() { printf("Hello World!\n"); } \ No newline at end of file diff --git a/resources/testfragments/lexertest.c3 b/resources/testfragments/lexertest.c3 index bb402ac10..5df2d1517 100644 --- a/resources/testfragments/lexertest.c3 +++ b/resources/testfragments/lexertest.c3 @@ -11,7 +11,7 @@ struct Boo }; } -func void test() +fn void test() { int i = 0; i++; diff --git a/resources/testfragments/parsertest.c3 b/resources/testfragments/parsertest.c3 index 31f671b22..7051223bf 100644 --- a/resources/testfragments/parsertest.c3 +++ b/resources/testfragments/parsertest.c3 @@ -68,7 +68,7 @@ error Errors OTHER_ERROR } -func Foom test(int a) +fn Foom test(int a) { while (int x = 0, int y = 3; int y = foo()) { @@ -85,7 +85,7 @@ func Foom test(int a) return 1 + 2; } -func boo::Bar zab::Baz.sd(die::Eij i) throws Zab // , sij:Zig +fn boo::Bar zab::Baz.sd(die::Eij i) throws Zab // , sij:Zig { float a = 0, b = 3, double c = 1, d; int i = 0; @@ -111,20 +111,20 @@ generic boor2(i) $if ($e > 0) { - func void foo() {} + fn void foo() {} } $elif ($e < 0) { - func void foo() { printf("HELO"); } + fn void foo() { printf("HELO"); } } $else { - func void foo() { printf("OLEH"); } + fn void foo() { printf("OLEH"); } } $if ($e > 0) { - func void foo() {} + fn void foo() {} } $if ($b > 0) @@ -151,7 +151,7 @@ generic boofer2(i, g, eok) -func void hello() throws Errors +fn void hello() throws Errors { int i, j; throw FOO; @@ -229,11 +229,11 @@ func void hello() throws Errors } typedef Foo* as Bar; -typedef func void(int, Foo*) as Zoo; +typedef fn void(int, Foo*) as Zoo; -func void test2() +fn void test2() { return; } \ No newline at end of file diff --git a/resources/testfragments/sdl2.c3 b/resources/testfragments/sdl2.c3 index 0b6446890..dfe349d17 100644 --- a/resources/testfragments/sdl2.c3 +++ b/resources/testfragments/sdl2.c3 @@ -26,11 +26,11 @@ void* gWindow = null; void* gScreenSurface = null; -extern func int init(uint flags) @extname("SDL_Init"); -extern func int initSubSystem(uint flags) @extname("SDL_InitSubSystem"); -extern func void quitSubSystem(uint flags) @extname("SDL_QuitSubSystem"); -extern func uint wasInit(uint flags) @extname("SDL_WasInit"); -extern func void quit() @extname("SDL_Quit"); +extern fn int init(uint flags) @extname("SDL_Init"); +extern fn int initSubSystem(uint flags) @extname("SDL_InitSubSystem"); +extern fn void quitSubSystem(uint flags) @extname("SDL_QuitSubSystem"); +extern fn uint wasInit(uint flags) @extname("SDL_WasInit"); +extern fn void quit() @extname("SDL_Quit"); enum SDLWindowFlags : c_int { @@ -59,13 +59,13 @@ enum SDLWindowFlags : c_int VULKAN = 0x10000000 /**< window usable for Vulkan surface */ } -extern func void* createWindow(char *title, uint x, uint y, int w, int h, uint flags) @extname("SDL_CreateWindow"); -extern func void* getWindowSurface(void *window) @extname("SDL_GetWindowSurface"); +extern fn void* createWindow(char *title, uint x, uint y, int w, int h, uint flags) @extname("SDL_CreateWindow"); +extern fn void* getWindowSurface(void *window) @extname("SDL_GetWindowSurface"); const uint WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; -extern func int exit(int code); -extern func int printf(char *mess, ...); +extern fn int exit(int code); +extern fn int printf(char *mess, ...); -func bool initX() +fn bool initX() { //Initialization flag bool success = true; @@ -86,7 +86,7 @@ func bool initX() } -func void close() +fn void close() { //Destroy window // SDL_DestroyWindow( gWindow ); @@ -96,8 +96,8 @@ func void close() quit(); } -extern func int pollEvent(SDL_Event *event) @extname("SDL_PollEvent"); -extern func int updateWindowSurface(void *window) @extname("SDL_UpdateWindowSurface"); +extern fn int pollEvent(SDL_Event *event) @extname("SDL_PollEvent"); +extern fn int updateWindowSurface(void *window) @extname("SDL_UpdateWindowSurface"); enum SDLEventType : uint { @@ -223,7 +223,7 @@ union SDL_Event const uint SDL_QUIT = 0x100; -func int main(int argc, char** args) +fn int main(int argc, char** args) { initX(); //Main loop flag diff --git a/resources/testfragments/test.c3 b/resources/testfragments/test.c3 index 5efd5ce4f..0baa2e5dc 100644 --- a/resources/testfragments/test.c3 +++ b/resources/testfragments/test.c3 @@ -1,6 +1,6 @@ import std::io; -extern func int printf(char* message, ...); +extern fn int printf(char* message, ...); macro void swap(&a, &b) { @@ -9,7 +9,7 @@ macro void swap(&a, &b) b = temp; } -func void main() +fn void main() { int x = 1; int y = 2; diff --git a/resources/testfragments/test_break.c3 b/resources/testfragments/test_break.c3 index 8e663aed7..69a3d7cb8 100644 --- a/resources/testfragments/test_break.c3 +++ b/resources/testfragments/test_break.c3 @@ -1,10 +1,10 @@ module foo; -extern func void printf(char *hello, ...); +extern fn void printf(char *hello, ...); error MyError; error YourError; -func void main() +fn void main() { int! i = 1; catch (i) diff --git a/resources/testfragments/testdefer.c3 b/resources/testfragments/testdefer.c3 index 6c41f682d..ae332cd78 100644 --- a/resources/testfragments/testdefer.c3 +++ b/resources/testfragments/testdefer.c3 @@ -1,19 +1,19 @@ -extern func void printf(char* message, ...); +extern fn void printf(char* message, ...); -public func void defer1() {} -public func void defer2() {} -public func void defer3() {} -public func void defer4() {} -public func void defer5() {} -public func void defer6() {} -public func void defer7() {} -public func void defer8() {} -public func void defer9() {} -public func void defer10() {} -public func void defer11() {} +public fn void defer1() {} +public fn void defer2() {} +public fn void defer3() {} +public fn void defer4() {} +public fn void defer5() {} +public fn void defer6() {} +public fn void defer7() {} +public fn void defer8() {} +public fn void defer9() {} +public fn void defer10() {} +public fn void defer11() {} -public func int main(int argc) +public fn int main(int argc) { int a = 0; { diff --git a/resources/testfragments/tmem.c3 b/resources/testfragments/tmem.c3 index d5001acc3..cbf440616 100644 --- a/resources/testfragments/tmem.c3 +++ b/resources/testfragments/tmem.c3 @@ -10,7 +10,7 @@ struct String char* ptr; } -func void String.init(String *s, char[] c) +fn void String.init(String *s, char[] c) { s.capacity = c.len + 16; s.ptr = mem::_malloc(s.capacity); @@ -18,7 +18,7 @@ func void String.init(String *s, char[] c) mem::copy(s.ptr, (char*)(c), c.len); } -func char* String.zstr(String *s) +fn char* String.zstr(String *s) { char* c = mem::_malloc(s.len + 1); mem::copy(c, s.ptr, s.len); @@ -26,7 +26,7 @@ func char* String.zstr(String *s) return c; } -func void String.appendc(String *s, char c) +fn void String.appendc(String *s, char c) { if (s.capacity == s.len) { @@ -38,7 +38,7 @@ func void String.appendc(String *s, char c) s.ptr[s.len++] = c; } -func void String.append(String *s, char[] other_string) +fn void String.append(String *s, char[] other_string) { if (s.capacity < s.len + other_string.len) { @@ -55,7 +55,7 @@ func void String.append(String *s, char[] other_string) s.len += other_string.len; } -func void String.concat(String *s, String* other_string) +fn void String.concat(String *s, String* other_string) { if (s.capacity < s.len + other_string.len) { @@ -72,7 +72,7 @@ func void String.concat(String *s, String* other_string) s.len += other_string.len; } -func void main() +fn void main() { String s; s.init("Hello"); diff --git a/resources/testfragments/toposort.c3 b/resources/testfragments/toposort.c3 index 44fa8dc7f..afdb1f0d3 100644 --- a/resources/testfragments/toposort.c3 +++ b/resources/testfragments/toposort.c3 @@ -2,7 +2,7 @@ module topologicalsort; import std::mem; import std::array; -extern func void printf(char* x, ...); +extern fn void printf(char* x, ...); struct InputPair { @@ -23,7 +23,7 @@ struct TopoList } -func void sort(InputPair[] pairs, uint elements) +fn void sort(InputPair[] pairs, uint elements) { InputPair[] result = @array::make(InputPair, pairs.len); TopoList* top = @array::make(TopoList, elements); @@ -70,7 +70,7 @@ func void sort(InputPair[] pairs, uint elements) } } -func void main() +fn void main() { InputPair[10] pairs = { { 9, 2 }, diff --git a/resources/testproject/bar.c3 b/resources/testproject/bar.c3 index 57f3aca7b..de4a1cd67 100644 --- a/resources/testproject/bar.c3 +++ b/resources/testproject/bar.c3 @@ -3,7 +3,7 @@ module bar; import baz::foo; import testbaz::zab; -func void test() +fn void test() { Foo x; baz::foo::test(); diff --git a/resources/testproject/foo.c3 b/resources/testproject/foo.c3 index d12d25903..082f06080 100644 --- a/resources/testproject/foo.c3 +++ b/resources/testproject/foo.c3 @@ -7,14 +7,14 @@ struct Foo int a; } -extern func void printf(char *hello); +extern fn void printf(char *hello); -private func void ofke() +private fn void ofke() {} -private func void exple() {} +private fn void exple() {} -func void test() +fn void test() { printf("Hello from baz::foo::test()!\n"); } \ No newline at end of file diff --git a/resources/testproject/hello_world.c3 b/resources/testproject/hello_world.c3 index 662269858..6ad121883 100644 --- a/resources/testproject/hello_world.c3 +++ b/resources/testproject/hello_world.c3 @@ -1,9 +1,9 @@ module hello_world; import bar; -extern func void printf(char *hello); +extern fn void printf(char *hello); -func int main(int x) +fn int main(int x) { printf("Hello World!\n"); bar::test(); diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 688de084b..af8aaeab8 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -365,6 +365,7 @@ typedef struct VarDecl_ bool unwrap : 1; bool vararg : 1; bool is_static : 1; + bool is_threadglobal : 1; TypeInfo *type_info; union { diff --git a/src/compiler/enums.h b/src/compiler/enums.h index e9fc77fc0..4e926bc98 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -442,6 +442,7 @@ typedef enum TOKEN_FN, TOKEN_FUNC, TOKEN_GENERIC, + TOKEN_GLOBAL, TOKEN_IF, TOKEN_IMPORT, TOKEN_MACRO, diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index f1f15ff48..c829320bf 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -363,6 +363,8 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl) // TODO fix name LLVMValueRef old = decl->backend_ref; decl->backend_ref = LLVMAddGlobal(c->module, LLVMTypeOf(init_value), decl->extname ? decl->extname : decl->external_name); + bool thread_local = !decl->var.is_threadglobal && decl->var.kind != VARDECL_CONST; + LLVMSetThreadLocal(decl->backend_ref, thread_local); if (decl->section) { LLVMSetSection(decl->backend_ref, decl->section); @@ -373,6 +375,7 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl) if (failable_ref) { llvm_set_alignment(failable_ref, type_alloca_alignment(type_anyerr)); + LLVMSetThreadLocal(failable_ref, thread_local); } if (init_expr && IS_FAILABLE(init_expr) && init_expr->expr_kind == EXPR_FAILABLE) { diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index 77099de35..797c52810 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -73,16 +73,13 @@ void recover_top_level(Context *context) switch (context->tok.type) { case TOKEN_PRIVATE: - case TOKEN_STRUCT: case TOKEN_IMPORT: - case TOKEN_UNION: case TOKEN_EXTERN: case TOKEN_ENUM: case TOKEN_GENERIC: case TOKEN_ATTRIBUTE: case TOKEN_DEFINE: case TOKEN_ERRTYPE: - case TOKEN_BITSTRUCT: return; case TOKEN_IDENT: // Incr arrays only case TOKEN_CONST: @@ -95,6 +92,9 @@ void recover_top_level(Context *context) case TOKEN_CT_SWITCH: case TOKEN_FUNC: case TOKEN_FN: + case TOKEN_STRUCT: + case TOKEN_UNION: + case TOKEN_BITSTRUCT: case TYPELIKE_TOKENS: // Only recover if this is in the first col. if (TOKLOC(context->tok)->col == 1) return; @@ -805,7 +805,8 @@ Decl *parse_decl(Context *context) return parse_const_declaration(context, VISIBLE_LOCAL); } - bool is_static = try_consume(context, TOKEN_STATIC); + bool is_threadglobal = try_consume(context, TOKEN_GLOBAL); + bool is_static = !is_threadglobal && try_consume(context, TOKEN_STATIC); ASSIGN_TYPE_ELSE(TypeInfo *type, parse_failable_type(context), poisoned_decl); @@ -815,7 +816,8 @@ Decl *parse_decl(Context *context) SEMA_ERROR(decl, "You cannot use unwrap with a failable variable."); return poisoned_decl; } - decl->var.is_static = is_static; + decl->var.is_static = is_static || is_threadglobal; + decl->var.is_threadglobal = is_threadglobal; return decl; } @@ -1009,9 +1011,9 @@ bool parse_attributes(Context *context, Attr ***attributes_ref) /** * global_declaration - * : failable_type IDENT ';' - * | failable_type IDENT '=' expression ';' - * | failable_type func_definition + * : global? failable_type IDENT ';' + * | global? failable_type IDENT '=' expression ';' + * | global? failable_type func_definition * ; * * @param visibility @@ -1019,10 +1021,14 @@ bool parse_attributes(Context *context, Attr ***attributes_ref) */ static inline Decl *parse_global_declaration(Context *context, Visibility visibility) { + bool thread_global = try_consume(context, TOKEN_GLOBAL); + ASSIGN_TYPE_ELSE(TypeInfo *type, parse_failable_type(context), poisoned_decl); Decl *decl = decl_new_var(context->tok.id, type, VARDECL_GLOBAL, visibility); + decl->var.is_threadglobal = thread_global; + if (TOKEN_IS(TOKEN_CONST_IDENT)) { SEMA_TOKEN_ERROR(context->tok, "This looks like a constant variable, did you forget 'const'?"); @@ -2360,6 +2366,7 @@ Decl *parse_top_level_statement(Context *context) case TOKEN_IMPORT: SEMA_TOKEN_ERROR(context->tok, "Imports are only allowed directly after the module declaration."); return poisoned_decl; + case TOKEN_GLOBAL: case TYPELIKE_TOKENS: { ASSIGN_DECL_ELSE(decl, parse_global_declaration(context, visibility), poisoned_decl); diff --git a/src/compiler/parse_stmt.c b/src/compiler/parse_stmt.c index ddb1f821e..4d6dd7ad4 100644 --- a/src/compiler/parse_stmt.c +++ b/src/compiler/parse_stmt.c @@ -800,6 +800,7 @@ Ast *parse_stmt(Context *context) return parse_decl_or_expr_stmt(context); case TOKEN_VAR: return parse_var_stmt(context); + case TOKEN_GLOBAL: // Global means declaration! case TOKEN_STATIC: // Static means declaration! case TOKEN_CONST: // Const means declaration! return parse_declaration_stmt(context); diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 33621f699..b794967df 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -1847,6 +1847,7 @@ static bool sema_analyse_body_expansion(Context *context, Expr *call) assert(macro); assert(macro->macro_decl.block_parameter.index); + // TODO handle named arguments ExprCall *call_expr = &call->call_expr; if (vec_size(call_expr->body_arguments)) { diff --git a/src/compiler/tokens.c b/src/compiler/tokens.c index 825751821..2e47bad72 100644 --- a/src/compiler/tokens.c +++ b/src/compiler/tokens.c @@ -236,6 +236,8 @@ const char *token_type_to_string(TokenType type) return "func"; case TOKEN_GENERIC: return "generic"; + case TOKEN_GLOBAL: + return "global"; case TOKEN_IF: return "if"; case TOKEN_IMPORT: diff --git a/test/test_suite/abi/literal_load.c3t b/test/test_suite/abi/literal_load.c3t index b1bb284b2..940b9702f 100644 --- a/test/test_suite/abi/literal_load.c3t +++ b/test/test_suite/abi/literal_load.c3t @@ -7,9 +7,9 @@ struct Test Test foo = {}; -extern func void blorg(Test t); +extern fn void blorg(Test t); -func Test creator() +fn Test creator() { blorg(Test{}); return Test{}; diff --git a/test/test_suite/abi/literal_load_aarch64.c3t b/test/test_suite/abi/literal_load_aarch64.c3t index 5c98595be..eced81adc 100644 --- a/test/test_suite/abi/literal_load_aarch64.c3t +++ b/test/test_suite/abi/literal_load_aarch64.c3t @@ -8,9 +8,9 @@ struct Test Test foo = {}; -extern func void blorg(Test t); +extern fn void blorg(Test t); -func Test creator() +fn Test creator() { blorg(Test{}); return Test{}; diff --git a/test/test_suite/abi/literal_load_mingw.c3t b/test/test_suite/abi/literal_load_mingw.c3t index a2c10c7bd..3fbc2fc7d 100644 --- a/test/test_suite/abi/literal_load_mingw.c3t +++ b/test/test_suite/abi/literal_load_mingw.c3t @@ -8,9 +8,9 @@ struct Test Test foo = {}; -extern func void blorg(Test t); +extern fn void blorg(Test t); -func Test creator() +fn Test creator() { blorg(Test{}); return Test{}; diff --git a/test/test_suite/abi/pass_large_aarch.c3t b/test/test_suite/abi/pass_large_aarch.c3t index 300f94132..fbd453355 100644 --- a/test/test_suite/abi/pass_large_aarch.c3t +++ b/test/test_suite/abi/pass_large_aarch.c3t @@ -8,9 +8,9 @@ struct Large void*[8] pointers; } -extern func void pass_large(Large large); +extern fn void pass_large(Large large); -func void example() +fn void example() { Large l = {}; pass_large(l); diff --git a/test/test_suite/abi/test_sret.c3t b/test/test_suite/abi/test_sret.c3t index fbdbf12de..f841c8423 100644 --- a/test/test_suite/abi/test_sret.c3t +++ b/test/test_suite/abi/test_sret.c3t @@ -8,10 +8,10 @@ struct Abc { long e; } -extern func Abc foo1(); -extern func Abc foo2(); +extern fn Abc foo1(); +extern fn Abc foo2(); -func void bar() { +fn void bar() { Abc dummy1 = foo1(); Abc dummy2 = foo2(); } diff --git a/test/test_suite/abi/union_x64.c3t b/test/test_suite/abi/union_x64.c3t index 5ecdc0374..af583bde9 100644 --- a/test/test_suite/abi/union_x64.c3t +++ b/test/test_suite/abi/union_x64.c3t @@ -7,9 +7,9 @@ union Foo long a; char[12] b; } -extern func void hello2(Foo f); +extern fn void hello2(Foo f); -func void hello(Foo f) +fn void hello(Foo f) { hello2(f); } diff --git a/test/test_suite/abi/vec2_aarch64.c3t b/test/test_suite/abi/vec2_aarch64.c3t index fd56ddf0f..9e6dc33ba 100644 --- a/test/test_suite/abi/vec2_aarch64.c3t +++ b/test/test_suite/abi/vec2_aarch64.c3t @@ -5,12 +5,12 @@ struct Vector2 { float x; float y; } -extern func Vector2 vector2_zero() { return Vector2 {}; } -extern func Vector2 vector2_one() { return Vector2 {}; } -extern func Vector2 vector2_add(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern func Vector2 vector2_add_value(Vector2 v, float add) { return Vector2 {}; } -extern func Vector2 vector2_subtract(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern func Vector2 vector2_subtract_value(Vector2 v, float sub) { return Vector2 {}; } +extern fn Vector2 vector2_zero() { return Vector2 {}; } +extern fn Vector2 vector2_one() { return Vector2 {}; } +extern fn Vector2 vector2_add(Vector2 v1, Vector2 v2) { return Vector2 {}; } +extern fn Vector2 vector2_add_value(Vector2 v, float add) { return Vector2 {}; } +extern fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) { return Vector2 {}; } +extern fn Vector2 vector2_subtract_value(Vector2 v, float sub) { return Vector2 {}; } // #expect: abi.ll %Vector2 = type { float, float } diff --git a/test/test_suite/abi/vec2_x64.c3t b/test/test_suite/abi/vec2_x64.c3t index 196484740..e5bf7e0dd 100644 --- a/test/test_suite/abi/vec2_x64.c3t +++ b/test/test_suite/abi/vec2_x64.c3t @@ -5,12 +5,12 @@ struct Vector2 { float x; float y; } -extern func Vector2 vector2_zero() { return Vector2 {}; } -extern func Vector2 vector2_one() { return Vector2 {}; } -extern func Vector2 vector2_add(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern func Vector2 vector2_add_value(Vector2 v, float add) { return Vector2 {}; } -extern func Vector2 vector2_subtract(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern func Vector2 vector2_subtract_value(Vector2 v, float sub) { return Vector2 {}; } +extern fn Vector2 vector2_zero() { return Vector2 {}; } +extern fn Vector2 vector2_one() { return Vector2 {}; } +extern fn Vector2 vector2_add(Vector2 v1, Vector2 v2) { return Vector2 {}; } +extern fn Vector2 vector2_add_value(Vector2 v, float add) { return Vector2 {}; } +extern fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) { return Vector2 {}; } +extern fn Vector2 vector2_subtract_value(Vector2 v, float sub) { return Vector2 {}; } // #expect: abi.ll diff --git a/test/test_suite/arrays/array_casts.c3t b/test/test_suite/arrays/array_casts.c3t index db777181b..5d2930b6c 100644 --- a/test/test_suite/arrays/array_casts.c3t +++ b/test/test_suite/arrays/array_casts.c3t @@ -1,7 +1,7 @@ module array_casts; -func void test() +fn void test() { int[3] x; int *y = &x; diff --git a/test/test_suite/arrays/array_invalid_casts.c3 b/test/test_suite/arrays/array_invalid_casts.c3 index d58930909..a197e4fd3 100644 --- a/test/test_suite/arrays/array_invalid_casts.c3 +++ b/test/test_suite/arrays/array_invalid_casts.c3 @@ -1,11 +1,11 @@ -func void test() +fn void test() { int[3] x; double *y = &x; // #error: 'int[3]*' to 'double* } -func void test2() +fn void test2() { int[3] x; double[] z = &x; // #error: 'int[3]*' into 'double[]' diff --git a/test/test_suite/arrays/array_literal.c3t b/test/test_suite/arrays/array_literal.c3t index 53933cfb4..9d343d267 100644 --- a/test/test_suite/arrays/array_literal.c3t +++ b/test/test_suite/arrays/array_literal.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin module array_literal; -func double test(uint x) +fn double test(uint x) { double[30] student_t = { 0.0 , 12.706 , 4.303 , 3.182 , 2.776 , 2.571 , 2.447 , 2.365 , 2.306 , 2.262 , 2.228 , diff --git a/test/test_suite/arrays/array_struct.c3t b/test/test_suite/arrays/array_struct.c3t index 304ec68ea..d585a07f6 100644 --- a/test/test_suite/arrays/array_struct.c3t +++ b/test/test_suite/arrays/array_struct.c3t @@ -6,7 +6,7 @@ struct Foo int x, y; } -private Foo[10] array; +private global Foo[10] array; // #expect: test.ll diff --git a/test/test_suite/arrays/complex_array_const.c3t b/test/test_suite/arrays/complex_array_const.c3t index c5a387497..a532ff7dd 100644 --- a/test/test_suite/arrays/complex_array_const.c3t +++ b/test/test_suite/arrays/complex_array_const.c3t @@ -8,7 +8,7 @@ struct Connection long length; } -private Connection[3] link +private global Connection[3] link = { {1, "link1", 10}, {2, "link2", 20}, {3, "link3", 30} }; diff --git a/test/test_suite/arrays/global_array_non_const.c3 b/test/test_suite/arrays/global_array_non_const.c3 index f31803328..7f6512ea8 100644 --- a/test/test_suite/arrays/global_array_non_const.c3 +++ b/test/test_suite/arrays/global_array_non_const.c3 @@ -8,7 +8,7 @@ int[B] c2; // #error: Expected an integer size. int non_constant = 10; int[non_constant] b; // #error: Expected a constant value as -func int foo() +fn int foo() { return 10; } diff --git a/test/test_suite/arrays/slice.c3 b/test/test_suite/arrays/slice.c3 index b9b9d5475..6d12e07c3 100644 --- a/test/test_suite/arrays/slice.c3 +++ b/test/test_suite/arrays/slice.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { int[3] x = { 1, 2, 3 }; int[] z = &x; diff --git a/test/test_suite/assert/assert_variants.c3t b/test/test_suite/assert/assert_variants.c3t index 029aa0959..58c9807c0 100644 --- a/test/test_suite/assert/assert_variants.c3t +++ b/test/test_suite/assert/assert_variants.c3t @@ -1,11 +1,11 @@ // #target: x64-windows -func int foo() +fn int foo() { return 1; } -func void test() +fn void test() { int x = foo(); int y = foo(); diff --git a/test/test_suite/assert/local_static_assert_not_constant.c3 b/test/test_suite/assert/local_static_assert_not_constant.c3 index 0f13c8202..cc02a64ca 100644 --- a/test/test_suite/assert/local_static_assert_not_constant.c3 +++ b/test/test_suite/assert/local_static_assert_not_constant.c3 @@ -1,19 +1,19 @@ int x = 3; -func void test() +fn void test() { $assert(x == 3); // #error: Compile time evaluation requires a compile time constant value. } -func void test2() +fn void test2() { int i = 0; $assert(1); $assert(i == 0); // #error: Compile time evaluation requires a compile time constant value. } -func int foo(); -func void test3() +fn int foo(); +fn void test3() { int i = 0; $assert(foo() == 0); // #error: Compile time evaluation requires a compile time constant value. diff --git a/test/test_suite/assert/static_assert.c3 b/test/test_suite/assert/static_assert.c3 index 2a139c833..a49691433 100644 --- a/test/test_suite/assert/static_assert.c3 +++ b/test/test_suite/assert/static_assert.c3 @@ -1,7 +1,7 @@ const int FOO = 2; -func void test() +fn void test() { $assert(FOO == 2, "Bad"); $assert(FOO == 0, "Good"); // #error: Compile time assert - Good diff --git a/test/test_suite/assert/unreachable.c3t b/test/test_suite/assert/unreachable.c3t index 115459fb3..197b6c65c 100644 --- a/test/test_suite/assert/unreachable.c3t +++ b/test/test_suite/assert/unreachable.c3t @@ -1,10 +1,10 @@ -func int foo() +fn int foo() { return 1; } -func void test() +fn void test() { int x = foo(); if (x > 0) return; diff --git a/test/test_suite/assignment/int_assign.c3t b/test/test_suite/assignment/int_assign.c3t index d32e2680c..0160df514 100644 --- a/test/test_suite/assignment/int_assign.c3t +++ b/test/test_suite/assignment/int_assign.c3t @@ -1,6 +1,6 @@ module test; -func int foo() +fn int foo() { int x = 0; int y; diff --git a/test/test_suite/attributes/repeat_of_attributes.c3 b/test/test_suite/attributes/repeat_of_attributes.c3 index 2e5f323d0..2729e1ccf 100644 --- a/test/test_suite/attributes/repeat_of_attributes.c3 +++ b/test/test_suite/attributes/repeat_of_attributes.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { for (int a @align(16) @align(16) = 0 ; a < 10; a++) // #error: Repeat of attribute 'align' { diff --git a/test/test_suite/cast/cast_ok.c3 b/test/test_suite/cast/cast_ok.c3 index a90fc4d69..8ce12894c 100644 --- a/test/test_suite/cast/cast_ok.c3 +++ b/test/test_suite/cast/cast_ok.c3 @@ -1,11 +1,11 @@ struct Foo { int a; } -func void test4() +fn void test4() { int x = (int)(32); } -func void test5() +fn void test5() { Foo x = (Foo)(Foo{32}); } \ No newline at end of file diff --git a/test/test_suite/cast/cast_parse_fails.c3 b/test/test_suite/cast/cast_parse_fails.c3 index bc444c41c..e52fbad02 100644 --- a/test/test_suite/cast/cast_parse_fails.c3 +++ b/test/test_suite/cast/cast_parse_fails.c3 @@ -1,11 +1,11 @@ struct Foo { int a; } -func void test2() +fn void test2() { int x = int{ 32 }; // #error: 'int' cannot use compound literal initialization, did you intend to use a cast } -func void test3() +fn void test3() { int x = int(32); // #error: A type cannot be followed by (), if you intended a cast, use (type)(expression) } diff --git a/test/test_suite/cast/cast_parse_fails2.c3 b/test/test_suite/cast/cast_parse_fails2.c3 index 0d1a5a8c9..c5e2e3a0f 100644 --- a/test/test_suite/cast/cast_parse_fails2.c3 +++ b/test/test_suite/cast/cast_parse_fails2.c3 @@ -1,7 +1,7 @@ struct Foo { int a; } -func void test1() +fn void test1() { Foo({ 32 }); (Foo)({ 32 }); // #error: Unexpected start of a block '{' here. If you intended a compound literal diff --git a/test/test_suite/cast/cast_struct.c3 b/test/test_suite/cast/cast_struct.c3 index 594a1cce0..d3a4addfc 100644 --- a/test/test_suite/cast/cast_struct.c3 +++ b/test/test_suite/cast/cast_struct.c3 @@ -22,7 +22,7 @@ struct BazTwo int e; } -func void test() +fn void test() { Foo x; Bar y = (Bar)(x); diff --git a/test/test_suite/cast/cast_struct_fails.c3 b/test/test_suite/cast/cast_struct_fails.c3 index 9749d7b8c..244ae1cfc 100644 --- a/test/test_suite/cast/cast_struct_fails.c3 +++ b/test/test_suite/cast/cast_struct_fails.c3 @@ -22,12 +22,12 @@ struct BazTwo int e; } -func void test1() +fn void test1() { Foo x; Bar z = (Baz)(x); // #error: cast 'Foo' to 'Baz' } -func void test2() +fn void test2() { Baz x; BazTwo z = (BazTwo)(x); // #error: cast 'Baz' to 'BazTwo' diff --git a/test/test_suite/cast/cast_to_failable.c3 b/test/test_suite/cast/cast_to_failable.c3 index 99d18f6d5..dc1e8620b 100644 --- a/test/test_suite/cast/cast_to_failable.c3 +++ b/test/test_suite/cast/cast_to_failable.c3 @@ -3,7 +3,7 @@ errtype MyErr FOO } -func void test() +fn void test() { int! x; int! d = ($typeof(MyErr.FOO!))(x); // #error: Casting to a failable type is not allowed diff --git a/test/test_suite/comments/simple_comments.c3 b/test/test_suite/comments/simple_comments.c3 index eeb0b294b..ded9afc18 100644 --- a/test/test_suite/comments/simple_comments.c3 +++ b/test/test_suite/comments/simple_comments.c3 @@ -7,7 +7,7 @@ module comments; Multiline span style */ -func void test() +fn void test() { return; } diff --git a/test/test_suite/compile_time/compile_time_ptr_ref.c3t b/test/test_suite/compile_time/compile_time_ptr_ref.c3t index 404ed8405..da64ee139 100644 --- a/test/test_suite/compile_time/compile_time_ptr_ref.c3t +++ b/test/test_suite/compile_time/compile_time_ptr_ref.c3t @@ -2,12 +2,12 @@ module test; -int*[] blurp = { &ptr, &ptr, (&ptr + 1), &ptr - 1, (int*)((iptr)(&ptr) - 4) }; -int* c = (int*)((iptr)(&ptr) - 4); -int* c2 = (int*)((iptr)(&ptr) + 4); -int* c3 = (int*)(4 + (iptr)(&ptr)); -iptr ff = (iptr)(&ptr); -int ptr = 0; +global int*[] blurp = { &ptr, &ptr, (&ptr + 1), &ptr - 1, (int*)((iptr)(&ptr) - 4) }; +global int* c = (int*)((iptr)(&ptr) - 4); +global int* c2 = (int*)((iptr)(&ptr) + 4); +global int* c3 = (int*)(4 + (iptr)(&ptr)); +global iptr ff = (iptr)(&ptr); +global int ptr = 0; // #expect: test.ll diff --git a/test/test_suite/compile_time/ct_if.c3t b/test/test_suite/compile_time/ct_if.c3t index 006554164..269cfae02 100644 --- a/test/test_suite/compile_time/ct_if.c3t +++ b/test/test_suite/compile_time/ct_if.c3t @@ -4,7 +4,7 @@ $else: $elif (0): $elif (0): $else: - int x = 1; + global int x = 1; $endif; $endif; @@ -18,7 +18,7 @@ $endif; $if (1): $assert(true); -int d = 5; +global int d = 5; $elif (0): $assert(false); $else: @@ -29,7 +29,7 @@ $if (0): $assert(true); $elif (1): $assert(true); -int c = 5; +global int c = 5; $else: $assert(false); $endif; @@ -38,7 +38,7 @@ $if (0): $assert(true); $elif (1): $assert(true); -int b = 4; +global int b = 4; $elif (0): $assert(false); $else: @@ -51,7 +51,7 @@ $elif (0): $assert(false); $elif (1): $assert(true); -int a = 3; +global int a = 3; $else: $assert(false); $endif; diff --git a/test/test_suite/compile_time/cttype_reassign.c3t b/test/test_suite/compile_time/cttype_reassign.c3t index 7c53b05e0..4f7b9cd96 100644 --- a/test/test_suite/compile_time/cttype_reassign.c3t +++ b/test/test_suite/compile_time/cttype_reassign.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin module reassign; -func void test() +fn void test() { var $Foo = double; $Foo = int; diff --git a/test/test_suite/compile_time/not_yet_initialized.c3 b/test/test_suite/compile_time/not_yet_initialized.c3 index 08659e684..eef09a7fc 100644 --- a/test/test_suite/compile_time/not_yet_initialized.c3 +++ b/test/test_suite/compile_time/not_yet_initialized.c3 @@ -4,13 +4,13 @@ macro foo($Foo) return a; } -func void test1() +fn void test1() { var $Bar; @foo($Bar); // #error: '$Bar' is not defined yet } -func void test2() +fn void test2() { var $Bar; $Bar z; // #error: '$Bar' is not defined yet diff --git a/test/test_suite/compile_time/ternary_folding.c3t b/test/test_suite/compile_time/ternary_folding.c3t index 2ceafe276..6bf2f0619 100644 --- a/test/test_suite/compile_time/ternary_folding.c3t +++ b/test/test_suite/compile_time/ternary_folding.c3t @@ -1,15 +1,15 @@ // #target: x64-darwin -int foo = 2.2 ? 1 : 2; -double bar = false ? 1.0 : 2; -bool baz = 1 ? false : true; +global int foo = 2.2 ? 1 : 2; +global double bar = false ? 1.0 : 2; +global bool baz = 1 ? false : true; -func void test() +fn void test() { int x = 1 ? 0 : test2(); } -func int test2() { return 3; } +fn int test2() { return 3; } // #expect: ternary_folding.ll diff --git a/test/test_suite/compile_time/typeof_example.c3t b/test/test_suite/compile_time/typeof_example.c3t index f58f302a8..a8d8ea5a3 100644 --- a/test/test_suite/compile_time/typeof_example.c3t +++ b/test/test_suite/compile_time/typeof_example.c3t @@ -1,4 +1,4 @@ -extern func void printf(char *, ...); +extern fn void printf(char *, ...); macro bitcast($Target, value) { @@ -7,7 +7,7 @@ macro bitcast($Target, value) return *result; } -func void main() +fn void main() { float f = 100; int i = @bitcast(int, f); diff --git a/test/test_suite/compile_time/typeof_from_literal.c3 b/test/test_suite/compile_time/typeof_from_literal.c3 index 6043e7ff7..f4bbb82e4 100644 --- a/test/test_suite/compile_time/typeof_from_literal.c3 +++ b/test/test_suite/compile_time/typeof_from_literal.c3 @@ -1,12 +1,12 @@ module foo; -func void a() +fn void a() { $typeof(9146744073709551615i64) ef; int fffx = ef; // #error: 'long' to 'int' } -func void b() +fn void b() { $typeof(9223372036854775809u64) ef; int fffx = ef; // #error: 'ulong' to 'int' diff --git a/test/test_suite/compile_time_introspection/alignof.c3t b/test/test_suite/compile_time_introspection/alignof.c3t index 259cf2831..9eb117325 100644 --- a/test/test_suite/compile_time_introspection/alignof.c3t +++ b/test/test_suite/compile_time_introspection/alignof.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin module foo; -int[100] zfe; +global int[100] zfe; struct Bob { Bob[] x; @@ -37,29 +37,29 @@ union Foob Ar izzy; -long x = $alignof(zfe); -short y = $alignof("Bob.y"); -int z = $alignof("Bob.y"); -int w = $alignof(Bob.y); -int v = $alignof(v); -int x1 = $alignof("Ex.c"); -int x2 = $alignof(Ex.y); -int x3 = $alignof(char[8]); -int x4 = $alignof("Ar.br[1]"); -int x5 = $alignof(Ar.br[1]); -int x6 = $alignof(Ar.br[1]); -int x7 = $alignof(Ar.br[1]); -int x8 = $alignof(Ar.br[2]); -int x9 = $alignof("izzy.br[1]"); -int x10 = $alignof("izzy.br[1]"); -int x11 = $alignof(izzy.br[1]); -int z0 = $alignof("Foob.c"); -int z00 = $alignof("Foob.c[0]"); -int z01 = $alignof("Foob.c[1]"); -int z02 = $alignof("Foob.c[2]"); -int z03 = $alignof("Foob.c[3]"); -int z04 = $alignof("Foob.c[4]"); -int z05 = $alignof("Foob.c[5]"); +global long x = $alignof(zfe); +global short y = $alignof("Bob.y"); +global int z = $alignof("Bob.y"); +global int w = $alignof(Bob.y); +global int v = $alignof(v); +global int x1 = $alignof("Ex.c"); +global int x2 = $alignof(Ex.y); +global int x3 = $alignof(char[8]); +global int x4 = $alignof("Ar.br[1]"); +global int x5 = $alignof(Ar.br[1]); +global int x6 = $alignof(Ar.br[1]); +global int x7 = $alignof(Ar.br[1]); +global int x8 = $alignof(Ar.br[2]); +global int x9 = $alignof("izzy.br[1]"); +global int x10 = $alignof("izzy.br[1]"); +global int x11 = $alignof(izzy.br[1]); +global int z0 = $alignof("Foob.c"); +global int z00 = $alignof("Foob.c[0]"); +global int z01 = $alignof("Foob.c[1]"); +global int z02 = $alignof("Foob.c[2]"); +global int z03 = $alignof("Foob.c[3]"); +global int z04 = $alignof("Foob.c[4]"); +global int z05 = $alignof("Foob.c[5]"); diff --git a/test/test_suite/compile_time_introspection/defined.c3t b/test/test_suite/compile_time_introspection/defined.c3t index a3cd5f0ae..fda07d901 100644 --- a/test/test_suite/compile_time_introspection/defined.c3t +++ b/test/test_suite/compile_time_introspection/defined.c3t @@ -2,7 +2,7 @@ module mymodule; -extern func void printf(char *, ...); +extern fn void printf(char *, ...); struct Foo { @@ -13,7 +13,7 @@ struct Foo int j; } } -func void main() +fn void main() { int x = 0; var $counter = 0; diff --git a/test/test_suite/compile_time_introspection/defined_err.c3 b/test/test_suite/compile_time_introspection/defined_err.c3 index 194c144ad..59f9e8aca 100644 --- a/test/test_suite/compile_time_introspection/defined_err.c3 +++ b/test/test_suite/compile_time_introspection/defined_err.c3 @@ -1,4 +1,4 @@ -func void test1() +fn void test1() { bool x = $defined(1); // #error: constant string containing an identifier or type was expected } @@ -6,13 +6,13 @@ func void test1() struct Foo {} -func void test2() +fn void test2() { $assert($defined(int[1])); bool x = $defined(int[y]); // #error: 'y' could not be found, did you spell it right? } -func void test3() +fn void test3() { $assert($defined(Foo[1])); $assert($defined(Foo*)); diff --git a/test/test_suite/compile_time_introspection/nameof.c3t b/test/test_suite/compile_time_introspection/nameof.c3t index defc32050..0d9656cb4 100644 --- a/test/test_suite/compile_time_introspection/nameof.c3t +++ b/test/test_suite/compile_time_introspection/nameof.c3t @@ -1,13 +1,13 @@ // #target: x64-darwin module mymodule; -extern func void printf(char *, ...); +extern fn void printf(char *, ...); struct Foo { } int b; -func void main() +fn void main() { printf("%s\n", $qnameof(Foo)); printf("%s\n", $qnameof("Foo")); diff --git a/test/test_suite/compile_time_introspection/nameof_err.c3 b/test/test_suite/compile_time_introspection/nameof_err.c3 index 530137138..b23c18902 100644 --- a/test/test_suite/compile_time_introspection/nameof_err.c3 +++ b/test/test_suite/compile_time_introspection/nameof_err.c3 @@ -1,15 +1,15 @@ -func void main() +fn void main() { int a; $extnameof(a); // #error: 'a' does not have an external name. } -func void main2() +fn void main2() { int a; $extnameof("a"); // #error: 'a' does not have an external name. } -func void main3() +fn void main3() { $extnameof("int"); // #error: Only user defined types have an external name. } diff --git a/test/test_suite/compile_time_introspection/offsetof.c3t b/test/test_suite/compile_time_introspection/offsetof.c3t index 5ad956f71..386ebf574 100644 --- a/test/test_suite/compile_time_introspection/offsetof.c3t +++ b/test/test_suite/compile_time_introspection/offsetof.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin module foo; -int[100] zfe; +global int[100] zfe; struct Bob { Bob[] x; @@ -36,21 +36,21 @@ union Foob } -short y = $offsetof("Bob.y"); -int z = $offsetof("Bob.y"); -int w = $offsetof(Bob.y); -int x1 = $offsetof("Ex.c[3]"); -int x2 = $offsetof("Ex.y[1]"); -int x4 = $offsetof("Ar.br[1]"); -int x6 = $offsetof(Ar.br[1].x); -int x5 = $offsetof(Ar.br[1]); -int x7 = $offsetof("Ar.br[2].x"); -int x8 = $offsetof(Ar.br[2]); -int z0 = $offsetof("Foob.c"); -int z00 = $offsetof("Foob.c[0]"); -int z01 = $offsetof("Foob.c[1]"); -int z02 = $offsetof("Foob.c[5]"); -int z03 = $offsetof("Foob.a"); +global short y = $offsetof("Bob.y"); +global int z = $offsetof("Bob.y"); +global int w = $offsetof(Bob.y); +global int x1 = $offsetof("Ex.c[3]"); +global int x2 = $offsetof("Ex.y[1]"); +global int x4 = $offsetof("Ar.br[1]"); +global int x6 = $offsetof(Ar.br[1].x); +global int x5 = $offsetof(Ar.br[1]); +global int x7 = $offsetof("Ar.br[2].x"); +global int x8 = $offsetof(Ar.br[2]); +global int z0 = $offsetof("Foob.c"); +global int z00 = $offsetof("Foob.c[0]"); +global int z01 = $offsetof("Foob.c[1]"); +global int z02 = $offsetof("Foob.c[5]"); +global int z03 = $offsetof("Foob.a"); // #expect: foo.ll @foo.y = global i16 16, align 2 diff --git a/test/test_suite/compile_time_introspection/qnameof.c3t b/test/test_suite/compile_time_introspection/qnameof.c3t index f69cc1ce5..9126bcac9 100644 --- a/test/test_suite/compile_time_introspection/qnameof.c3t +++ b/test/test_suite/compile_time_introspection/qnameof.c3t @@ -1,11 +1,11 @@ module qnametest; -extern func int printf(char *, ...); +extern fn int printf(char *, ...); int x; struct Blob { int z; int f; } -func void main() +fn void main() { int help; printf("printf: %s\n", $nameof(printf)); diff --git a/test/test_suite/compile_time_introspection/sizeof.c3t b/test/test_suite/compile_time_introspection/sizeof.c3t index a0e8fe74d..d95cf90fc 100644 --- a/test/test_suite/compile_time_introspection/sizeof.c3t +++ b/test/test_suite/compile_time_introspection/sizeof.c3t @@ -2,22 +2,22 @@ module foo; import bar; import bar::abc; -long x = $sizeof(Baz); -short y = $sizeof("Baz"); -int z = $sizeof(bar::Baz); -int w = $sizeof("bar::Baz"); -int v = $sizeof("bar::abc::Foo"); -int x1 = $sizeof(x); -int y1 = $sizeof("y"); -int a = $sizeof("Baz.y"); -int b = $sizeof("Deep.a.b"); -int c = $sizeof("Deep.a.b.c"); -int d = $sizeof("Deep[][100]"); -int e = $sizeof("Deep[][100]**[100][]*"); -int a2 = $sizeof("Baz.y"); -int a3 = $sizeof(Baz.y); -int a4 = $sizeof(Baz.y); -int a5 = $sizeof(Baz.y); +global long x = $sizeof(Baz); +global short y = $sizeof("Baz"); +global int z = $sizeof(bar::Baz); +global int w = $sizeof("bar::Baz"); +global int v = $sizeof("bar::abc::Foo"); +global int x1 = $sizeof(x); +global int y1 = $sizeof("y"); +global int a = $sizeof("Baz.y"); +global int b = $sizeof("Deep.a.b"); +global int c = $sizeof("Deep.a.b.c"); +global int d = $sizeof("Deep[][100]"); +global int e = $sizeof("Deep[][100]**[100][]*"); +global int a2 = $sizeof("Baz.y"); +global int a3 = $sizeof(Baz.y); +global int a4 = $sizeof(Baz.y); +global int a5 = $sizeof(Baz.y); module bar; diff --git a/test/test_suite/compile_time_introspection/sizeof_errors.c3 b/test/test_suite/compile_time_introspection/sizeof_errors.c3 index dd110af2a..e4f662868 100644 --- a/test/test_suite/compile_time_introspection/sizeof_errors.c3 +++ b/test/test_suite/compile_time_introspection/sizeof_errors.c3 @@ -2,62 +2,62 @@ module foo; import bar; import bar::abc; -func void a() +fn void a() { int x = $sizeof(Bazy); // #error: 'Bazy' could not be found, did you spell it right } -func void b() +fn void b() { int x = $sizeof("Bazz"); // #error: 'Bazz' could not be found, did you misspell it } -func void c() +fn void c() { int x = $sizeof("Baz#"); // #error: The path to an existing member was expected after 'Baz', did you make a mistake? } -func void c2() +fn void c2() { int x = $sizeof("#Baz"); // #error: '#Baz' is not a valid identifier, did you misspell it? } -func void d() +fn void d() { int x = $sizeof("Baz."); // #error: The path to an existing member was expected after 'Baz', did you make a mistake? } -func void e() +fn void e() { int x = $sizeof(bar::Baze); // #error: 'Baze' could not be found, did you spell it right } -func void f() +fn void f() { int x = $sizeof("bar::Bazy"); // #error: 'Bazy' could not be found, did you spell it right } -func void g() +fn void g() { int x = $sizeof("bar::"); // #error: 'bar::' is not a valid identifier, did you misspell it? } -func void k() +fn void k() { int v = $sizeof("int.x"); // #error: 'int' has no members } -func void l() +fn void l() { int v = $sizeof("int[].len"); // #error: 'int[]' has no members } -func void m() +fn void m() { int v = $sizeof("int[4].len"); // #error: 'int[4]' has no members } -func void n() +fn void n() { int v = $sizeof("Baz.x1"); // #error: The path to an existing member was expected after } diff --git a/test/test_suite/constants/byte_literals.c3t b/test/test_suite/constants/byte_literals.c3t index 9909bc1f5..28c6d00cf 100644 --- a/test/test_suite/constants/byte_literals.c3t +++ b/test/test_suite/constants/byte_literals.c3t @@ -1,8 +1,8 @@ -char[*] foob = x"a0"; -char[*] fooz = x"00aabbccddeeff"; -char[*] fooy = x'dead beef'; -char[*] foow = x"4549234d e d"; -char[*] foo64 = b64"SGVsbG8gV29ybGQ="; +global char[*] foob = x"a0"; +global char[*] fooz = x"00aabbccddeeff"; +global char[*] fooy = x'dead beef'; +global char[*] foow = x"4549234d e d"; +global char[*] foo64 = b64"SGVsbG8gV29ybGQ="; // #expect: byte_literals.ll diff --git a/test/test_suite/constants/char_literals.c3t b/test/test_suite/constants/char_literals.c3t index 2a3aa06d0..dc1f3d3d7 100644 --- a/test/test_suite/constants/char_literals.c3t +++ b/test/test_suite/constants/char_literals.c3t @@ -1,15 +1,15 @@ // #file: file1.c3 module test; -char a = ' '; -char b = '\r'; -char c = '\t'; -char d = '\n'; -char e = '\0'; -char f = '\''; -char g = '"'; -char h = '\\'; -char i = '\e'; +global char a = ' '; +global char b = '\r'; +global char c = '\t'; +global char d = '\n'; +global char e = '\0'; +global char f = '\''; +global char g = '"'; +global char h = '\\'; +global char i = '\e'; // #expect: test.ll diff --git a/test/test_suite/constants/constants.c3t b/test/test_suite/constants/constants.c3t index 370fac253..91bc6f184 100644 --- a/test/test_suite/constants/constants.c3t +++ b/test/test_suite/constants/constants.c3t @@ -5,13 +5,13 @@ private const uint DD = FOO; private const FOO = ~(uint)(0); -private uint x = AA; -private uint z = CC; -private char w = (char)(FOO); -private ushort v = (ushort)(FOO); -private uint z2 = DD; +private global uint x = AA; +private global uint z = CC; +private global char w = (char)(FOO); +private global ushort v = (ushort)(FOO); +private global uint z2 = DD; -func void test() +fn void test() { int xx = FOO; uint* yy = &&FOO; diff --git a/test/test_suite/define/common.c3 b/test/test_suite/define/common.c3 index 95cee7bb3..8f5452dd0 100644 --- a/test/test_suite/define/common.c3 +++ b/test/test_suite/define/common.c3 @@ -7,8 +7,8 @@ define FooInt = Foo; define A_CONST_INT = A_CONST; define standard_foo = ofke; // #error: Expected '=' -define func foo = fef; // #error: An identifier was expected here. -define feokfe = func void(int); // #error: Expected a function or variable name here +define fn foo = fef; // #error: An identifier was expected here. +define feokfe = fn void(int); // #error: Expected a function or variable name here define AOFKE = ofek; // #error: Expected a constant name here define okfoe = OFKEOK; // #error: Expected a function or variable name here define Helo = helo; // #error: A type name was expected here diff --git a/test/test_suite/distinct/distinct_struct.c3 b/test/test_suite/distinct/distinct_struct.c3 index c567ab4ea..f7e7b39e0 100644 --- a/test/test_suite/distinct/distinct_struct.c3 +++ b/test/test_suite/distinct/distinct_struct.c3 @@ -18,7 +18,7 @@ struct Struct2 } Foo f = { 1, 1.0 }; -func void test(int x) +fn void test(int x) { Struct s = { 1, 2.0 }; Foo f2 = (Foo)(s); diff --git a/test/test_suite/distinct/distinct_struct_array.c3 b/test/test_suite/distinct/distinct_struct_array.c3 index e8b3a77df..9794d6363 100644 --- a/test/test_suite/distinct/distinct_struct_array.c3 +++ b/test/test_suite/distinct/distinct_struct_array.c3 @@ -11,7 +11,7 @@ struct Struct define Struct2 = distinct Struct; define StructArr = distinct Struct2[3]; -func void test(int x) +fn void test(int x) { StructArr z = { { .x = 1 }, { .y = x }, { 1, 2 }}; usize len = z.len; diff --git a/test/test_suite/distinct/distinct_union.c3 b/test/test_suite/distinct/distinct_union.c3 index 0ec2798a1..49af50a55 100644 --- a/test/test_suite/distinct/distinct_union.c3 +++ b/test/test_suite/distinct/distinct_union.c3 @@ -23,7 +23,7 @@ define Union3 = distinct Union2; define UnionArr = distinct Union3[3]; -func void test(int x) +fn void test(int x) { Union s = { .y = 2.0 }; Foo f2 = (Foo)(s); diff --git a/test/test_suite/distinct/test_errors.c3 b/test/test_suite/distinct/test_errors.c3 index f64d8a527..ccea22f84 100644 --- a/test/test_suite/distinct/test_errors.c3 +++ b/test/test_suite/distinct/test_errors.c3 @@ -2,7 +2,7 @@ module test; define Int2 = distinct int; -func void test() +fn void test() { Int2 a = 1; a = a + 1; diff --git a/test/test_suite/distinct/test_ops_on_int.c3 b/test/test_suite/distinct/test_ops_on_int.c3 index 13b8478de..76f50b233 100644 --- a/test/test_suite/distinct/test_ops_on_int.c3 +++ b/test/test_suite/distinct/test_ops_on_int.c3 @@ -2,7 +2,7 @@ module test; define Foo = distinct int; -func int test1() +fn int test1() { Foo x = 1; x += 2; diff --git a/test/test_suite/distinct/test_ops_on_struct.c3 b/test/test_suite/distinct/test_ops_on_struct.c3 index ee157b92e..8afcb4962 100644 --- a/test/test_suite/distinct/test_ops_on_struct.c3 +++ b/test/test_suite/distinct/test_ops_on_struct.c3 @@ -15,7 +15,7 @@ struct Struct2 } Foo f = { 1, 1.0 }; -func void test(int x) +fn void test(int x) { Struct s = { 1, 2.0 }; Foo f2 = (Foo)(s); diff --git a/test/test_suite/enumerations/compile_time.c3t b/test/test_suite/enumerations/compile_time.c3t index d51584493..64ecd627e 100644 --- a/test/test_suite/enumerations/compile_time.c3t +++ b/test/test_suite/enumerations/compile_time.c3t @@ -5,11 +5,11 @@ enum MyEnum : short BYE = -5 } -int myenum_max = MyEnum.max; -int myenum_min = MyEnum.min; -int myenum_elements = MyEnum.elements; -int myenum_alignof = $alignof(MyEnum); -int myenum_sizeof = $sizeof(MyEnum); +global int myenum_max = MyEnum.max; +global int myenum_min = MyEnum.min; +global int myenum_elements = MyEnum.elements; +global int myenum_alignof = $alignof(MyEnum); +global int myenum_sizeof = $sizeof(MyEnum); // #expect: compile_time.ll diff --git a/test/test_suite/enumerations/simple_inference.c3t b/test/test_suite/enumerations/simple_inference.c3t index bb0bbf0c9..9ddd42659 100644 --- a/test/test_suite/enumerations/simple_inference.c3t +++ b/test/test_suite/enumerations/simple_inference.c3t @@ -6,7 +6,7 @@ enum HelloEnum WORLD, ELLOWORLD, } -func void test() +fn void test() { HelloEnum h = WORLD; h = ELLOWORLD; diff --git a/test/test_suite/errors/anyerr_void.c3t b/test/test_suite/errors/anyerr_void.c3t index d67856710..3b5396e19 100644 --- a/test/test_suite/errors/anyerr_void.c3t +++ b/test/test_suite/errors/anyerr_void.c3t @@ -14,7 +14,7 @@ fn void! errorThing2() } extern fn void printf(char*, ...); -func void main() +fn void main() { anyerr z = errorThing(); printf("Z; %llx\n", (iptr)(z)); diff --git a/test/test_suite/errors/bitshift_failable.c3 b/test/test_suite/errors/bitshift_failable.c3 index 8019d2a60..f649501f3 100644 --- a/test/test_suite/errors/bitshift_failable.c3 +++ b/test/test_suite/errors/bitshift_failable.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { int! x = 0; int! z = x << 100; // #error: shift exceeds bitsize of 'int' diff --git a/test/test_suite/errors/else_checks.c3t b/test/test_suite/errors/else_checks.c3t index 156eb3558..34f1eeeea 100644 --- a/test/test_suite/errors/else_checks.c3t +++ b/test/test_suite/errors/else_checks.c3t @@ -1,8 +1,8 @@ // #target: x64-darwin -extern func int! testError(); +extern fn int! testError(); -func void test() +fn void test() { double x = (testError() + testError()) ?? 100; diff --git a/test/test_suite/errors/error_throw.c3 b/test/test_suite/errors/error_throw.c3 index 7ea855f2b..220549815 100644 --- a/test/test_suite/errors/error_throw.c3 +++ b/test/test_suite/errors/error_throw.c3 @@ -5,7 +5,7 @@ errtype Blurg Z } -func void main() +fn void main() { int! i = Blurg.Z!; int! j = Blurg.Z!; diff --git a/test/test_suite/errors/error_union.c3 b/test/test_suite/errors/error_union.c3 index 6a26bc0f1..d18201251 100644 --- a/test/test_suite/errors/error_union.c3 +++ b/test/test_suite/errors/error_union.c3 @@ -5,7 +5,7 @@ errtype Blurg X, Y, Z } -func void main() +fn void main() { anyerr foo; } \ No newline at end of file diff --git a/test/test_suite/errors/failable_taddr_and_access.c3t b/test/test_suite/errors/failable_taddr_and_access.c3t index 6f00199d8..bd87a32c8 100644 --- a/test/test_suite/errors/failable_taddr_and_access.c3t +++ b/test/test_suite/errors/failable_taddr_and_access.c3t @@ -11,9 +11,9 @@ errtype MyErr FOO } -extern func int printf(char *c, ...); +extern fn int printf(char *c, ...); -func void main() +fn void main() { int! z = 2; Foo*! w = &&Foo{ z, 0 }; diff --git a/test/test_suite/errors/failable_untyped_list.c3 b/test/test_suite/errors/failable_untyped_list.c3 index 54245c1c3..eab0d24da 100644 --- a/test/test_suite/errors/failable_untyped_list.c3 +++ b/test/test_suite/errors/failable_untyped_list.c3 @@ -9,15 +9,15 @@ errtype MyErr FOO } -extern func int printf(char *c, ...); +extern fn int printf(char *c, ...); -func void main() +fn void main() { int! z = 2; Foo*! w = &&{ z, 0 }; // #error: A failable 'int[2]*!' cannot be converted to 'Foo*' } -func void test() +fn void test() { int! z = 2; Foo*! w = &&Foo!{ z, 0 }; // #error: please remove the '!' diff --git a/test/test_suite/errors/general_error_regression.c3t b/test/test_suite/errors/general_error_regression.c3t index 6a9e08295..b6927d9bd 100644 --- a/test/test_suite/errors/general_error_regression.c3t +++ b/test/test_suite/errors/general_error_regression.c3t @@ -26,21 +26,21 @@ enum MyEnum B } -func void Foo.hello(Foo *f) +fn void Foo.hello(Foo *f) { io::println("Hello from Foo"); } -func void Bar.hello(Bar *b) +fn void Bar.hello(Bar *b) { io::println("Hello from Bar"); } -func void MyEnum.hello(MyEnum *myenum) +fn void MyEnum.hello(MyEnum *myenum) { io::println("Hello from MyEnum"); } -func void main() +fn void main() { Foo f = Foo.X; Foo ef = Foo.Y; diff --git a/test/test_suite/errors/illegal_use_of_failable.c3 b/test/test_suite/errors/illegal_use_of_failable.c3 index b944a7a10..0c6bb1cb2 100644 --- a/test/test_suite/errors/illegal_use_of_failable.c3 +++ b/test/test_suite/errors/illegal_use_of_failable.c3 @@ -1,4 +1,4 @@ -func void syntaxErrors() +fn void syntaxErrors() { int! i = 0; while (i + 1) {} // #error: 'int!' to 'bool' diff --git a/test/test_suite/errors/precedence_err.c3 b/test/test_suite/errors/precedence_err.c3 index 239a9690d..0d80271cb 100644 --- a/test/test_suite/errors/precedence_err.c3 +++ b/test/test_suite/errors/precedence_err.c3 @@ -1,5 +1,5 @@ -func void test() +fn void test() { int x = 3 ^ 5 & 6; // #error: You need to add explicit parentheses to clarify precedence } diff --git a/test/test_suite/errors/rethrow.c3t b/test/test_suite/errors/rethrow.c3t index 2bae7c637..118ce8c6d 100644 --- a/test/test_suite/errors/rethrow.c3t +++ b/test/test_suite/errors/rethrow.c3t @@ -1,6 +1,6 @@ // #target: x64-darwin -func void! test() +fn void! test() { int! i; i?; diff --git a/test/test_suite/errors/rethrow_mingw.c3t b/test/test_suite/errors/rethrow_mingw.c3t index 24cacdc3d..50a7957b7 100644 --- a/test/test_suite/errors/rethrow_mingw.c3t +++ b/test/test_suite/errors/rethrow_mingw.c3t @@ -2,7 +2,7 @@ module rethrow; -func void! test() +fn void! test() { int! i; i?; diff --git a/test/test_suite/errors/rethrow_no_err.c3 b/test/test_suite/errors/rethrow_no_err.c3 index cac642af2..625b268e4 100644 --- a/test/test_suite/errors/rethrow_no_err.c3 +++ b/test/test_suite/errors/rethrow_no_err.c3 @@ -1,5 +1,5 @@ -func void test() +fn void test() { test()?; // #error: No failable to rethrow before '?' in the expression, please remove '?' int i = 0; @@ -9,7 +9,7 @@ func void test() if ((j?)?) return; // #error: This expression implicitly returns with a failable result, but the function } -func void! test2() +fn void! test2() { int! j = 0; if (j?) return; diff --git a/test/test_suite/errors/simple_static_failable.c3t b/test/test_suite/errors/simple_static_failable.c3t index 913ecf662..39f46d786 100644 --- a/test/test_suite/errors/simple_static_failable.c3t +++ b/test/test_suite/errors/simple_static_failable.c3t @@ -7,7 +7,7 @@ errtype Blurg Y } -func void main() +fn void main() { static int! x = 120; int! i = Blurg.Y!; diff --git a/test/test_suite/errors/try_assign.c3t b/test/test_suite/errors/try_assign.c3t index 7df31deb2..6c29e36cd 100644 --- a/test/test_suite/errors/try_assign.c3t +++ b/test/test_suite/errors/try_assign.c3t @@ -1,10 +1,10 @@ // #target: x64-darwin -extern func int! err(); +extern fn int! err(); errtype FooErr { QBERT } -extern func int printf(char* fmt, ...); +extern fn int printf(char* fmt, ...); -func void main() +fn void main() { int x = 123; int! z = 234; diff --git a/test/test_suite/errors/try_catch_if.c3t b/test/test_suite/errors/try_catch_if.c3t index 3b6bbf65a..2cff186db 100644 --- a/test/test_suite/errors/try_catch_if.c3t +++ b/test/test_suite/errors/try_catch_if.c3t @@ -1,13 +1,13 @@ // #target: x64-darwin -func int hello(int x) +fn int hello(int x) { return x + 1; } -extern func int printf(char *c, ...); +extern fn int printf(char *c, ...); -func int! tester() +fn int! tester() { printf("In tester\n"); return 222; @@ -17,7 +17,7 @@ errtype Foo { A } -func void test1() +fn void test1() { int! a = 123; if (catch err = (a, tester())) @@ -29,7 +29,7 @@ func void test1() printf("Noerr %d\n", a); } } -func void main() +fn void main() { test1(); } diff --git a/test/test_suite/errors/try_catch_unwrapping_while_if.c3 b/test/test_suite/errors/try_catch_unwrapping_while_if.c3 index 05646762a..06794efcd 100644 --- a/test/test_suite/errors/try_catch_unwrapping_while_if.c3 +++ b/test/test_suite/errors/try_catch_unwrapping_while_if.c3 @@ -1,11 +1,11 @@ -extern func int printf(char* fmt, ...); +extern fn int printf(char* fmt, ...); -extern func int! err(); +extern fn int! err(); errtype FooErr { X } -func void test1() +fn void test1() { int! z = 234; if (try z) @@ -17,7 +17,7 @@ func void test1() } -func void test4() +fn void test4() { int! z = 234; int! w = 123; @@ -28,7 +28,7 @@ func void test4() } } -func void test5() +fn void test5() { int! z = 234; int! w = 123; @@ -37,7 +37,7 @@ func void test5() int y = z; } } -func void test5b() +fn void test5b() { int! z = 234; int! w = 123; @@ -47,7 +47,7 @@ func void test5b() } } -func void test6() +fn void test6() { int! z = 234; int! w = 123; @@ -58,7 +58,7 @@ func void test6() } } -func void test7() +fn void test7() { int! z = 234; int! w = 123; @@ -71,7 +71,7 @@ func void test7() } } -func void test8() +fn void test8() { int! z = 234; int! w = 123; @@ -83,7 +83,7 @@ func void test8() int y = z; } } -func void test9() +fn void test9() { int! z = 234; int! w = 123; diff --git a/test/test_suite/errors/try_unwrap_using_assert.c3t b/test/test_suite/errors/try_unwrap_using_assert.c3t index 5e220b592..13be65c5c 100644 --- a/test/test_suite/errors/try_unwrap_using_assert.c3t +++ b/test/test_suite/errors/try_unwrap_using_assert.c3t @@ -1,9 +1,9 @@ // #target: x64-darwin module test; -extern func int! maybe(); +extern fn int! maybe(); -func int tester(int n) +fn int tester(int n) { int! num = maybe(); assert(try num, "Hello"); diff --git a/test/test_suite/errors/try_with_assign_to_failable.c3 b/test/test_suite/errors/try_with_assign_to_failable.c3 index 8e7550614..191006004 100644 --- a/test/test_suite/errors/try_with_assign_to_failable.c3 +++ b/test/test_suite/errors/try_with_assign_to_failable.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { int! z; int! w; diff --git a/test/test_suite/errors/try_with_chained_unwrap.c3t b/test/test_suite/errors/try_with_chained_unwrap.c3t index 12c2ddff1..adc67dfea 100644 --- a/test/test_suite/errors/try_with_chained_unwrap.c3t +++ b/test/test_suite/errors/try_with_chained_unwrap.c3t @@ -1,11 +1,11 @@ // #target: x64-darwin -extern func char*! readLine(); -extern func int! atoi(char*); +extern fn char*! readLine(); +extern fn int! atoi(char*); -extern func int printf(char* fmt, ...); +extern fn int printf(char* fmt, ...); -func void main() +fn void main() { int val; if (try val = atoi(readLine())) diff --git a/test/test_suite/errors/try_with_chained_unwrap_errors.c3 b/test/test_suite/errors/try_with_chained_unwrap_errors.c3 index 35cb3dd48..cfadc2bf9 100644 --- a/test/test_suite/errors/try_with_chained_unwrap_errors.c3 +++ b/test/test_suite/errors/try_with_chained_unwrap_errors.c3 @@ -1,10 +1,10 @@ -func void test() +fn void test() { int! a; int b; if (try int b = a) {} // #error: 'b' would shadow a previous declaration. } -func void test2() +fn void test2() { int! a; int b; @@ -14,7 +14,7 @@ func void test2() const int BAZ = 1; -func void test3() +fn void test3() { int! a; @@ -23,7 +23,7 @@ func void test3() } -func void test4() +fn void test4() { int! a; @@ -31,7 +31,7 @@ func void test4() if (try b = 1) {} // #error: Expected a failable expression to 'try' here. If it isn't a failable, remove 'try' } -func void test5() +fn void test5() { int! a; @@ -39,7 +39,7 @@ func void test5() if (try a = a) {} // #error: This is a failable variable, you should only have non-failable variables on the left side unless you use 'try' without '=' } -func void test6() +fn void test6() { int! a; @@ -49,7 +49,7 @@ func void test6() } -func void test7() +fn void test7() { int! a; int b; @@ -57,7 +57,7 @@ func void test7() if (try foo::z = a) {} // #error: The variable may not have a path. } -func void test8() +fn void test8() { int! a; int b; @@ -66,7 +66,7 @@ func void test8() if (try c = a && try c = a) { c++; } } -func void test9() +fn void test9() { int! a = 11; if (try z = a) @@ -79,7 +79,7 @@ func void test9() } } -func void test10() +fn void test10() { int! a = 11; if (try a) diff --git a/test/test_suite/errors/try_with_unwrap.c3t b/test/test_suite/errors/try_with_unwrap.c3t index 7131c30e5..d2133805d 100644 --- a/test/test_suite/errors/try_with_unwrap.c3t +++ b/test/test_suite/errors/try_with_unwrap.c3t @@ -1,10 +1,10 @@ // #target: x64-darwin -extern func char*! readLine(); -extern func int! atoi(char*); +extern fn char*! readLine(); +extern fn int! atoi(char*); -extern func int printf(char* fmt, ...); +extern fn int printf(char* fmt, ...); -func void main() +fn void main() { char*! line = readLine(); if (try line) diff --git a/test/test_suite/errors/try_with_unwrapper.c3t b/test/test_suite/errors/try_with_unwrapper.c3t index e29a7a149..b0d122a86 100644 --- a/test/test_suite/errors/try_with_unwrapper.c3t +++ b/test/test_suite/errors/try_with_unwrapper.c3t @@ -1,13 +1,13 @@ // #target: x64-darwin -func int hello(int x) +fn int hello(int x) { return x + 1; } -extern func int printf(char *c, ...); +extern fn int printf(char *c, ...); -func int! tester() +fn int! tester() { printf("In tester\n"); return 222; @@ -17,7 +17,7 @@ errtype Foo { A } -func void test1() +fn void test1() { int! a = 11; if (try int b = a && try int c = tester()) @@ -26,12 +26,12 @@ func void test1() printf("%d\n", c); } } -func void main() +fn void main() { test1(); } -func void test2() +fn void test2() { int! a; if (try int b = a && hello(b)) diff --git a/test/test_suite/errors/try_with_weird_stuff.c3 b/test/test_suite/errors/try_with_weird_stuff.c3 index e4a95d478..371a8cb43 100644 --- a/test/test_suite/errors/try_with_weird_stuff.c3 +++ b/test/test_suite/errors/try_with_weird_stuff.c3 @@ -1,4 +1,4 @@ -func void test1() +fn void test1() { int! a; @@ -7,7 +7,7 @@ func void test1() if (try int &a = a) {} // #error: Expected a variable name after the type. } -func void test2() +fn void test2() { int! a; int b; diff --git a/test/test_suite/examples/gameoflife.c3 b/test/test_suite/examples/gameoflife.c3 index c0e7b7c68..a663e892e 100644 --- a/test/test_suite/examples/gameoflife.c3 +++ b/test/test_suite/examples/gameoflife.c3 @@ -1,12 +1,12 @@ module game_of_life; -extern func void printf(char *fmt, ...); -extern func int atoi(char *val); +extern fn void printf(char *fmt, ...); +extern fn int atoi(char *val); extern void *__stdoutp; -extern func void fflush(void *std); -extern func int rand(); -extern func void* malloc(usize size); -extern func void usleep(int time); +extern fn void fflush(void *std); +extern fn int rand(); +extern fn void* malloc(usize size); +extern fn void usleep(int time); struct GameBoard @@ -17,7 +17,7 @@ struct GameBoard char* temp; } -func void GameBoard.show(GameBoard *board) +fn void GameBoard.show(GameBoard *board) { printf("\e[H"); @@ -34,7 +34,7 @@ func void GameBoard.show(GameBoard *board) fflush(__stdoutp); } -func void GameBoard.evolve(GameBoard *board) +fn void GameBoard.evolve(GameBoard *board) { for (int y = 0; y < board.h; y++) { @@ -61,7 +61,7 @@ func void GameBoard.evolve(GameBoard *board) } -func int main(int c, char** v) +fn int main(int c, char** v) { int w = 0; int h = 0; diff --git a/test/test_suite/expression_block/expression_block_break.c3 b/test/test_suite/expression_block/expression_block_break.c3 index 603dde3da..6c558005d 100644 --- a/test/test_suite/expression_block/expression_block_break.c3 +++ b/test/test_suite/expression_block/expression_block_break.c3 @@ -1,8 +1,8 @@ module fe; import std::io; -extern func int printf(char *str, ...); +extern fn int printf(char *str, ...); -func int main() +fn int main() { while(true) { diff --git a/test/test_suite/expressions/addr_compiles.c3t b/test/test_suite/expressions/addr_compiles.c3t index 8c2395920..454122aaa 100644 --- a/test/test_suite/expressions/addr_compiles.c3t +++ b/test/test_suite/expressions/addr_compiles.c3t @@ -2,16 +2,16 @@ module test; -extern func void printf(char*, ...); +extern fn void printf(char*, ...); -func void main() +fn void main() { test(); test2(); test3(); } -func void test() +fn void test() { int f = 3; int* x = &(((f))); @@ -21,7 +21,7 @@ func void test() const int XX = 314; -func void test2() +fn void test2() { int* w = &XX; printf("w = %d (314)\n", *w); @@ -32,7 +32,7 @@ struct Foo int x; int y; } -func void test3() +fn void test3() { Foo h = { 345, 555 }; int* zx = &h.x; diff --git a/test/test_suite/expressions/addr_of_fails.c3 b/test/test_suite/expressions/addr_of_fails.c3 index 855c78208..fa830c6a3 100644 --- a/test/test_suite/expressions/addr_of_fails.c3 +++ b/test/test_suite/expressions/addr_of_fails.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { int f; int* x = &(((f))); @@ -7,7 +7,7 @@ func void test() } -func void test2() +fn void test2() { int f; var $foo; @@ -20,24 +20,24 @@ macro int hello() return he; } -func void test3() +fn void test3() { int* x = &@hello(); // #error: To take the address of a temporary value, use '&&' instead of '&' } -func void test3b() +fn void test3b() { int* x = &hello; // #error: It is not possible to take the address of a macro. } const X = 2; const int XX = 3; -func void test4() +fn void test4() { int* w = &XX; } -func void test5() +fn void test5() { int* z = &X; // #error: The constant is not typed, either type it or use && to take the reference to a temporary. } @@ -50,7 +50,7 @@ struct Foo define heh = he; -func void test6() +fn void test6() { int* hee = &heh; Foo h; @@ -66,7 +66,7 @@ errtype Err { FOO } union Un { int x; } enum MyEnum { BAR } -func void test7() +fn void test7() { &Baz; // #error: It is not possible to take the address of a type. &Bar; // #error: It is not possible to take the address of a type. diff --git a/test/test_suite/expressions/arithmetics.c3 b/test/test_suite/expressions/arithmetics.c3 index 28d331b4c..3644ed17e 100644 --- a/test/test_suite/expressions/arithmetics.c3 +++ b/test/test_suite/expressions/arithmetics.c3 @@ -1,40 +1,40 @@ module arithmetics; -func void testAdd(int a, int b) +fn void testAdd(int a, int b) { a = a + b; a += b; a += 1; } -func void testSub(int a, int b) +fn void testSub(int a, int b) { a = a - b; a -= b; a -= 1; } -func void testMult(int a, int b) +fn void testMult(int a, int b) { a = a * b; a *= b; a *= 1; } -func void testDiv(int a, int b) +fn void testDiv(int a, int b) { a = a / b; a /= b; a /= 1; } -func void testAssignment() +fn void testAssignment() { ichar x = -3 - 5; ichar c = -128; } -func char test22() +fn char test22() { return 100; } \ No newline at end of file diff --git a/test/test_suite/expressions/arithmetics_sema_fail.c3 b/test/test_suite/expressions/arithmetics_sema_fail.c3 index 9134c58fc..a7de80b31 100644 --- a/test/test_suite/expressions/arithmetics_sema_fail.c3 +++ b/test/test_suite/expressions/arithmetics_sema_fail.c3 @@ -1,51 +1,51 @@ -func void test7() +fn void test7() { double x = 1.2 / 0; // This is ok! NaN } -func void test8() +fn void test8() { int y = 0 / 0; // #error: division by zero is not allowed } -func void test9() +fn void test9() { int y = 0; int x = y / 0; // #error: division by zero is not allowed } -func void test10() +fn void test10() { 10 = 20; // #error: This expression is not assignable } -func void test11() +fn void test11() { '10' = '20'; // #error: This expression is not assignable } -func void test12() +fn void test12() { true = false; // #error: This expression is not assignable } -func void test13() +fn void test13() { "a" = "b"; // #error: This expression is not assignable } -func void test14() +fn void test14() { 1.2 = 1.3; // #error: This expression is not assignable } -func void test15() +fn void test15() { null = null; // #error: This expression is not assignable } -func void test16() +fn void test16() { int a = 0; uint b = 2; @@ -54,24 +54,24 @@ func void test16() int g = a + b; } -func void test17() +fn void test17() { char a = 100 + 300; // #error: '400' is out of range for 'char' } -func void test18() +fn void test18() { char b = 100 + 156; // #error: '256' is out of range for 'char' } -func void test19() +fn void test19() { ichar b = (-40) - 126; // #error: '-166' is out of range for 'ichar' } -func void test20() +fn void test20() { ichar d = ((-128 - 10) + 10) - 2; // #error: '-130' is out of range for 'ichar' ichar c = 100 * 100; // #error: '10000' is out of range for 'ichar' @@ -81,10 +81,10 @@ func void test20() check(128); // #error: '128' is out of range for 'ichar' } -func void check(ichar x) {} +fn void check(ichar x) {} -func char test22() +fn char test22() { return 300; // #error: '300' is out of range for 'char' } diff --git a/test/test_suite/expressions/assign.c3 b/test/test_suite/expressions/assign.c3 index 4e6234c8f..046ae8a8d 100644 --- a/test/test_suite/expressions/assign.c3 +++ b/test/test_suite/expressions/assign.c3 @@ -1,4 +1,4 @@ -func void test1() +fn void test1() { int* p; *p = 10; diff --git a/test/test_suite/expressions/assignability.c3 b/test/test_suite/expressions/assignability.c3 index 28b69e7f6..ea5192f75 100644 --- a/test/test_suite/expressions/assignability.c3 +++ b/test/test_suite/expressions/assignability.c3 @@ -1,38 +1,38 @@ define Number = int; -func void test1() +fn void test1() { 10 = 20; // #error: This expression is not assignable } -func void test2() +fn void test2() { "foo" = "bar"; // #error: This expression is not assignable } -func void test3() +fn void test3() { true = false; // #error: This expression is not assignable } -func void test4() +fn void test4() { 'c' = 'd'; // #error: This expression is not assignable } -func void test5() +fn void test5() { 3.14 = 2.14; // #error: This expression is not assignable } -func void test21() +fn void test21() { int a = 0; int b = 2; a++ = b++; // #error: This expression is not assignable } -func void test22() +fn void test22() { $Type = int; } \ No newline at end of file diff --git a/test/test_suite/expressions/assignment_precedence.c3t b/test/test_suite/expressions/assignment_precedence.c3t index 71ab108ff..da7d5bc14 100644 --- a/test/test_suite/expressions/assignment_precedence.c3t +++ b/test/test_suite/expressions/assignment_precedence.c3t @@ -1,6 +1,6 @@ module prec; -func void test() +fn void test() { int i = 1; int j = 2; diff --git a/test/test_suite/expressions/call_arg_types.c3 b/test/test_suite/expressions/call_arg_types.c3 index ba86aaea2..b260c3732 100644 --- a/test/test_suite/expressions/call_arg_types.c3 +++ b/test/test_suite/expressions/call_arg_types.c3 @@ -1,7 +1,7 @@ -func void test2(ichar a) +fn void test2(ichar a) {} -func void test1() +fn void test1() { test2(100); ichar c = 1; diff --git a/test/test_suite/expressions/call_inline.c3t b/test/test_suite/expressions/call_inline.c3t index 3b816aa22..57c0df0fe 100644 --- a/test/test_suite/expressions/call_inline.c3t +++ b/test/test_suite/expressions/call_inline.c3t @@ -1,22 +1,22 @@ module inlineme; import std::io; -func void test1() @inline +fn void test1() @inline { io::println("Inline!"); } -func void test2() @noinline +fn void test2() @noinline { io::println("No inline!"); } -func void test3() +fn void test3() { io::println("Plain"); } -func void main() +fn void main() { test1() @inline; test2() @inline; diff --git a/test/test_suite/expressions/casts/cast_const.c3 b/test/test_suite/expressions/casts/cast_const.c3 index 5c4eb5ed8..b109f700c 100644 --- a/test/test_suite/expressions/casts/cast_const.c3 +++ b/test/test_suite/expressions/casts/cast_const.c3 @@ -1,4 +1,4 @@ -func void test1() +fn void test1() { ichar a = (ichar)(256 + 1); ushort b = (ushort)(65536+1); diff --git a/test/test_suite/expressions/casts/cast_enum_to_various.c3 b/test/test_suite/expressions/casts/cast_enum_to_various.c3 index fb9e2b346..e943e167c 100644 --- a/test/test_suite/expressions/casts/cast_enum_to_various.c3 +++ b/test/test_suite/expressions/casts/cast_enum_to_various.c3 @@ -16,9 +16,9 @@ enum EnumB : char C, D } -define Func = func void(Enum); +define Func = fn void(Enum); -func void test1(Enum e) +fn void test1(Enum e) { bool a = (bool)(e); char b = (char)(e); @@ -27,12 +27,12 @@ func void test1(Enum e) uint* f = (uint*)(e); // #error: cast 'Enum' to 'uint*' } -func void test2(Enum e) +fn void test2(Enum e) { Struct* g = (Struct*)(e); // #error: cast 'Enum' to 'Struct*' } -func void test3(Enum e) +fn void test3(Enum e) { EnumB h = (EnumB)(e); Func i = (Func)(e); // #error: cast 'Enum' to 'Func' diff --git a/test/test_suite/expressions/casts/cast_expr.c3t b/test/test_suite/expressions/casts/cast_expr.c3t index 2b4752188..32d8ee294 100644 --- a/test/test_suite/expressions/casts/cast_expr.c3t +++ b/test/test_suite/expressions/casts/cast_expr.c3t @@ -1,6 +1,6 @@ module cast_expr; -func int main(int argc, char** argv) +fn int main(int argc, char** argv) { int a = 10; diff --git a/test/test_suite/expressions/casts/cast_failable.c3 b/test/test_suite/expressions/casts/cast_failable.c3 index 0dfb5dee3..28cb23aeb 100644 --- a/test/test_suite/expressions/casts/cast_failable.c3 +++ b/test/test_suite/expressions/casts/cast_failable.c3 @@ -3,7 +3,7 @@ errtype MyErr FOO } -func void test() +fn void test() { int! x = (int!)(MyErr.FOO!); // #error: Casting to a failable type is not allowed int! y = MyErr.FOO!; diff --git a/test/test_suite/expressions/casts/cast_func_to_various.c3 b/test/test_suite/expressions/casts/cast_func_to_various.c3 index 6507922c8..9ef156925 100644 --- a/test/test_suite/expressions/casts/cast_func_to_various.c3 +++ b/test/test_suite/expressions/casts/cast_func_to_various.c3 @@ -8,33 +8,33 @@ enum Enum : uptr A, B } -define Func = func void(int); -define FuncOther = func bool(char*); -define FuncSame = func void(int); +define Func = fn void(int); +define FuncOther = fn bool(char*); +define FuncSame = fn void(int); -func void test1(Func arg) +fn void test1(Func arg) { bool a = (bool)(arg); bool b = arg; } -func void test2(Func arg) +fn void test2(Func arg) { ichar b = (ichar)(arg); // #error: 'Func' (func void(int)) to 'ichar' } -func void test3(Func arg) +fn void test3(Func arg) { uint c = (uint)(arg); // #error: 'Func' (func void(int)) to 'uint' } -func void test4(Func arg) +fn void test4(Func arg) { float d = (float)(arg); // #error: 'Func' (func void(int)) to 'float' } -func void test7(Func arg) +fn void test7(Func arg) { usize g = (usize)(arg); FuncOther k = (FuncOther)(arg); diff --git a/test/test_suite/expressions/casts/cast_to_nonscalar.c3 b/test/test_suite/expressions/casts/cast_to_nonscalar.c3 index e3ecbed12..6a43d7a4c 100644 --- a/test/test_suite/expressions/casts/cast_to_nonscalar.c3 +++ b/test/test_suite/expressions/casts/cast_to_nonscalar.c3 @@ -3,7 +3,7 @@ struct Struct int x; } -func void test1() +fn void test1() { int a = (Struct)(200); // #error: 'int' to 'Struct' } diff --git a/test/test_suite/expressions/casts/cast_unknown.c3 b/test/test_suite/expressions/casts/cast_unknown.c3 index 73b9b7864..31d34c792 100644 --- a/test/test_suite/expressions/casts/cast_unknown.c3 +++ b/test/test_suite/expressions/casts/cast_unknown.c3 @@ -1,6 +1,6 @@ define Number = int; -func void test1() +fn void test1() { int a = 10; @@ -9,12 +9,12 @@ func void test1() int c = (Foo)(a); // #error: 'Foo' could not be found } -func void test2() +fn void test2() { int d = (Number)(bar);; // #error: 'bar' could not be found } -func void test3() +fn void test3() { int e = (Bar)( // #error: 'Bar' could not be found faa); // #error: 'faa' could not be found diff --git a/test/test_suite/expressions/casts/explicit_cast.c3 b/test/test_suite/expressions/casts/explicit_cast.c3 index c216acaf1..4743e41ae 100644 --- a/test/test_suite/expressions/casts/explicit_cast.c3 +++ b/test/test_suite/expressions/casts/explicit_cast.c3 @@ -1,7 +1,7 @@ define Number8 = char; define Number32 = int; -func void test1() +fn void test1() { int a = (ichar)(10); int b = (ichar)(200); @@ -9,7 +9,7 @@ func void test1() ichar d = (int)(200); // #error: 'int' to 'ichar' } -func void test2() +fn void test2() { char e = (Number32)(200); // #error: 'Number32' (int) to 'char' } \ No newline at end of file diff --git a/test/test_suite/expressions/chained_conditional.c3t b/test/test_suite/expressions/chained_conditional.c3t index cfdb1e2e1..2b7638cd0 100644 --- a/test/test_suite/expressions/chained_conditional.c3t +++ b/test/test_suite/expressions/chained_conditional.c3t @@ -1,11 +1,11 @@ module chained; -func int foo() +fn int foo() { return 1; } -func void test() +fn void test() { int x = foo(); int y = foo(); diff --git a/test/test_suite/expressions/check_implict_conversion_signed_unsigned.c3t b/test/test_suite/expressions/check_implict_conversion_signed_unsigned.c3t index a9be04c2f..743750b98 100644 --- a/test/test_suite/expressions/check_implict_conversion_signed_unsigned.c3t +++ b/test/test_suite/expressions/check_implict_conversion_signed_unsigned.c3t @@ -1,6 +1,6 @@ module check; -func int main() +fn int main() { int a = 0; ulong b = 3; diff --git a/test/test_suite/expressions/elvis.c3t b/test/test_suite/expressions/elvis.c3t index 628c77419..f85342de4 100644 --- a/test/test_suite/expressions/elvis.c3t +++ b/test/test_suite/expressions/elvis.c3t @@ -1,15 +1,15 @@ -func int* elvis(int *x, int *y) +fn int* elvis(int *x, int *y) { return x ?: y; } -func int* elvis2(int *x, int *y) +fn int* elvis2(int *x, int *y) { return x ?: (y ?: x); } -func bool elvis3(bool x, bool y) +fn bool elvis3(bool x, bool y) { return x ?: y; } diff --git a/test/test_suite/expressions/fail_index_usize.c3 b/test/test_suite/expressions/fail_index_usize.c3 index d165fcb0e..911ebd3e0 100644 --- a/test/test_suite/expressions/fail_index_usize.c3 +++ b/test/test_suite/expressions/fail_index_usize.c3 @@ -1,4 +1,4 @@ -func void test(int* array, usize n) +fn void test(int* array, usize n) { array[n] = 33; n[array] = 33; // #error: Cannot index diff --git a/test/test_suite/expressions/incdec.c3t b/test/test_suite/expressions/incdec.c3t index 0e33cda13..39d42d8ed 100644 --- a/test/test_suite/expressions/incdec.c3t +++ b/test/test_suite/expressions/incdec.c3t @@ -1,4 +1,4 @@ -func void test(int* foo) +fn void test(int* foo) { foo++; foo--; diff --git a/test/test_suite/expressions/negate_int.c3 b/test/test_suite/expressions/negate_int.c3 index 3c9f52dc4..258fbbd1b 100644 --- a/test/test_suite/expressions/negate_int.c3 +++ b/test/test_suite/expressions/negate_int.c3 @@ -1,39 +1,39 @@ -func void test1() +fn void test1() { short! a = 1; try(-a); short b = -a; // #error: 'int!' cannot be converted to 'short' } -func void test2() +fn void test2() { int! a = 1; try(-a); int b = -a; // #error: 'int!' to 'int' } -func void test3() +fn void test3() { long! a = 1; try(-a); long b = -a; // #error: 'long!' to 'long' } -func void test4() +fn void test4() { short! a = 1; try(~a); short b = ~a; // #error: 'short!' to 'short' } -func void test5() +fn void test5() { int! a = 1; try(~a); int b = ~a; // #error: 'int!' to 'int' } -func void test6() +fn void test6() { long! a = 1; try(~a); diff --git a/test/test_suite/expressions/no_valid_conversion_minus.c3 b/test/test_suite/expressions/no_valid_conversion_minus.c3 index 653493dab..30c91a85a 100644 --- a/test/test_suite/expressions/no_valid_conversion_minus.c3 +++ b/test/test_suite/expressions/no_valid_conversion_minus.c3 @@ -1,7 +1,7 @@ struct Foo {} -func int main() +fn int main() { int a = 0; Foo f; diff --git a/test/test_suite/expressions/parsed_numbers.c3t b/test/test_suite/expressions/parsed_numbers.c3t index 727d824eb..5ee674d03 100644 --- a/test/test_suite/expressions/parsed_numbers.c3t +++ b/test/test_suite/expressions/parsed_numbers.c3t @@ -1,9 +1,9 @@ module numbers; -double a = 0x1.1p+1; -double b = -12.3e-12; -double c = 0x1.1p-1; -double d = 12.3e+12; +global double a = 0x1.1p+1; +global double b = -12.3e-12; +global double c = 0x1.1p-1; +global double d = 12.3e+12; // #expect: numbers.ll diff --git a/test/test_suite/expressions/pointer_access.c3t b/test/test_suite/expressions/pointer_access.c3t index d37d32c0a..7639e7f21 100644 --- a/test/test_suite/expressions/pointer_access.c3t +++ b/test/test_suite/expressions/pointer_access.c3t @@ -1,5 +1,5 @@ -extern func void printf(char* c, ...); +extern fn void printf(char* c, ...); struct ExtraSimple { @@ -27,7 +27,7 @@ struct ExtraSimple } -func void testSimple() +fn void testSimple() { ExtraSimple a = { .c.j = 3.3 }; a.c.j = 3.4; diff --git a/test/test_suite/expressions/pointer_arith.c3 b/test/test_suite/expressions/pointer_arith.c3 index e6406ba39..2338aa493 100644 --- a/test/test_suite/expressions/pointer_arith.c3 +++ b/test/test_suite/expressions/pointer_arith.c3 @@ -1,4 +1,4 @@ -func void test1(ichar* cp) +fn void test1(ichar* cp) { int a = 10; @@ -11,7 +11,7 @@ func void test1(ichar* cp) ichar* cp4 = cp - a; cp2 - cp3; } -func void test2(ichar* cp) +fn void test2(ichar* cp) { cp + 1; cp * 1.0; // #error: 'ichar*' by 'double' diff --git a/test/test_suite/expressions/pointer_conv_error.c3 b/test/test_suite/expressions/pointer_conv_error.c3 index 4b611205a..40e59f04e 100644 --- a/test/test_suite/expressions/pointer_conv_error.c3 +++ b/test/test_suite/expressions/pointer_conv_error.c3 @@ -1,16 +1,16 @@ -func void test1() +fn void test1() { int myInt = 1; int* p1 = myInt; // #error: 'int' into 'int*' } -func void test2() +fn void test2() { uint myUInt = 1; int* p2 = myUInt; // #error: 'uint' into 'int*' } -func void test3() +fn void test3() { uint myUInt = 1; int* p2 = (int*)(myUInt); // #error: 'uint' to 'int*' diff --git a/test/test_suite/expressions/pointer_to_bool.c3 b/test/test_suite/expressions/pointer_to_bool.c3 index 3a4068aff..fcdf1292d 100644 --- a/test/test_suite/expressions/pointer_to_bool.c3 +++ b/test/test_suite/expressions/pointer_to_bool.c3 @@ -3,7 +3,7 @@ struct Struct char* ptr; } -func void test1(Struct* s) +fn void test1(Struct* s) { if (s.ptr) {} } \ No newline at end of file diff --git a/test/test_suite/expressions/rvalues.c3 b/test/test_suite/expressions/rvalues.c3 index 05e4c96e5..d7d949322 100644 --- a/test/test_suite/expressions/rvalues.c3 +++ b/test/test_suite/expressions/rvalues.c3 @@ -3,7 +3,7 @@ macro void hello($bar) $bar; } const FOO = 1 + 2; -func void test() +fn void test() { var $Foo = int; var $Bar = $Foo; diff --git a/test/test_suite/expressions/simple_float_sub_neg.c3t b/test/test_suite/expressions/simple_float_sub_neg.c3t index c30e80e4b..4b434d6aa 100644 --- a/test/test_suite/expressions/simple_float_sub_neg.c3t +++ b/test/test_suite/expressions/simple_float_sub_neg.c3t @@ -1,6 +1,6 @@ module simple_float_sub_neg; -func double test(double a, double b, double c, double d) +fn double test(double a, double b, double c, double d) { return -(a-b) - (c-d); } diff --git a/test/test_suite/expressions/strings.c3t b/test/test_suite/expressions/strings.c3t index 0d2e3984b..11e1135c2 100644 --- a/test/test_suite/expressions/strings.c3t +++ b/test/test_suite/expressions/strings.c3t @@ -1,6 +1,6 @@ module test; -func char* foo() +fn char* foo() { return "*** Word \"%s\" on line %d is not"; } diff --git a/test/test_suite/expressions/ternary_bool.c3t b/test/test_suite/expressions/ternary_bool.c3t index 01b176ebb..efe97999a 100644 --- a/test/test_suite/expressions/ternary_bool.c3t +++ b/test/test_suite/expressions/ternary_bool.c3t @@ -1,8 +1,8 @@ // #target: x64-darwin -extern func void printf(char *, ...); +extern fn void printf(char *, ...); -func void main() +fn void main() { bool b = true; diff --git a/test/test_suite/expressions/ternary_no_ident.c3 b/test/test_suite/expressions/ternary_no_ident.c3 index 4c7a4c44a..dbd2e7457 100644 --- a/test/test_suite/expressions/ternary_no_ident.c3 +++ b/test/test_suite/expressions/ternary_no_ident.c3 @@ -1,14 +1,14 @@ -func void test1() +fn void test1() { int a = (i ? 1 : 1); // #error: 'i' could not be found, did you spell it right } -func void test2() +fn void test2() { int a = (1 ? i : 2); // #error: 'i' could not be found, did you spell it right } -func void test3() +fn void test3() { int a = (1 ? 2 : i); // #error: 'i' could not be found, did you spell it right } diff --git a/test/test_suite/failable_catch.c3t b/test/test_suite/failable_catch.c3t index 4b21e6540..2e952e951 100644 --- a/test/test_suite/failable_catch.c3t +++ b/test/test_suite/failable_catch.c3t @@ -11,9 +11,9 @@ macro foo(int x) return MyErr.TEST!; } -extern func void printf(char*, ...); +extern fn void printf(char*, ...); -func void main() +fn void main() { int! a = @foo(1); diff --git a/test/test_suite/floats/explicit_float_truncation_needed.c3 b/test/test_suite/floats/explicit_float_truncation_needed.c3 index 374385ed3..72774ec8c 100644 --- a/test/test_suite/floats/explicit_float_truncation_needed.c3 +++ b/test/test_suite/floats/explicit_float_truncation_needed.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { float x = 0x7FFFFFFFFFFF.0p+400; // #error: The value '3.63419e+134' is out of range for 'float' } \ No newline at end of file diff --git a/test/test_suite/floats/float_exceeding_size.c3 b/test/test_suite/floats/float_exceeding_size.c3 index 0d198b3d9..88867f28f 100644 --- a/test/test_suite/floats/float_exceeding_size.c3 +++ b/test/test_suite/floats/float_exceeding_size.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { float x = 0x7FFFFFFFFFFF.0p+40000; // #error: The float value is out of range. diff --git a/test/test_suite/floats/inf_nan.c3t b/test/test_suite/floats/inf_nan.c3t index 1a024aa61..b3a776a76 100644 --- a/test/test_suite/floats/inf_nan.c3t +++ b/test/test_suite/floats/inf_nan.c3t @@ -1,6 +1,6 @@ module fe; -func void main() +fn void main() { float z = float.inf + 100; double z2 = double.inf; diff --git a/test/test_suite/from_docs/examples_defer.c3t b/test/test_suite/from_docs/examples_defer.c3t index eb6c1838d..d0adc8762 100644 --- a/test/test_suite/from_docs/examples_defer.c3t +++ b/test/test_suite/from_docs/examples_defer.c3t @@ -2,7 +2,7 @@ module defer1; import std::io; -func void test(int x) +fn void test(int x) { defer io::println(); defer io::print("A"); @@ -14,7 +14,7 @@ func void test(int x) io::print("!"); } -func void main() +fn void main() { test(1); // Prints "A" test(0); // Prints "BA" diff --git a/test/test_suite/from_docs/examples_forswitch.c3t b/test/test_suite/from_docs/examples_forswitch.c3t index dba521893..7aa6ccf21 100644 --- a/test/test_suite/from_docs/examples_forswitch.c3t +++ b/test/test_suite/from_docs/examples_forswitch.c3t @@ -3,7 +3,7 @@ module examples; import std::io; -func void example_for() +fn void example_for() { // the for-loop is the same as C99. for (int i = 0; i < 10; i++) @@ -25,7 +25,7 @@ enum Height : uint HIGH, } -func void demo_enum(Height h) +fn void demo_enum(Height h) { switch (h) { diff --git a/test/test_suite/from_docs/examples_functionpointer.c3t b/test/test_suite/from_docs/examples_functionpointer.c3t index a24594013..0a5a74b8f 100644 --- a/test/test_suite/from_docs/examples_functionpointer.c3t +++ b/test/test_suite/from_docs/examples_functionpointer.c3t @@ -1,16 +1,16 @@ // #target: x64-darwin module demo; -define Callback = func int(char* text, int value); +define Callback = fn int(char* text, int value); -func int my_callback(char* text, int value) +fn int my_callback(char* text, int value) { return 0; } Callback cb = &my_callback; -func void main() +fn void main() { int result = cb("demo", 123); // .. diff --git a/test/test_suite/from_docs/examples_if_catch.c3t b/test/test_suite/from_docs/examples_if_catch.c3t index 74f1d8af9..a6039da1c 100644 --- a/test/test_suite/from_docs/examples_if_catch.c3t +++ b/test/test_suite/from_docs/examples_if_catch.c3t @@ -7,10 +7,10 @@ errtype MathError DIVISION_BY_ZERO } -func int foo() { return 123; } -func int bar() { return 0; } +fn int foo() { return 123; } +fn int bar() { return 0; } -func double! divide(int a, int b) +fn double! divide(int a, int b) { if (b == 0) return MathError.DIVISION_BY_ZERO!; return (double)(a) / (double)(b); @@ -18,12 +18,12 @@ func double! divide(int a, int b) } // Rethrowing an error uses "?" suffix -func void! testMayError() +fn void! testMayError() { divide(foo(), bar())?; } -func void main() +fn void main() { // ratio has a failable type. double! ratio = divide(foo(), bar()); diff --git a/test/test_suite/from_docs/examples_macro_function.c3t b/test/test_suite/from_docs/examples_macro_function.c3t index 10df6176c..d1a73e8ce 100644 --- a/test/test_suite/from_docs/examples_macro_function.c3t +++ b/test/test_suite/from_docs/examples_macro_function.c3t @@ -7,12 +7,12 @@ macro foo(a, b) return a(b); } -func int square(int x) +fn int square(int x) { return x * x; } -func int test() +fn int test() { int a = 2; int b = 3; diff --git a/test/test_suite/from_docs/examples_struct.c3 b/test/test_suite/from_docs/examples_struct.c3 index 2c7d8d6e0..065e4de8c 100644 --- a/test/test_suite/from_docs/examples_struct.c3 +++ b/test/test_suite/from_docs/examples_struct.c3 @@ -1,4 +1,4 @@ -define Callback = func int(char c); +define Callback = fn int(char c); struct Person {} struct Company {} enum Status : int diff --git a/test/test_suite/functions/assorted_tests.c3t b/test/test_suite/functions/assorted_tests.c3t index 2d97dd283..ef3784bfc 100644 --- a/test/test_suite/functions/assorted_tests.c3t +++ b/test/test_suite/functions/assorted_tests.c3t @@ -1,6 +1,6 @@ module test; -func int foo1() +fn int foo1() { char *pp = void; uint w_cnt = void; @@ -10,14 +10,14 @@ func int foo1() return (int)(w_cnt); } -extern func void test2(int, double, float); +extern fn void test2(int, double, float); -func void foo2(int x) +fn void foo2(int x) { test2(x, x ? 1.0 : 12.5, 1.0); } -func int trys(ichar* s, int x) +fn int trys(ichar* s, int x) { int asa = void; double val = void; @@ -37,12 +37,12 @@ struct InternalFPF char type; } -func void setInternalFPFZero(InternalFPF* dest) @noinline +fn void setInternalFPFZero(InternalFPF* dest) @noinline { dest.type = 0; } -func void denormalize(InternalFPF* ptr) +fn void denormalize(InternalFPF* ptr) { setInternalFPFZero(ptr); } diff --git a/test/test_suite/functions/body_argument_fail.c3 b/test/test_suite/functions/body_argument_fail.c3 index bd9ae861c..7af99bcf5 100644 --- a/test/test_suite/functions/body_argument_fail.c3 +++ b/test/test_suite/functions/body_argument_fail.c3 @@ -1,5 +1,5 @@ -func void foo1(int... x;) {} // #error: Expected ')' -func void foo2(... x;) {} // #error: Expected ')' -func void foo3(... x;) {} // #error: Expected ')' -func void foo4(;) {} // #error: Expected ')' -func void foo5(int x;) {} // #error: Expected ')' \ No newline at end of file +fn void foo1(int... x;) {} // #error: Expected ')' +fn void foo2(... x;) {} // #error: Expected ')' +fn void foo3(... x;) {} // #error: Expected ')' +fn void foo4(;) {} // #error: Expected ')' +fn void foo5(int x;) {} // #error: Expected ')' \ No newline at end of file diff --git a/test/test_suite/functions/double_return.c3t b/test/test_suite/functions/double_return.c3t index fae952c56..752700bce 100644 --- a/test/test_suite/functions/double_return.c3t +++ b/test/test_suite/functions/double_return.c3t @@ -1,6 +1,6 @@ module double_return; -func int test(bool pos, bool color) +fn int test(bool pos, bool color) { return 0; return (int)(pos && color); diff --git a/test/test_suite/functions/macro_arguments.c3 b/test/test_suite/functions/macro_arguments.c3 index e00c2c98f..88ca22ee6 100644 --- a/test/test_suite/functions/macro_arguments.c3 +++ b/test/test_suite/functions/macro_arguments.c3 @@ -1,10 +1,10 @@ -func void foo1(int #foo) { } // #error: Only regular parameters are allowed for functions. +fn void foo1(int #foo) { } // #error: Only regular parameters are allowed for functions. -func void foo2(int $foo) { } // #error: Only regular parameters are allowed for functions. +fn void foo2(int $foo) { } // #error: Only regular parameters are allowed for functions. -func void foo3(bar) { } // #error: Only typed parameters are allowed for functions +fn void foo3(bar) { } // #error: Only typed parameters are allowed for functions -func void foo4($Type) { } // #error: Only regular parameters are allowed for functions. +fn void foo4($Type) { } // #error: Only regular parameters are allowed for functions. -func void foo8(int &foo) {} // #error: Only regular parameters are allowed for functions. \ No newline at end of file +fn void foo8(int &foo) {} // #error: Only regular parameters are allowed for functions. \ No newline at end of file diff --git a/test/test_suite/functions/missing_first_paren.c3 b/test/test_suite/functions/missing_first_paren.c3 index fdd38d7d6..384625bd2 100644 --- a/test/test_suite/functions/missing_first_paren.c3 +++ b/test/test_suite/functions/missing_first_paren.c3 @@ -1,3 +1,3 @@ -func void foo) // #error: Expected '(' +fn void foo) // #error: Expected '(' { } diff --git a/test/test_suite/functions/missing_return.c3 b/test/test_suite/functions/missing_return.c3 index c212663f2..d1028c19b 100644 --- a/test/test_suite/functions/missing_return.c3 +++ b/test/test_suite/functions/missing_return.c3 @@ -1,3 +1,3 @@ -func int test1() // #error: Missing return statement at the end of +fn int test1() // #error: Missing return statement at the end of { } \ No newline at end of file diff --git a/test/test_suite/functions/naked_function.c3t b/test/test_suite/functions/naked_function.c3t index 03fd2a13a..271f3bc56 100644 --- a/test/test_suite/functions/naked_function.c3t +++ b/test/test_suite/functions/naked_function.c3t @@ -1,6 +1,6 @@ // #target: x64-darwin -func void test(int i) @naked +fn void test(int i) @naked { } diff --git a/test/test_suite/functions/naked_function_fail.c3 b/test/test_suite/functions/naked_function_fail.c3 index ac0c34aac..df2b693f7 100644 --- a/test/test_suite/functions/naked_function_fail.c3 +++ b/test/test_suite/functions/naked_function_fail.c3 @@ -1,4 +1,4 @@ -func void test() @naked +fn void test() @naked { int i; // #error: Only asm statements are allowed inside of a naked function } \ No newline at end of file diff --git a/test/test_suite/functions/returning_void.c3t b/test/test_suite/functions/returning_void.c3t index 34e2911d0..567463bfe 100644 --- a/test/test_suite/functions/returning_void.c3t +++ b/test/test_suite/functions/returning_void.c3t @@ -1,4 +1,4 @@ -func void test1() +fn void test1() { int x; if (x == 0) return; diff --git a/test/test_suite/functions/splat.c3t b/test/test_suite/functions/splat.c3t index d8fe48781..b7d9b5370 100644 --- a/test/test_suite/functions/splat.c3t +++ b/test/test_suite/functions/splat.c3t @@ -1,9 +1,9 @@ // #target: x64-darwin module splat; -extern func int sum_us(int... x); +extern fn int sum_us(int... x); -func void test() +fn void test() { sum_us(1, 2, 3); int[3] x = { 1, 2, 3 }; diff --git a/test/test_suite/functions/splat_aarch64.c3t b/test/test_suite/functions/splat_aarch64.c3t index 9d35e17ef..9262b0504 100644 --- a/test/test_suite/functions/splat_aarch64.c3t +++ b/test/test_suite/functions/splat_aarch64.c3t @@ -1,9 +1,9 @@ // #target: aarch64-linux module splat; -extern func int sum_us(int... x); +extern fn int sum_us(int... x); -func void test() +fn void test() { sum_us(1, 2, 3); int[3] x = { 1, 2, 3 }; diff --git a/test/test_suite/functions/splat_mingw.c3t b/test/test_suite/functions/splat_mingw.c3t index 7f2edc88a..b90653060 100644 --- a/test/test_suite/functions/splat_mingw.c3t +++ b/test/test_suite/functions/splat_mingw.c3t @@ -1,9 +1,9 @@ // #target: x64-mingw module splat; -extern func int sum_us(int... x); +extern fn int sum_us(int... x); -func void test() +fn void test() { sum_us(1, 2, 3); int[3] x = { 1, 2, 3 }; diff --git a/test/test_suite/functions/static_vars.c3t b/test/test_suite/functions/static_vars.c3t index 6daf532b3..4cb83d501 100644 --- a/test/test_suite/functions/static_vars.c3t +++ b/test/test_suite/functions/static_vars.c3t @@ -1,15 +1,17 @@ module foo; -func int test() +fn int test() { static int x = 1; + global int y = 2; x++; return x; } // #expect: foo.ll -@test.x = hidden global i32 1, align 4 +@test.x = hidden thread_local global i32 1, align 4 +@test.y = hidden global i32 2, align 4 define i32 @foo.test() diff --git a/test/test_suite/functions/test_regression.c3t b/test/test_suite/functions/test_regression.c3t index 8639c4926..388e2207d 100644 --- a/test/test_suite/functions/test_regression.c3t +++ b/test/test_suite/functions/test_regression.c3t @@ -7,15 +7,15 @@ import std::array::linkedlist; import hello_world; -extern func int printf(char *, ...); +extern fn int printf(char *, ...); -func void helloWorld() +fn void helloWorld() { printf("helloWorld!\n"); } -func int test_static() +fn int test_static() { - static int x = 1; + global int x = 1; x++; printf("Test static %d\n", x); return x; @@ -33,7 +33,7 @@ union Foor } -func int helo(double d, Bobo b) +fn int helo(double d, Bobo b) { int[3] de = { 1, 2, 3 }; Bobo c = b; @@ -42,7 +42,7 @@ func int helo(double d, Bobo b) } -func int test1(int a, int b) +fn int test1(int a, int b) { a = a >> b; if (b > 128) return -1; @@ -54,12 +54,12 @@ struct Foo2 int x; } -func void Foo2.printme(Foo2 *foo) +fn void Foo2.printme(Foo2 *foo) { printf("Foo is: %d\n", foo.x); } -func int Foo2.mutate(Foo2 *foo) +fn int Foo2.mutate(Foo2 *foo) { printf("Mutating"); return ++foo.x; @@ -67,12 +67,12 @@ func int Foo2.mutate(Foo2 *foo) define oopsInt = test2::argh; define oopsDouble = test2::argh; -define Argh = func int(double, Bobo); -define Argh2 = func int(double, Bobo); +define Argh = fn int(double, Bobo); +define Argh2 = fn int(double, Bobo); -func int sum_us(int... x) +fn int sum_us(int... x) { int sum = 0; if (x.len == 0) return 0; @@ -82,7 +82,7 @@ func int sum_us(int... x) define Frob = long; -func int sumd(int[] x) +fn int sumd(int[] x) { int sum = 0; for (int i = 0; i < x.len; i++) sum += x[i]; @@ -113,7 +113,7 @@ enum MyEnum : int } -func void main() +fn void main() { test_static(); test_static(); @@ -174,10 +174,10 @@ func void main() module hello_world; import foo; -extern func int printf(char *, ...); +extern fn int printf(char *, ...); define doubleMult = check; -func void hello() +fn void hello() { printf("Hello baby\n"); printf("Mult %f\n", doubleMult(11.1)); @@ -185,7 +185,7 @@ func void hello() module foo ; -func Type check(Type i) +fn Type check(Type i) { return i * i; } @@ -197,11 +197,11 @@ struct Blob Type a; } -func Type getMult(Type a) +fn Type getMult(Type a) { return a * a; } -Type argh = 234; +global Type argh = 234; errtype MyErr { @@ -224,12 +224,12 @@ define Bye = Hello; define wat = wut; define byebye = hello; -func int hello() +fn int hello() { return 1; } -func Type getValue(Blob blob) +fn Type getValue(Blob blob) { return blob.a; } diff --git a/test/test_suite/functions/test_regression_mingw.c3t b/test/test_suite/functions/test_regression_mingw.c3t index c713cffb0..9e2b47ad4 100644 --- a/test/test_suite/functions/test_regression_mingw.c3t +++ b/test/test_suite/functions/test_regression_mingw.c3t @@ -7,15 +7,15 @@ import std::array::linkedlist; import hello_world; -extern func int printf(char *, ...); +extern fn int printf(char *, ...); -func void helloWorld() +fn void helloWorld() { printf("helloWorld!\n"); } -func int test_static() +fn int test_static() { - static int x = 1; + global int x = 1; x++; printf("Test static %d\n", x); return x; @@ -33,7 +33,7 @@ union Foor } -func int helo(double d, Bobo b) +fn int helo(double d, Bobo b) { int[3] de = { 1, 2, 3 }; Bobo c = b; @@ -42,7 +42,7 @@ func int helo(double d, Bobo b) } -func int test1(int a, int b) +fn int test1(int a, int b) { a = a >> b; if (b > 128) return -1; @@ -54,12 +54,12 @@ struct Foo2 int x; } -func void Foo2.printme(Foo2 *foo) +fn void Foo2.printme(Foo2 *foo) { printf("Foo is: %d\n", foo.x); } -func int Foo2.mutate(Foo2 *foo) +fn int Foo2.mutate(Foo2 *foo) { printf("Mutating"); return ++foo.x; @@ -69,12 +69,12 @@ func int Foo2.mutate(Foo2 *foo) define oopsInt = test2::argh; define oopsDouble = test2::argh; -define Argh = func int(double, Bobo); -define Argh2 = func int(double, Bobo); +define Argh = fn int(double, Bobo); +define Argh2 = fn int(double, Bobo); -func int sum_us(int... x) +fn int sum_us(int... x) { int sum = 0; if (x.len == 0) return 0; @@ -84,7 +84,7 @@ func int sum_us(int... x) define Frob = long; -func int sumd(int[] x) +fn int sumd(int[] x) { int sum = 0; for (int i = 0; i < x.len; i++) sum += x[i]; @@ -115,7 +115,7 @@ enum MyEnum : int } -func void main() +fn void main() { test_static(); test_static(); @@ -176,10 +176,10 @@ func void main() module hello_world; import foo; -extern func int printf(char *, ...); +extern fn int printf(char *, ...); define doubleMult = check; -func void hello() +fn void hello() { printf("Hello baby\n"); printf("Mult %f\n", doubleMult(11.1)); @@ -187,7 +187,7 @@ func void hello() module foo ; -func Type check(Type i) +fn Type check(Type i) { return i * i; } @@ -199,11 +199,11 @@ struct Blob Type a; } -func Type getMult(Type a) +fn Type getMult(Type a) { return a * a; } -Type argh = 234; +global Type argh = 234; errtype MyErr { @@ -226,12 +226,12 @@ define Bye = Hello; define wat = wut; define byebye = hello; -func int hello() +fn int hello() { return 1; } -func Type getValue(Blob blob) +fn Type getValue(Blob blob) { return blob.a; } diff --git a/test/test_suite/functions/vararg_argument_fails.c3 b/test/test_suite/functions/vararg_argument_fails.c3 index e5cb1efa6..9e865b473 100644 --- a/test/test_suite/functions/vararg_argument_fails.c3 +++ b/test/test_suite/functions/vararg_argument_fails.c3 @@ -1,5 +1,5 @@ -func void foo5(..., ...) {} // #error: Only a single vararg parameter is allowed +fn void foo5(..., ...) {} // #error: Only a single vararg parameter is allowed -func void foo6(int ..., int ...) {} // #error: Only a single vararg parameter is allowed +fn void foo6(int ..., int ...) {} // #error: Only a single vararg parameter is allowed -func void foo7(int... x, int ... y) {} // #error: Only a single vararg parameter is allowed \ No newline at end of file +fn void foo7(int... x, int ... y) {} // #error: Only a single vararg parameter is allowed \ No newline at end of file diff --git a/test/test_suite/functions/varargs.c3t b/test/test_suite/functions/varargs.c3t index 0121ba2f9..75ac34113 100644 --- a/test/test_suite/functions/varargs.c3t +++ b/test/test_suite/functions/varargs.c3t @@ -1,8 +1,8 @@ module varargs; -extern func void printf(char* c, ...); +extern fn void printf(char* c, ...); -func void test() +fn void test() { printf("%d\n", true); printf("%d\n", 123); diff --git a/test/test_suite/generic/generic_copy.c3t b/test/test_suite/generic/generic_copy.c3t index 7bbaae001..47f486f5b 100644 --- a/test/test_suite/generic/generic_copy.c3t +++ b/test/test_suite/generic/generic_copy.c3t @@ -1,6 +1,6 @@ module foo; -func void abc() +fn void abc() { int i; defer { i++; } diff --git a/test/test_suite/generic/generic_idents.c3t b/test/test_suite/generic/generic_idents.c3t index 14cb03b22..3ca15b100 100644 --- a/test/test_suite/generic/generic_idents.c3t +++ b/test/test_suite/generic/generic_idents.c3t @@ -1,11 +1,11 @@ module gen ; -func Type mult(Type x) +fn Type mult(Type x) { return x * x; } -func Type addMult(Type x, Type a, Type b) +fn Type addMult(Type x, Type a, Type b) { return x * a + b; } @@ -16,12 +16,12 @@ import gen; define intMult = gen::mult; define doubleAddMult = gen::addMult; -func int getIt(int i) +fn int getIt(int i) { return intMult(i) + 1; } -func double getIt2(double i) +fn double getIt2(double i) { return doubleAddMult(i, 2, 3); } diff --git a/test/test_suite/globals/external_global.c3t b/test/test_suite/globals/external_global.c3t index 5f6ccbb4f..0c7527f98 100644 --- a/test/test_suite/globals/external_global.c3t +++ b/test/test_suite/globals/external_global.c3t @@ -13,9 +13,9 @@ struct UzGlobs MinInfo* pInfo; } -extern UzGlobs g; +extern global UzGlobs g; -func int extract_or_test_files() +fn int extract_or_test_files() { g.pInfo = &g.info; return 0; diff --git a/test/test_suite/globals/global_extname.c3t b/test/test_suite/globals/global_extname.c3t index 26f486e22..71514a523 100644 --- a/test/test_suite/globals/global_extname.c3t +++ b/test/test_suite/globals/global_extname.c3t @@ -1,6 +1,6 @@ module foo; -int baz @extname("foobar") = 123; +global int baz @extname("foobar") = 123; // #expect: foo.ll diff --git a/test/test_suite/import/import_error.c3 b/test/test_suite/import/import_error.c3 index 00d88652f..2a9c1acb9 100644 --- a/test/test_suite/import/import_error.c3 +++ b/test/test_suite/import/import_error.c3 @@ -4,4 +4,4 @@ import std::mem; // #error: was imported more import hello_world; // #error: No module named import test; // #error: Importing the current -func void hello() { } \ No newline at end of file +fn void hello() { } \ No newline at end of file diff --git a/test/test_suite/import/import_error_out_of_order.c3 b/test/test_suite/import/import_error_out_of_order.c3 index 39dd94b1b..63e28ae0c 100644 --- a/test/test_suite/import/import_error_out_of_order.c3 +++ b/test/test_suite/import/import_error_out_of_order.c3 @@ -1,5 +1,5 @@ module foo; -func void hello() {} +fn void hello() {} import bar; // #error: Imports are only allowed directly after the module declaration \ No newline at end of file diff --git a/test/test_suite/initializer_lists/disallowed_lists.c3 b/test/test_suite/initializer_lists/disallowed_lists.c3 index b3ba706d5..abfcb2617 100644 --- a/test/test_suite/initializer_lists/disallowed_lists.c3 +++ b/test/test_suite/initializer_lists/disallowed_lists.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { char* hello = "123"; char[] a = { '1', '2', '3' }; diff --git a/test/test_suite/initializer_lists/fasta.c3t b/test/test_suite/initializer_lists/fasta.c3t index 8e289fb8c..a486f7176 100644 --- a/test/test_suite/initializer_lists/fasta.c3t +++ b/test/test_suite/initializer_lists/fasta.c3t @@ -6,15 +6,15 @@ const IA = 3877u; const IC = 29573u; const SEED = 42u; -uint seed = SEED; +global uint seed = SEED; -func float fasta_rand(float max) +fn float fasta_rand(float max) { seed = (seed * IA + IC) % IM; return max * seed / IM; } -private char[] alu = +private global char[] alu = "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" @@ -23,12 +23,12 @@ private char[] alu = "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; -extern func int atoi(char *s); -extern func int printf(char *s, ...); -extern func void putchar(int c); +extern fn int atoi(char *s); +extern fn int printf(char *s, ...); +extern fn void putchar(int c); -char[] iub = "acgtBDHKMNRSVWY"; -double[] iub_p = { +global char[] iub = "acgtBDHKMNRSVWY"; +global double[] iub_p = { 0.27, 0.12, 0.12, @@ -45,8 +45,8 @@ double[] iub_p = { 0.02, 0.02 }; -char[] homosapiens = "acgt"; -double[] homosapiens_p = { +global char[] homosapiens = "acgt"; +global double[] homosapiens_p = { 0.3029549426680, 0.1979883004921, 0.1975473066391, @@ -56,7 +56,7 @@ double[] homosapiens_p = { const LINELEN = 60; // slowest character-at-a-time output -func void repeat_fasta(char[] seq, int n) +fn void repeat_fasta(char[] seq, int n) { usize len = seq.len; int i = void; @@ -68,7 +68,7 @@ func void repeat_fasta(char[] seq, int n) if (i % LINELEN != 0) putchar('\n'); } -func void random_fasta(char[] symb, double[] probability, int n) +fn void random_fasta(char[] symb, double[] probability, int n) { assert(symb.len == probability.len); int len = probability.len; @@ -89,7 +89,7 @@ func void random_fasta(char[] symb, double[] probability, int n) if (i % LINELEN != 0) putchar('\n'); } -func void main(int argc, char **argv) +fn void main(int argc, char **argv) { int n = 1000; if (argc > 1) n = atoi(argv[1]); diff --git a/test/test_suite/initializer_lists/general_tests.c3t b/test/test_suite/initializer_lists/general_tests.c3t index 898adf128..edb9fc371 100644 --- a/test/test_suite/initializer_lists/general_tests.c3t +++ b/test/test_suite/initializer_lists/general_tests.c3t @@ -11,13 +11,13 @@ struct Bar int y; } -func int test() +fn int test() { Baz ffe = { .x = 1 }; int[1] azz = {}; int[*] a = {}; var $foo = { 11, 22, 33 }; - static int foo1 = $foo[1]; + global int foo1 = $foo[1]; int foo2 = $foo[2]; var $foos = { "Hello!" }; char* str = $foos[0]; diff --git a/test/test_suite/initializer_lists/indexing_into_complist.c3 b/test/test_suite/initializer_lists/indexing_into_complist.c3 index 7254be9c3..27b96140b 100644 --- a/test/test_suite/initializer_lists/indexing_into_complist.c3 +++ b/test/test_suite/initializer_lists/indexing_into_complist.c3 @@ -1,27 +1,27 @@ -func void test() +fn void test() { char* c = { 1, 3, "hello"}[2]; int x; int z = { 1, 3 }[x]; // #error: To subscript a compile time list a compile time integer index is needed } -func void test2() +fn void test2() { int z = { 1, 3 }[-1]; // #error: The index may not be negative } -func void test3() +fn void test3() { int z = { 1, 3 }[0xFFFF_FFFF_FFFF_FFFFu64]; // #error: The index is out of range. } -func void test4() +fn void test4() { int z = { 1, 3 }[2]; // #error: An index of '2' is out of range, a value between 0 and 1 was expected. int z2 = { 1 }[2]; // #error: An index of '2' is out of range, a value of 0 was expected. } -func void test5() +fn void test5() { int z = { 1, 3 }[^4]; // #error: An index of '4' from the end is out of range, a value between 1 and 2 was expected int z2 = { 1 }[^4]; // #error: An index of '4' from the end is out of range, a value of 1 was expected. diff --git a/test/test_suite/initializer_lists/statics.c3t b/test/test_suite/initializer_lists/statics.c3t index 11491de23..0ddd377c6 100644 --- a/test/test_suite/initializer_lists/statics.c3t +++ b/test/test_suite/initializer_lists/statics.c3t @@ -13,16 +13,16 @@ struct Bar } -func void test() +fn void test() { Bar[] b = { { 1, 2 } }; - static Bar[] c = { { 1, 2 } }; + global Bar[] c = { { 1, 2 } }; io::printf("%d %d\n", b[0].y, c[0].y); b[0].y += 1; c[0].y += 1; } -func int main() +fn int main() { test(); test(); diff --git a/test/test_suite/initializer_lists/subarrays.c3t b/test/test_suite/initializer_lists/subarrays.c3t index f42851bcc..e51c8fbfe 100644 --- a/test/test_suite/initializer_lists/subarrays.c3t +++ b/test/test_suite/initializer_lists/subarrays.c3t @@ -14,11 +14,11 @@ struct Bar } -Bar[] arrbar = { { 3, 4 }, { 8, 9 }}; -int[] xd = { 1, 2 }; -int* fofeo = &&(int[2]{ 3, 4 }); +global Bar[] arrbar = { { 3, 4 }, { 8, 9 }}; +global int[] xd = { 1, 2 }; +global int* fofeo = &&(int[2]{ 3, 4 }); -func int main() +fn int main() { Bar w = arrbar[1]; io::printf("%d\n", arrbar[1].x); diff --git a/test/test_suite/initializer_lists/zero_init.c3t b/test/test_suite/initializer_lists/zero_init.c3t index 610f5fb5d..1a7ef8387 100644 --- a/test/test_suite/initializer_lists/zero_init.c3t +++ b/test/test_suite/initializer_lists/zero_init.c3t @@ -10,7 +10,7 @@ struct Bar int x; int y; } -func int test() +fn int test() { int[1] azz = {}; int[*] a = {}; diff --git a/test/test_suite/literals/literal_general.c3t b/test/test_suite/literals/literal_general.c3t index b09e6fdb0..bd38675cd 100644 --- a/test/test_suite/literals/literal_general.c3t +++ b/test/test_suite/literals/literal_general.c3t @@ -1,14 +1,14 @@ // #target: x64-darwin module foo; -int aa = 'ä'; -int x = 'ABCD'; -uint y = 'Helo'; -ushort z = '\x31\x32'; -int d = '\u0031'; -char b = '\x40'; -uint abc = '\U133222AB'; -uint foo = '謝'; +global int aa = 'ä'; +global int x = 'ABCD'; +global uint y = 'Helo'; +global ushort z = '\x31\x32'; +global int d = '\u0031'; +global char b = '\x40'; +global uint abc = '\U133222AB'; +global uint foo = '謝'; /* #expect: foo.ll diff --git a/test/test_suite/macro_methods/access.c3 b/test/test_suite/macro_methods/access.c3 index 2221e3b2b..b381aeca2 100644 --- a/test/test_suite/macro_methods/access.c3 +++ b/test/test_suite/macro_methods/access.c3 @@ -12,20 +12,20 @@ struct An2 { } -extern func void printf(char *string); +extern fn void printf(char *string); macro void An2.helloWorld(An2 *an2) { printf("An2 hello\n"); } -func void check() +fn void check() { printf("Checking\n"); } -func void main() +fn void main() { An1 an; an.x.y.@helloWorld(); diff --git a/test/test_suite/macro_methods/macro_method_fails.c3 b/test/test_suite/macro_methods/macro_method_fails.c3 index be2bf0be0..2253bddcc 100644 --- a/test/test_suite/macro_methods/macro_method_fails.c3 +++ b/test/test_suite/macro_methods/macro_method_fails.c3 @@ -12,44 +12,44 @@ struct An2 { } -extern func void printf(char *string); +extern fn void printf(char *string); macro void An2.helloWorld(An2 *an2) { printf("An2 hello\n"); } -func void check() +fn void check() { printf("Checking\n"); } -func void test1() +fn void test1() { An1 an; an.x.y.@helloWorld; // #error: macro name must be followed by '(' } -func void test2() +fn void test2() { An2 a; a.@helloWorld; // #error: A macro name must be followed by '(' } -func void test3() +fn void test3() { An2 a; a.@helloWorld.b; // #error: There is no member or method 'b' on 'void' } -func void test4() +fn void test4() { An1 an; an.x.@y; // #error: '@' should only be placed in front of macro names } -func void test5() +fn void test5() { An1 an; an.x.@y(); // #error: '@' should only be placed in front of macro names diff --git a/test/test_suite/macro_methods/macro_methods_defined_twice.c3 b/test/test_suite/macro_methods/macro_methods_defined_twice.c3 index 6b6517cf0..f79f218dd 100644 --- a/test/test_suite/macro_methods/macro_methods_defined_twice.c3 +++ b/test/test_suite/macro_methods/macro_methods_defined_twice.c3 @@ -23,7 +23,7 @@ module abc; import foo; import baz; -func void main() +fn void main() { Bar bar; bar.test(); diff --git a/test/test_suite/macros/hash_ident.c3 b/test/test_suite/macros/hash_ident.c3 index ebb2e1ea5..192b00f1e 100644 --- a/test/test_suite/macros/hash_ident.c3 +++ b/test/test_suite/macros/hash_ident.c3 @@ -6,13 +6,13 @@ macro int cofefe(#a) private int abc = 1; -func int xx() +fn int xx() { abc++; return abc; } -func void main() +fn void main() { var $x = 0; int x = 0; diff --git a/test/test_suite/macros/macro_body_as_value.c3 b/test/test_suite/macros/macro_body_as_value.c3 index 851e3d74a..aea846468 100644 --- a/test/test_suite/macros/macro_body_as_value.c3 +++ b/test/test_suite/macros/macro_body_as_value.c3 @@ -3,7 +3,7 @@ macro foo4(;@body) @body; // #error: must be followed by () } -func void test() +fn void test() { @foo4() { diff --git a/test/test_suite/macros/macro_common.c3t b/test/test_suite/macros/macro_common.c3t index 269579e61..1e7bd6c58 100644 --- a/test/test_suite/macros/macro_common.c3t +++ b/test/test_suite/macros/macro_common.c3t @@ -6,7 +6,7 @@ macro frab(x) return 0.0; } -func void test2() +fn void test2() { @frab(1); @frab(0); diff --git a/test/test_suite/macros/macro_convert_literal.c3 b/test/test_suite/macros/macro_convert_literal.c3 index 3f25ff9f8..a6e41023a 100644 --- a/test/test_suite/macros/macro_convert_literal.c3 +++ b/test/test_suite/macros/macro_convert_literal.c3 @@ -6,7 +6,7 @@ macro foo(y) return y * y; } -func void main() +fn void main() { io::printf("%d\n", @foo(10)); } \ No newline at end of file diff --git a/test/test_suite/macros/macro_import_resolution.c3 b/test/test_suite/macros/macro_import_resolution.c3 index 02858819e..d375ccf3b 100644 --- a/test/test_suite/macros/macro_import_resolution.c3 +++ b/test/test_suite/macros/macro_import_resolution.c3 @@ -1,6 +1,6 @@ module foo; import bar; -func void run() +fn void run() { @bar::test(); } @@ -10,4 +10,4 @@ import baz; macro test() { baz::test(); } module baz; -func void test() {} \ No newline at end of file +fn void test() {} \ No newline at end of file diff --git a/test/test_suite/macros/macro_resolution.c3 b/test/test_suite/macros/macro_resolution.c3 index d63051d52..07b8e6db4 100644 --- a/test/test_suite/macros/macro_resolution.c3 +++ b/test/test_suite/macros/macro_resolution.c3 @@ -1,16 +1,16 @@ module foo; import bar; -func void run() +fn void run() { @bar::test(); } -func void run2() +fn void run2() { @bar::test2(); } -func void tester() {} +fn void tester() {} module bar; macro test() diff --git a/test/test_suite/macros/macro_rtype.c3 b/test/test_suite/macros/macro_rtype.c3 index ee51bfb97..bb95c1daa 100644 --- a/test/test_suite/macros/macro_rtype.c3 +++ b/test/test_suite/macros/macro_rtype.c3 @@ -3,7 +3,7 @@ macro int frob() return 0.0; // #error: Expected 'int', not 'double'. } -func void test1() +fn void test1() { @frob(); } \ No newline at end of file diff --git a/test/test_suite/macros/macro_with_body.c3t b/test/test_suite/macros/macro_with_body.c3t index c89d16ecc..7d59e3f20 100644 --- a/test/test_suite/macros/macro_with_body.c3t +++ b/test/test_suite/macros/macro_with_body.c3t @@ -1,14 +1,14 @@ module withbody; -extern func int printf(char *, ...); +extern fn int printf(char *, ...); struct Foo { int x; } -func int Foo.mutate(Foo *foo) +fn int Foo.mutate(Foo *foo) { printf("Mutating\n"); return 10 * ++foo.x; @@ -28,7 +28,7 @@ macro repeat(int times; @body(x)) } } -func void main() +fn void main() { Foo f = { 33 }; int y; diff --git a/test/test_suite/macros/no_body.c3 b/test/test_suite/macros/no_body.c3 index d871db878..14bdb5655 100644 --- a/test/test_suite/macros/no_body.c3 +++ b/test/test_suite/macros/no_body.c3 @@ -1,25 +1,25 @@ module test; -extern func int printf(char *, ...); +extern fn int printf(char *, ...); macro foo(x; @body(y)) { @body(x); } -func void test() +fn void test() { @foo(10); // #error: Expected call to have a trailing statement, did you forget to add it? } -func void test3() +fn void test3() { @foo(10) // #error: Not enough parameters { }; } -func void test5() +fn void test5() { @foo(10; int a, int b) // #error: Too many parameters for the macro body, expected { @@ -30,7 +30,7 @@ macro foo_no(x) return x; } -func void test2() +fn void test2() { @foo_no(10) // #error: This macro does not support trailing statements { @@ -43,7 +43,7 @@ macro foo2(x) @body(x); // #error: 'body' could not be found, did you spell it right? } -func void test4() +fn void test4() { @foo2(10); } diff --git a/test/test_suite/macros/type_params.c3t b/test/test_suite/macros/type_params.c3t index 4d108c124..4354361a5 100644 --- a/test/test_suite/macros/type_params.c3t +++ b/test/test_suite/macros/type_params.c3t @@ -6,7 +6,7 @@ macro foo($Foo) } define Bar = short; -func void test() +fn void test() { int x = @foo(int); var $Foo = double; diff --git a/test/test_suite/macros/userland_bitcast.c3t b/test/test_suite/macros/userland_bitcast.c3t index 2e380f2cb..36e230cf1 100644 --- a/test/test_suite/macros/userland_bitcast.c3t +++ b/test/test_suite/macros/userland_bitcast.c3t @@ -37,7 +37,7 @@ macro testbitcast(expr, $Type) return x; } -extern func void printf(char*, ...); +extern fn void printf(char*, ...); struct Foo { @@ -48,19 +48,19 @@ struct Foo short e; } -func ulong testFoo(short x) +fn ulong testFoo(short x) { Foo z; z.a = x; return @testbitcast(z, ulong); } -func char[4] test(float x) +fn char[4] test(float x) { return @testbitcast(x, char[4]); } -func void main() +fn void main() { float f = 12.353; int i = @testbitcast(f, int); diff --git a/test/test_suite/methods/access.c3 b/test/test_suite/methods/access.c3 index d3f15df2e..ab3391c11 100644 --- a/test/test_suite/methods/access.c3 +++ b/test/test_suite/methods/access.c3 @@ -1,4 +1,4 @@ -extern func void printf(...); +extern fn void printf(...); struct An1 { @@ -10,25 +10,25 @@ struct An3 An2 y; } -define AnCall = func void(); +define AnCall = fn void(); struct An2 { AnCall t; } -func void An2.helloWorld(An2 *an2) +fn void An2.helloWorld(An2 *an2) { printf("An2 hello\n"); } -func void check() +fn void check() { printf("Checking\n"); } -func void main() +fn void main() { An1 an; an.x.y.helloWorld(); diff --git a/test/test_suite/methods/enum_distinct_err_methods.c3t b/test/test_suite/methods/enum_distinct_err_methods.c3t index 35a2af87a..15176704e 100644 --- a/test/test_suite/methods/enum_distinct_err_methods.c3t +++ b/test/test_suite/methods/enum_distinct_err_methods.c3t @@ -16,21 +16,21 @@ enum MyEnum B } -func void Foo.hello(Foo *f) +fn void Foo.hello(Foo *f) { io::println("Hello from Foo"); } -func void Bar.hello(Bar *b) +fn void Bar.hello(Bar *b) { io::println("Hello from Bar"); } -func void MyEnum.hello(MyEnum *myenum) +fn void MyEnum.hello(MyEnum *myenum) { io::println("Hello from MyEnum"); } -func void main() +fn void main() { Foo f; Bar b; diff --git a/test/test_suite/methods/extension_method.c3t b/test/test_suite/methods/extension_method.c3t index c88790923..2b1281421 100644 --- a/test/test_suite/methods/extension_method.c3t +++ b/test/test_suite/methods/extension_method.c3t @@ -9,7 +9,7 @@ module baz; import foo; import std::io; -func void foo::Bar.test(Bar *bar) +fn void foo::Bar.test(Bar *bar) { io::println("Inside of baz::Bar.test"); } @@ -18,7 +18,7 @@ module abc; import foo; import baz; -func void main() +fn void main() { Bar bar; bar.test(); diff --git a/test/test_suite/methods/extension_method_already_exist.c3 b/test/test_suite/methods/extension_method_already_exist.c3 index 574e7a965..beccdbca1 100644 --- a/test/test_suite/methods/extension_method_already_exist.c3 +++ b/test/test_suite/methods/extension_method_already_exist.c3 @@ -1,6 +1,6 @@ module foo; -func void Bar.test(Bar *bar) +fn void Bar.test(Bar *bar) { io::println("Inside of baz::Bar.test"); } @@ -14,7 +14,7 @@ module baz; import foo; import std::io; -func void foo::Bar.test(Bar *bar) // #error: This method is already defined for 'Bar' +fn void foo::Bar.test(Bar *bar) // #error: This method is already defined for 'Bar' { io::println("Inside of baz::Bar.test"); } @@ -23,7 +23,7 @@ module abc; import foo; import baz; -func void main() +fn void main() { Bar bar; bar.test(); diff --git a/test/test_suite/methods/methods_defined_twice.c3 b/test/test_suite/methods/methods_defined_twice.c3 index 67adb4b0e..60d809b6f 100644 --- a/test/test_suite/methods/methods_defined_twice.c3 +++ b/test/test_suite/methods/methods_defined_twice.c3 @@ -9,12 +9,12 @@ module baz; import foo; import std::io; -func void foo::Bar.test(Bar *bar) +fn void foo::Bar.test(Bar *bar) { io::println("Inside of baz::Bar.test"); } -func void Bar.test(Bar *bar) // #error: This method is already defined in this module +fn void Bar.test(Bar *bar) // #error: This method is already defined in this module { io::println("Inside of baz::Bar.test"); } @@ -23,7 +23,7 @@ module abc; import foo; import baz; -func void main() +fn void main() { Bar bar; bar.test(); diff --git a/test/test_suite/pointers/const_pointer.c3t b/test/test_suite/pointers/const_pointer.c3t index 1b24c70c8..9a3e95558 100644 --- a/test/test_suite/pointers/const_pointer.c3t +++ b/test/test_suite/pointers/const_pointer.c3t @@ -2,11 +2,11 @@ module const_pointer; -private double foo = 17; -private double bar = 12.0; -private float xx = 12.0; +private global double foo = 17; +private global double bar = 12.0; +private global float xx = 12.0; -private void*[3] data = { &foo, &bar, &xx }; +private global void*[3] data = { &foo, &bar, &xx }; // #expect: const_pointer.ll diff --git a/test/test_suite/pointers/pointer_index.c3t b/test/test_suite/pointers/pointer_index.c3t index 6997e9e49..97ab79e61 100644 --- a/test/test_suite/pointers/pointer_index.c3t +++ b/test/test_suite/pointers/pointer_index.c3t @@ -1,6 +1,6 @@ module pointer_index; -func void test1(int* x) +fn void test1(int* x) { int a = x[0]; int b = *x; @@ -8,14 +8,14 @@ func void test1(int* x) int d = x[-1]; } -func void test2(char* x) +fn void test2(char* x) { char a = x[0]; char b = *x; char c = x[1]; } -func void test3(long* x) +fn void test3(long* x) { long a = x[0]; long b = *x; diff --git a/test/test_suite/precedence/required_parens.c3 b/test/test_suite/precedence/required_parens.c3 index 25fb162f4..176469480 100644 --- a/test/test_suite/precedence/required_parens.c3 +++ b/test/test_suite/precedence/required_parens.c3 @@ -1,7 +1,7 @@ module foo; import std::io; -func void main() +fn void main() { int i = 0; int j = i ^ i | i; // #error: You need to add explicit parentheses to clarify precedence. diff --git a/test/test_suite/statements/binary_fail.c3 b/test/test_suite/statements/binary_fail.c3 index 9f60a9781..cb243ba8b 100644 --- a/test/test_suite/statements/binary_fail.c3 +++ b/test/test_suite/statements/binary_fail.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { float a; float b; diff --git a/test/test_suite/statements/call_missing_paren.c3 b/test/test_suite/statements/call_missing_paren.c3 index 7cf028ba2..1ccb83f99 100644 --- a/test/test_suite/statements/call_missing_paren.c3 +++ b/test/test_suite/statements/call_missing_paren.c3 @@ -1,6 +1,6 @@ -func void foo(int a) {} +fn void foo(int a) {} -func int main() +fn int main() { foo(10, foo(); // #error: Expected the ending ')' return 0; diff --git a/test/test_suite/statements/comparison_widening.c3t b/test/test_suite/statements/comparison_widening.c3t index 6a8ec9e4d..d37fb28ea 100644 --- a/test/test_suite/statements/comparison_widening.c3t +++ b/test/test_suite/statements/comparison_widening.c3t @@ -1,6 +1,6 @@ // #target: x64-darwin -func void test1() +fn void test1() { char a = 1; int b = 2; diff --git a/test/test_suite/statements/conditional_return.c3 b/test/test_suite/statements/conditional_return.c3 index 5ca9aeeb6..1337d5c26 100644 --- a/test/test_suite/statements/conditional_return.c3 +++ b/test/test_suite/statements/conditional_return.c3 @@ -1,4 +1,4 @@ -func int testReturnWithConditional() +fn int testReturnWithConditional() { int i = 0; if (i > 0) diff --git a/test/test_suite/statements/default_args.c3 b/test/test_suite/statements/default_args.c3 index 8f567c437..86005a917 100644 --- a/test/test_suite/statements/default_args.c3 +++ b/test/test_suite/statements/default_args.c3 @@ -1,2 +1,2 @@ -define Foo = func void(int a = 10); // #error: Function types may not have default arguments. +define Foo = fn void(int a = 10); // #error: Function types may not have default arguments. diff --git a/test/test_suite/statements/defer_break.c3t b/test/test_suite/statements/defer_break.c3t index c9083e337..6461ebf70 100644 --- a/test/test_suite/statements/defer_break.c3t +++ b/test/test_suite/statements/defer_break.c3t @@ -1,20 +1,20 @@ module foo; -extern func void printf(char* message, ...); +extern fn void printf(char* message, ...); -func void defer1() {} -func void defer2() {} -func void defer3() {} -func void defer4() {} -func void defer5() {} -func void defer6() {} -func void defer7() {} -func void defer8() {} -func void defer9() {} -func void defer10() {} -func void defer11() {} +fn void defer1() {} +fn void defer2() {} +fn void defer3() {} +fn void defer4() {} +fn void defer5() {} +fn void defer6() {} +fn void defer7() {} +fn void defer8() {} +fn void defer9() {} +fn void defer10() {} +fn void defer11() {} -func int main(int argc) +fn int main(int argc) { int a = 0; { diff --git a/test/test_suite/statements/defer_break_simple.c3t b/test/test_suite/statements/defer_break_simple.c3t index c6fb9f74b..bd1fda0d8 100644 --- a/test/test_suite/statements/defer_break_simple.c3t +++ b/test/test_suite/statements/defer_break_simple.c3t @@ -1,11 +1,11 @@ module test; -func void test2() {} -func void testA() {} -func void testB() {} -func void test3() {} +fn void test2() {} +fn void testA() {} +fn void testB() {} +fn void test3() {} -func int main(int argc) +fn int main(int argc) { int a = 0; while (a) diff --git a/test/test_suite/statements/defer_break_switch.c3t b/test/test_suite/statements/defer_break_switch.c3t index 73bb43f94..1a21917ac 100644 --- a/test/test_suite/statements/defer_break_switch.c3t +++ b/test/test_suite/statements/defer_break_switch.c3t @@ -1,11 +1,11 @@ -func void test1() +fn void test1() {} -func void test2() +fn void test2() {} -func void test(int i) +fn void test(int i) { bool b = true; switch (i) diff --git a/test/test_suite/statements/defer_in_defer.c3t b/test/test_suite/statements/defer_in_defer.c3t index 16af90c18..10f04d6d9 100644 --- a/test/test_suite/statements/defer_in_defer.c3t +++ b/test/test_suite/statements/defer_in_defer.c3t @@ -1,10 +1,10 @@ -func void test1() {} -func void test2() {} -func void test3() {} -func void test4() {} +fn void test1() {} +fn void test2() {} +fn void test3() {} +fn void test4() {} -func void test() +fn void test() { defer { @@ -15,7 +15,7 @@ func void test() test4(); } -func void test_line() +fn void test_line() { defer defer test1(); } diff --git a/test/test_suite/statements/defer_next_switch.c3t b/test/test_suite/statements/defer_next_switch.c3t index 0b85418b4..ad638d907 100644 --- a/test/test_suite/statements/defer_next_switch.c3t +++ b/test/test_suite/statements/defer_next_switch.c3t @@ -1,11 +1,11 @@ -func void test1() +fn void test1() {} -func void test2() +fn void test2() {} -func void test(int i) +fn void test(int i) { bool b = true; switch (i) diff --git a/test/test_suite/statements/defer_return.c3t b/test/test_suite/statements/defer_return.c3t index 2b5617da2..1435ed567 100644 --- a/test/test_suite/statements/defer_return.c3t +++ b/test/test_suite/statements/defer_return.c3t @@ -1,15 +1,15 @@ module test; -func void test1() {} -func void test2() {} -func void test3() {} -func void test4() {} -func void test5() {} -func void test6() {} -func void test7() {} -func void test8() {} -func void test9() {} +fn void test1() {} +fn void test2() {} +fn void test3() {} +fn void test4() {} +fn void test5() {} +fn void test6() {} +fn void test7() {} +fn void test8() {} +fn void test9() {} -func int main(int argc) +fn int main(int argc) { defer test1(); int a = 0; diff --git a/test/test_suite/statements/defer_test.c3 b/test/test_suite/statements/defer_test.c3 index 69e897b8e..6d240f8f9 100644 --- a/test/test_suite/statements/defer_test.c3 +++ b/test/test_suite/statements/defer_test.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { int i = 0; defer diff --git a/test/test_suite/statements/for.c3 b/test/test_suite/statements/for.c3 index 9c285002d..3dc2e9a52 100644 --- a/test/test_suite/statements/for.c3 +++ b/test/test_suite/statements/for.c3 @@ -2,7 +2,7 @@ module for_test; -func int test1() +fn int test1() { for (int x = 0;;) { @@ -10,7 +10,7 @@ func int test1() return 0; } -func int test2() +fn int test2() { for (int x = 0; 1 ;) { @@ -18,7 +18,7 @@ func int test2() return 0; } -func int test3() +fn int test3() { for (; 1 ;2) { diff --git a/test/test_suite/statements/for_empty.c3 b/test/test_suite/statements/for_empty.c3 index dce7890e7..3536032da 100644 --- a/test/test_suite/statements/for_empty.c3 +++ b/test/test_suite/statements/for_empty.c3 @@ -1,4 +1,4 @@ -func int main() +fn int main() { for (;;); diff --git a/test/test_suite/statements/for_errors.c3 b/test/test_suite/statements/for_errors.c3 index 27ee0c284..5da7a96e1 100644 --- a/test/test_suite/statements/for_errors.c3 +++ b/test/test_suite/statements/for_errors.c3 @@ -1,6 +1,6 @@ -func void foo() {} +fn void foo() {} -func int main() +fn int main() { for (; foo() ; ) {} // #error: 'void' into 'bool' return 0; diff --git a/test/test_suite/statements/for_with_extra_declarations.c3 b/test/test_suite/statements/for_with_extra_declarations.c3 index d1e2b493c..12a04a1f7 100644 --- a/test/test_suite/statements/for_with_extra_declarations.c3 +++ b/test/test_suite/statements/for_with_extra_declarations.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { int j; for (int i = 0; i < 10; i++) diff --git a/test/test_suite/statements/foreach_break.c3t b/test/test_suite/statements/foreach_break.c3t index e9b47c63e..8080720a8 100644 --- a/test/test_suite/statements/foreach_break.c3t +++ b/test/test_suite/statements/foreach_break.c3t @@ -1,6 +1,6 @@ module test; -func void test() +fn void test() { int[3] x; int g = 0; diff --git a/test/test_suite/statements/foreach_common.c3t b/test/test_suite/statements/foreach_common.c3t index 17e80aad1..474aaa764 100644 --- a/test/test_suite/statements/foreach_common.c3t +++ b/test/test_suite/statements/foreach_common.c3t @@ -1,8 +1,8 @@ module test; -extern func void printf(char*, ...); +extern fn void printf(char*, ...); -func void main() +fn void main() { float[3] foo = { 2, 4.5, 8 }; foreach (a : foo) diff --git a/test/test_suite/statements/foreach_custom.c3t b/test/test_suite/statements/foreach_custom.c3t index 0013c3644..9ade5d4f9 100644 --- a/test/test_suite/statements/foreach_custom.c3t +++ b/test/test_suite/statements/foreach_custom.c3t @@ -11,19 +11,19 @@ struct FooIterator usize index; Foo *f; } -func FooIterator Foo.iterator(Foo *f) +fn FooIterator Foo.iterator(Foo *f) { return FooIterator {0, f}; } -func bool FooIterator.next(FooIterator *it, int *value) +fn bool FooIterator.next(FooIterator *it, int *value) { if (it.index == it.f.x.len) return false; *value = it.f.x[it.index++]; return true; } -func void main() +fn void main() { int[*] i = { 1, 3, 10 }; Foo x = { &i }; @@ -36,7 +36,7 @@ func void main() } } -extern func int printf(char *fmt, ...); +extern fn int printf(char *fmt, ...); // #expect: foo.ll diff --git a/test/test_suite/statements/foreach_custom_errors.c3 b/test/test_suite/statements/foreach_custom_errors.c3 index cf0e898df..20dc9aa3d 100644 --- a/test/test_suite/statements/foreach_custom_errors.c3 +++ b/test/test_suite/statements/foreach_custom_errors.c3 @@ -1,4 +1,4 @@ -func void test1() +fn void test1() { int x; foreach (a : x) { }; // #error: It's not possible to enumerate an expression of type 'int' @@ -6,7 +6,7 @@ func void test1() define Test1 = distinct int; -func void test2() +fn void test2() { Test1 x; foreach (a : x) { }; // #error: This type cannot be iterated over, implement a method or method macro called 'iterator' @@ -15,9 +15,9 @@ func void test2() struct Test3 {} -func void Test3.iterator(Test3* x, int y) { } +fn void Test3.iterator(Test3* x, int y) { } -func void test3() +fn void test3() { Test3 x; foreach (a : x) { }; // #error: 'iterator()' takes parameters and can't be used for 'foreach'. @@ -28,7 +28,7 @@ struct Test4 macro Test4.iterator(Test4* x) { } -func void test4() +fn void test4() { Test4 x; foreach (a : x) { }; // #error: This type has an iterator without a declared result type, this can't be used with 'foreach' @@ -37,9 +37,9 @@ func void test4() struct Test5 {} -func int Test5.iterator(Test5* x) { return 1; } +fn int Test5.iterator(Test5* x) { return 1; } -func void test5() +fn void test5() { Test5 x; foreach (a : x) { }; // #error: This type has an implementation of 'iterator()' that doesn't return a struct, so it can't be used with 'foreach' @@ -48,12 +48,12 @@ func void test5() struct Test6 {} -func TestIterator6 Test6.iterator(Test6* x) { return TestIterator6{}; } +fn TestIterator6 Test6.iterator(Test6* x) { return TestIterator6{}; } struct TestIterator6 {} -func void test6() +fn void test6() { Test6 x; foreach (a : x) { }; // #error: The iterator 'TestIterator6' is missing a definition for 'next()' @@ -62,14 +62,14 @@ func void test6() struct Test7 {} -func TestIterator7 Test7.iterator(Test7* x) { return TestIterator7{}; } +fn TestIterator7 Test7.iterator(Test7* x) { return TestIterator7{}; } struct TestIterator7 {} -func bool TestIterator7.next(TestIterator7* x, int a, int b) { return true; } +fn bool TestIterator7.next(TestIterator7* x, int a, int b) { return true; } -func void test7() +fn void test7() { Test7 x; foreach (a : x) { }; // #error: An iterator with a 'next()' that take takes 2 parameters can't be used for 'foreach', it should have 1. diff --git a/test/test_suite/statements/foreach_custom_macro.c3t b/test/test_suite/statements/foreach_custom_macro.c3t index 198112872..e28d6c0fc 100644 --- a/test/test_suite/statements/foreach_custom_macro.c3t +++ b/test/test_suite/statements/foreach_custom_macro.c3t @@ -21,7 +21,7 @@ macro bool FooIterator.next(FooIterator *it, int *value) return true; } -func void main() +fn void main() { int[*] i = { 1, 3, 10 }; Foo x = { &i }; @@ -34,7 +34,7 @@ func void main() } } -extern func int printf(char *fmt, ...); +extern fn int printf(char *fmt, ...); // #expect: foo.ll diff --git a/test/test_suite/statements/foreach_errors.c3 b/test/test_suite/statements/foreach_errors.c3 index c3afb1db8..004dc950f 100644 --- a/test/test_suite/statements/foreach_errors.c3 +++ b/test/test_suite/statements/foreach_errors.c3 @@ -1,9 +1,9 @@ module test; -extern func void foo(); +extern fn void foo(); int[3] z; -func void test1() +fn void test1() { int x; foreach (a : x) // #error: It's not possible to enumerate an expression of type 'int'. @@ -12,42 +12,42 @@ func void test1() } } -func void test2() +fn void test2() { foreach (a : z) foo(); foreach (i, a : z) foo(); foreach (double i, a : z); // #error: Index must be an integer type, 'double' is not valid. } -func void test3() +fn void test3() { foreach (&a : z) foo(); foreach (&i, &a : z) foo(); // #error: The index cannot be held by reference, did you accidentally add a '&'? } -func void test4() +fn void test4() { foreach (&a : z) foo(); foreach (&i, a : z) foo(); // #error: The index cannot be held by reference, did you accidentally add a '&'? } -func void test5() +fn void test5() { foreach (int! y : z) foo(); // #error: The variable may not be a failable. } -func void test6() +fn void test6() { foreach (int! i, y : z) foo(); // #error: The index may not be a failable. } -func void test7() +fn void test7() { foreach (int a : { 1, 2, 3 }) foo(); foreach (a : { 1, 2, 3 }) foo(); // #error: Add the type of your variable here if you want to iterate over } -func void test8() +fn void test8() { foreach (int a : { z }) foo(); // #error: 'int[3]' into 'int' } diff --git a/test/test_suite/statements/foreach_parse_error.c3 b/test/test_suite/statements/foreach_parse_error.c3 index 38d1e0ceb..4a761601a 100644 --- a/test/test_suite/statements/foreach_parse_error.c3 +++ b/test/test_suite/statements/foreach_parse_error.c3 @@ -1,4 +1,4 @@ -func void test9() +fn void test9() { foreach (int a : { [2] = 1 }) foo(); foreach (int a : { [2] = 2, 1 }) foo(); // #error: Normal initialization cannot be mixed with designated initialization. diff --git a/test/test_suite/statements/foreach_with_error.c3 b/test/test_suite/statements/foreach_with_error.c3 index 6a68e8700..9554b4537 100644 --- a/test/test_suite/statements/foreach_with_error.c3 +++ b/test/test_suite/statements/foreach_with_error.c3 @@ -1,6 +1,6 @@ module test; -func void test() +fn void test() { int[3]! x; int g; diff --git a/test/test_suite/statements/if_decl.c3 b/test/test_suite/statements/if_decl.c3 index b6412d118..ad245ec61 100644 --- a/test/test_suite/statements/if_decl.c3 +++ b/test/test_suite/statements/if_decl.c3 @@ -1,4 +1,4 @@ -func int main() +fn int main() { if (int a) {} // #error: Expected a declaration with initializer return 0; diff --git a/test/test_suite/statements/if_single.c3 b/test/test_suite/statements/if_single.c3 index efc2146dc..94ae517ca 100644 --- a/test/test_suite/statements/if_single.c3 +++ b/test/test_suite/statements/if_single.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { int x = 0; if (x < 0) x++; diff --git a/test/test_suite/statements/if_tests.c3t b/test/test_suite/statements/if_tests.c3t index f0a0eb957..3268fc682 100644 --- a/test/test_suite/statements/if_tests.c3t +++ b/test/test_suite/statements/if_tests.c3t @@ -1,6 +1,6 @@ module iftest; -func void test1(int x) +fn void test1(int x) { if (x > 0) { @@ -10,7 +10,7 @@ func void test1(int x) {} } -func void test2(int x) +fn void test2(int x) { if (x > 0) { @@ -19,7 +19,7 @@ func void test2(int x) {} } -func void test3(int x) +fn void test3(int x) { if (x > 0) {} diff --git a/test/test_suite/statements/if_while_do_error.c3 b/test/test_suite/statements/if_while_do_error.c3 index 66859d951..d987de523 100644 --- a/test/test_suite/statements/if_while_do_error.c3 +++ b/test/test_suite/statements/if_while_do_error.c3 @@ -1,6 +1,6 @@ module test; -func void test1() +fn void test1() { bool! x = 0; if (x) // #error: 'bool!' to 'bool' @@ -9,7 +9,7 @@ func void test1() } } -func void test2() +fn void test2() { bool! x = 0; while (x) // #error: 'bool!' to 'bool' @@ -18,7 +18,7 @@ func void test2() } } -func void test3() +fn void test3() { bool! x = 0; double y = 1; diff --git a/test/test_suite/statements/label_errors.c3 b/test/test_suite/statements/label_errors.c3 index 0e5cf5bc7..61b579f3b 100644 --- a/test/test_suite/statements/label_errors.c3 +++ b/test/test_suite/statements/label_errors.c3 @@ -1,5 +1,5 @@ -func int main() +fn int main() { do FOO: { @@ -12,7 +12,7 @@ func int main() } -func void test1() +fn void test1() { do FOO: { diff --git a/test/test_suite/statements/labelled_continue_for.c3t b/test/test_suite/statements/labelled_continue_for.c3t index a7c5af692..9d9eae177 100644 --- a/test/test_suite/statements/labelled_continue_for.c3t +++ b/test/test_suite/statements/labelled_continue_for.c3t @@ -1,9 +1,9 @@ -func void errored() +fn void errored() {} -func void test() {} +fn void test() {} -func void testBreak() +fn void testBreak() { for FOO: (int i = 0; i < 10; i++) { diff --git a/test/test_suite/statements/return_stmt.c3 b/test/test_suite/statements/return_stmt.c3 index 257d7516b..51da39f94 100644 --- a/test/test_suite/statements/return_stmt.c3 +++ b/test/test_suite/statements/return_stmt.c3 @@ -1,10 +1,10 @@ -func void testNoReturn() +fn void testNoReturn() { int i = 0; i = -i; } -func int testReturn() +fn int testReturn() { int i = 0; return i; diff --git a/test/test_suite/statements/return_switch.c3t b/test/test_suite/statements/return_switch.c3t index 4d185d67b..40b43ea6b 100644 --- a/test/test_suite/statements/return_switch.c3t +++ b/test/test_suite/statements/return_switch.c3t @@ -1,4 +1,4 @@ -func int testReturnSwitch() +fn int testReturnSwitch() { int i = 0; switch (i) diff --git a/test/test_suite/statements/return_with_other_at_end.c3 b/test/test_suite/statements/return_with_other_at_end.c3 index d8655df4b..09c6384e6 100644 --- a/test/test_suite/statements/return_with_other_at_end.c3 +++ b/test/test_suite/statements/return_with_other_at_end.c3 @@ -1,4 +1,4 @@ -func int testReturnWithOtherAtEnd() +fn int testReturnWithOtherAtEnd() { int i = 0; return i; diff --git a/test/test_suite/statements/switch_errors.c3 b/test/test_suite/statements/switch_errors.c3 index e55e23a1b..c67b45469 100644 --- a/test/test_suite/statements/switch_errors.c3 +++ b/test/test_suite/statements/switch_errors.c3 @@ -9,7 +9,7 @@ enum Bar B } -func void test_other_enum() +fn void test_other_enum() { Foo f = A; switch (f) @@ -23,7 +23,7 @@ func void test_other_enum() } } -func void test_check_nums() +fn void test_check_nums() { Foo f = A; switch (f) @@ -35,7 +35,7 @@ func void test_check_nums() } } -func void test_scope(int i) +fn void test_scope(int i) { switch (i) { @@ -47,7 +47,7 @@ func void test_scope(int i) } } -func void test_duplicate_case(int i) +fn void test_duplicate_case(int i) { switch (i) { @@ -60,7 +60,7 @@ func void test_duplicate_case(int i) } } -func void test_duplicate_case2(Foo i) +fn void test_duplicate_case2(Foo i) { switch (i) { @@ -73,7 +73,7 @@ func void test_duplicate_case2(Foo i) } } -func void test_duplicate_case3(Foo i) +fn void test_duplicate_case3(Foo i) { switch (i) { @@ -89,14 +89,14 @@ enum Baz A, B, C, D } -func void test_missing_all_cases(Baz x) +fn void test_missing_all_cases(Baz x) { switch (x) // -error: 4 enumeration values not handled in switch: A, B, C, ... { } } -func void test_missing_some_cases(Baz x) +fn void test_missing_some_cases(Baz x) { switch (x) // -error: 4 enumeration B, C and D not handled in switch { @@ -105,7 +105,7 @@ func void test_missing_some_cases(Baz x) } } -func void test_missing_some_cases2(Baz x) +fn void test_missing_some_cases2(Baz x) { switch (x) // -error: 4 enumeration B and D not handled in switch { @@ -115,7 +115,7 @@ func void test_missing_some_cases2(Baz x) } } -func void test_missing_some_cases3(Baz x) +fn void test_missing_some_cases3(Baz x) { switch (x) // -error: 4 enumeration B and D not handled in switch { @@ -126,7 +126,7 @@ func void test_missing_some_cases3(Baz x) } } -func void test_missing_no_cases(Baz x) +fn void test_missing_no_cases(Baz x) { switch (x) { @@ -141,11 +141,11 @@ errtype MathError } // Rethrowing an error uses "!!" suffix -func void! testMayError() +fn void! testMayError() { } -func void main() +fn void main() { // Handle the error switch (catch err = testMayError()) // #error: Catch unwrapping is only allowed diff --git a/test/test_suite/statements/various_switching.c3t b/test/test_suite/statements/various_switching.c3t index d565ce487..0db2515b2 100644 --- a/test/test_suite/statements/various_switching.c3t +++ b/test/test_suite/statements/various_switching.c3t @@ -1,6 +1,6 @@ module mymodule; -extern func void printf(char *, ...); +extern fn void printf(char *, ...); errtype HelloErr { @@ -12,7 +12,7 @@ errtype ByeErr BAZ } -func void test() +fn void test() { int! x = ByeErr.BAR!; @@ -50,7 +50,7 @@ func void test() printf("None of the above\n"); } } -func void main() +fn void main() { test(); printf("Hello!\n"); diff --git a/test/test_suite/statements/while_statement_placement.c3 b/test/test_suite/statements/while_statement_placement.c3 index db5433899..66473b6eb 100644 --- a/test/test_suite/statements/while_statement_placement.c3 +++ b/test/test_suite/statements/while_statement_placement.c3 @@ -1,4 +1,4 @@ -func void test1() +fn void test1() { int a; while (1) a++; diff --git a/test/test_suite/statements/while_switch.c3t b/test/test_suite/statements/while_switch.c3t index bde41c2c3..72ce1e662 100644 --- a/test/test_suite/statements/while_switch.c3t +++ b/test/test_suite/statements/while_switch.c3t @@ -1,10 +1,10 @@ module test; -extern func int printf(char*, ...); -extern func int foo(); +extern fn int printf(char*, ...); +extern fn int foo(); -func int main() +fn int main() { while (foo()) { diff --git a/test/test_suite/strings/literal_to_subarray.c3t b/test/test_suite/strings/literal_to_subarray.c3t index 6a8a46378..00a40d72b 100644 --- a/test/test_suite/strings/literal_to_subarray.c3t +++ b/test/test_suite/strings/literal_to_subarray.c3t @@ -1,8 +1,8 @@ // #target: x64-darwin -char[] y = "hello"; +global char[] y = "hello"; -func void test() +fn void test() { char[] x = "world"; } diff --git a/test/test_suite/strings/string_escape.c3t b/test/test_suite/strings/string_escape.c3t index b1323f2de..bc31121da 100644 --- a/test/test_suite/strings/string_escape.c3t +++ b/test/test_suite/strings/string_escape.c3t @@ -1,4 +1,4 @@ -func void main() +fn void main() { char *s = "Hello\0 world!" " now"; } diff --git a/test/test_suite/struct/func_return_struct.c3 b/test/test_suite/struct/func_return_struct.c3 index c9c3d5ca7..66ae003b3 100644 --- a/test/test_suite/struct/func_return_struct.c3 +++ b/test/test_suite/struct/func_return_struct.c3 @@ -4,9 +4,9 @@ struct Test short s1, s2; } -extern func Test func_returning_struct(); +extern fn Test func_returning_struct(); -func void loop() +fn void loop() { func_returning_struct(); } diff --git a/test/test_suite/struct/member_access.c3 b/test/test_suite/struct/member_access.c3 index a9ef250da..c434fef35 100644 --- a/test/test_suite/struct/member_access.c3 +++ b/test/test_suite/struct/member_access.c3 @@ -34,7 +34,7 @@ struct Point } -func void tester() +fn void tester() { Multi m; m.a = 1; @@ -68,7 +68,7 @@ struct Aa1 } } -func void test_conversion_struct() +fn void test_conversion_struct() { Aa1 a1; int aa = a1.bb; // #error: 'bb' into 'int' @@ -79,7 +79,7 @@ struct Struct int a; } -func void myfunc() +fn void myfunc() { Struct s; s.b = 10; // #error: There is no field or method 'Struct.b' diff --git a/test/test_suite/struct/member_expr.c3 b/test/test_suite/struct/member_expr.c3 index be7e70094..77782deda 100644 --- a/test/test_suite/struct/member_expr.c3 +++ b/test/test_suite/struct/member_expr.c3 @@ -1,7 +1,7 @@ -define Func = func int(int); +define Func = fn int(int); -define Func2 = func int(Foo*, int); +define Func2 = fn int(Foo*, int); struct Foo { @@ -9,23 +9,23 @@ struct Foo Func callback; } -func int Foo.func2(Foo* f, int i) +fn int Foo.func2(Foo* f, int i) { return f.a + i; } -func void test_unknown_member() +fn void test_unknown_member() { int a = Foo.b; // #error: No method or inner struct/union 'Foo.b' found. } -func void test_nonstatic_stuct_func1() +fn void test_nonstatic_stuct_func1() { Func2 a = &Foo.func2; } -func void test_nonstatic_stuct_func2() +fn void test_nonstatic_stuct_func2() { int b = Foo.func2(null, 2); } diff --git a/test/test_suite/struct/simple_struct.c3t b/test/test_suite/struct/simple_struct.c3t index fb5f5308a..105ece5f5 100644 --- a/test/test_suite/struct/simple_struct.c3t +++ b/test/test_suite/struct/simple_struct.c3t @@ -1,6 +1,6 @@ module test; -private Foo a; +private global Foo a; struct Foo { diff --git a/test/test_suite/struct/struct_as_value.c3t b/test/test_suite/struct/struct_as_value.c3t index e7649f315..de6f348b7 100644 --- a/test/test_suite/struct/struct_as_value.c3t +++ b/test/test_suite/struct/struct_as_value.c3t @@ -6,7 +6,7 @@ struct Event int op; } -func Event test(int x) +fn Event test(int x) { Event foo = { 1 }; Event bar = { 2 }; diff --git a/test/test_suite/struct/struct_as_value_aarch64.c3t b/test/test_suite/struct/struct_as_value_aarch64.c3t index bfa7757a6..fe026b63b 100644 --- a/test/test_suite/struct/struct_as_value_aarch64.c3t +++ b/test/test_suite/struct/struct_as_value_aarch64.c3t @@ -6,7 +6,7 @@ struct Event int op; } -func Event test(int x) +fn Event test(int x) { Event foo = { 1 }; Event bar = { 2 }; diff --git a/test/test_suite/struct/struct_codegen.c3t b/test/test_suite/struct/struct_codegen.c3t index 33c39ac39..67ec9eb3c 100644 --- a/test/test_suite/struct/struct_codegen.c3t +++ b/test/test_suite/struct/struct_codegen.c3t @@ -7,7 +7,7 @@ struct Point int y; } -func void test1() +fn void test1() { Point p = { 5, 6 }; } diff --git a/test/test_suite/struct/struct_codegen_empty.c3t b/test/test_suite/struct/struct_codegen_empty.c3t index cc2a738c5..d9f7cbaa3 100644 --- a/test/test_suite/struct/struct_codegen_empty.c3t +++ b/test/test_suite/struct/struct_codegen_empty.c3t @@ -11,7 +11,7 @@ struct StructB } } -func void test() +fn void test() { StructA a = {}; StructA a2; diff --git a/test/test_suite/struct/struct_const_construct_simple.c3t b/test/test_suite/struct/struct_const_construct_simple.c3t index 57041cfb2..af40acd7b 100644 --- a/test/test_suite/struct/struct_const_construct_simple.c3t +++ b/test/test_suite/struct/struct_const_construct_simple.c3t @@ -6,16 +6,16 @@ struct Foo long bar; } -private usize x = $sizeof(Foo); +private global usize x = $sizeof(Foo); -private Foo foo1 = { 1, 2 }; -private Foo foo2 = { .foo = 2 }; -private Foo foo3 = { .bar = 3 }; -private Foo foo4 = { .bar = 4, .foo = 4, .bar = 1 }; -private Foo foo5 = {}; -private Foo foo6; +private global Foo foo1 = { 1, 2 }; +private global Foo foo2 = { .foo = 2 }; +private global Foo foo3 = { .bar = 3 }; +private global Foo foo4 = { .bar = 4, .foo = 4, .bar = 1 }; +private global Foo foo5 = {}; +private global Foo foo6; private const Foo FOO7 = { 1, 2 }; -private Foo foo8 = FOO7; +private global Foo foo8 = FOO7; // #expect: structo.ll diff --git a/test/test_suite/struct/struct_pack_and_align.c3t b/test/test_suite/struct/struct_pack_and_align.c3t index 346e1ecf8..d0fcb7fce 100644 --- a/test/test_suite/struct/struct_pack_and_align.c3t +++ b/test/test_suite/struct/struct_pack_and_align.c3t @@ -8,7 +8,7 @@ struct Foo1 @packed @align(4) } $assert($sizeof(Foo1) == 12); -Foo1 foo1 = { 1, 2 }; +global Foo1 foo1 = { 1, 2 }; // <{ i8, i64, [3 x i8] }> struct Foo2 @packed @align(4) @@ -18,7 +18,7 @@ struct Foo2 @packed @align(4) } $assert($sizeof(Foo2) == 12); -Foo2 foo2 = { 1, 2 }; +global Foo2 foo2 = { 1, 2 }; // <{ i8, i64, [7 x i8] }> struct Foo3 @packed @align(8) @@ -27,7 +27,7 @@ struct Foo3 @packed @align(8) long bar; } -Foo3 foo3 = { 1, 2 }; +global Foo3 foo3 = { 1, 2 }; $assert($sizeof(Foo3) == 16); // <{ i8, i64 }> @@ -38,7 +38,7 @@ struct Foo4 @packed } $assert($sizeof(Foo4) == 9); -Foo4 foo4 = { 1, 2 }; +global Foo4 foo4 = { 1, 2 }; // { i32, [12 x i8], i8, [15 x i8] } struct Foo5 @@ -48,9 +48,9 @@ struct Foo5 } $assert($sizeof(Foo5) == 32); -Foo5 foo5 = { 1, 2 }; +global Foo5 foo5 = { 1, 2 }; -func int test5(ichar x) +fn int test5(ichar x) { Foo5 y = { .foo = x }; return y.foo + y.bar; @@ -65,7 +65,7 @@ struct Foo6 @packed } $assert($sizeof(Foo6) == 8); -Foo6 foo6 = { 1, 2, 3 }; +global Foo6 foo6 = { 1, 2, 3 }; // #expect: struct2.ll diff --git a/test/test_suite/struct/struct_params.c3 b/test/test_suite/struct/struct_params.c3 index 6eb30e873..8a4bd2f69 100644 --- a/test/test_suite/struct/struct_params.c3 +++ b/test/test_suite/struct/struct_params.c3 @@ -10,15 +10,15 @@ struct Foo int q2; } -extern func int test(Foo, float); -extern func int testE(char,short,char,int,int,float); +extern fn int test(Foo, float); +extern fn int testE(char,short,char,int,int,float); -func void test3(Foo *x) +fn void test3(Foo *x) { x.q = 1; } -func void test2(Foo y) +fn void test2(Foo y) { testE(y.p, y.q, y.r, y.x, y.y, 0.1); test(y, 0.1); diff --git a/test/test_suite/subarrays/slice_comparison.c3t b/test/test_suite/subarrays/slice_comparison.c3t index 74390947a..d8cf849df 100644 --- a/test/test_suite/subarrays/slice_comparison.c3t +++ b/test/test_suite/subarrays/slice_comparison.c3t @@ -2,9 +2,9 @@ module mymodule; -extern func void printf(char *, ...); +extern fn void printf(char *, ...); -func void main() +fn void main() { char[] y = "hodo"; diff --git a/test/test_suite/subarrays/slice_negative_len.c3 b/test/test_suite/subarrays/slice_negative_len.c3 index 23455c12a..3ce848262 100644 --- a/test/test_suite/subarrays/slice_negative_len.c3 +++ b/test/test_suite/subarrays/slice_negative_len.c3 @@ -1,11 +1,11 @@ -func void test() +fn void test() { int[3] x = { 1, 2, 3}; int[] z = x[2..2]; z = x[2..1]; // #error: Start index greater than end index. } -func void test2() +fn void test2() { int[3] x = { 1, 2, 3}; int[] z = x[^2..^2]; @@ -13,50 +13,50 @@ func void test2() z = x[^1..^2]; // #error: Start index greater than end index. } -func void test3() +fn void test3() { int[3] x = { 1, 2, 3 }; int[] z = x[..4]; // #error: Array end index out of bounds, was 4, exceeding array length 3. } -func void test4() +fn void test4() { int[3] x = { 1, 2, 3 }; int[] z = x[..^1]; z = x[..^-1]; // #error: Negative numbers are not allowed when indexing from the end. } -func void test5() +fn void test5() { int[3] x = { 1, 2, 3 }; int[] z = x[..^4]; // #error: Array index out of bounds, using a negative array index is only allowed with pointers. } -func void test6() +fn void test6() { int[3] x = { 1, 2, 3 }; int[] z = x[3..]; // #error: Array index out of bounds, was 3, exceeding max array index 2. } -func void test7() +fn void test7() { int[3] x = { 1, 2, 3 }; int[] z = x[-1..]; // #error: Array index out of bounds, using a negative array index is only allowed with pointers. } -func void test8() +fn void test8() { int[3] x = { 1, 2, 3 }; int[] z = x[^4..]; // #error: Array index out of bounds, using a negative array index is only allowed with pointers. } -func void test9() +fn void test9() { int[3] x = { 1, 2, 3 }; int[] z = x[^0..]; // #error: Array index out of bounds, was 3, exceeding max array index 2. } -func void test10() +fn void test10() { int* x = null; x[-10..-3]; @@ -65,7 +65,7 @@ func void test10() int[] y = x[..^2]; // #error: Indexing from the end is not allowed for pointers. } -func void test11() +fn void test11() { int[3] x = { 1, 2, 3 }; int[] z = x[..^0]; // #error: Array end index out of bounds, was 3, exceeding array length 3 diff --git a/test/test_suite/subarrays/slice_offset.c3t b/test/test_suite/subarrays/slice_offset.c3t index 21c45f302..8b4aeff47 100644 --- a/test/test_suite/subarrays/slice_offset.c3t +++ b/test/test_suite/subarrays/slice_offset.c3t @@ -1,4 +1,4 @@ -func void test() +fn void test() { int[3] x = { 1, 2, 3 }; int[] y = x[1..2]; diff --git a/test/test_suite/subarrays/slice_offset_neg_end.c3t b/test/test_suite/subarrays/slice_offset_neg_end.c3t index fe1fc7a2e..5e33af0f3 100644 --- a/test/test_suite/subarrays/slice_offset_neg_end.c3t +++ b/test/test_suite/subarrays/slice_offset_neg_end.c3t @@ -1,5 +1,5 @@ -func void test() +fn void test() { int[3] x = { 1, 2, 3 }; int[] y = x[1..^1]; diff --git a/test/test_suite/subarrays/slice_offset_neg_start.c3t b/test/test_suite/subarrays/slice_offset_neg_start.c3t index 10e60898f..13a406179 100644 --- a/test/test_suite/subarrays/slice_offset_neg_start.c3t +++ b/test/test_suite/subarrays/slice_offset_neg_start.c3t @@ -1,4 +1,4 @@ -func void test() +fn void test() { int[3] x = { 1, 2, 3 }; int[] y = x[^2..1]; diff --git a/test/test_suite/subarrays/slice_start.c3t b/test/test_suite/subarrays/slice_start.c3t index 23e35724e..6f94e5d7c 100644 --- a/test/test_suite/subarrays/slice_start.c3t +++ b/test/test_suite/subarrays/slice_start.c3t @@ -1,4 +1,4 @@ -func void test() +fn void test() { int[3] x = { 1, 2, 3 }; int[] y = x[..]; diff --git a/test/test_suite/subarrays/slice_syntax.c3 b/test/test_suite/subarrays/slice_syntax.c3 index 44f324fc6..e4f3f641c 100644 --- a/test/test_suite/subarrays/slice_syntax.c3 +++ b/test/test_suite/subarrays/slice_syntax.c3 @@ -1,4 +1,4 @@ -func void test() +fn void test() { int[6] feok2 = { 1, 8, 100, 293, 23982, 34}; int[] feok = &feok2; diff --git a/test/test_suite/subarrays/sub_array_init.c3 b/test/test_suite/subarrays/sub_array_init.c3 index 35e012b31..4becdc105 100644 --- a/test/test_suite/subarrays/sub_array_init.c3 +++ b/test/test_suite/subarrays/sub_array_init.c3 @@ -1,4 +1,4 @@ -func void test2() +fn void test2() { int[2] a = { 1, 2 }; diff --git a/test/test_suite/symbols/various.c3 b/test/test_suite/symbols/various.c3 index b49e7614f..81b42ee3d 100644 --- a/test/test_suite/symbols/various.c3 +++ b/test/test_suite/symbols/various.c3 @@ -1,34 +1,34 @@ module test; -func void test1() +fn void test1() { char a = 1; int b = 2; char c = b > a ? 1 : 0; } -func void test2() +fn void test2() { char a = 1; char b = 2; char c = a + b; } -func void test3() +fn void test3() { ichar a = 1; int b = 2; ichar c = a + b; // #error: 'int' to 'ichar' } -func void test4() +fn void test4() { char a = 1; char b = 2; int c = a + b; } -func void test5() +fn void test5() { char a = 1; int b = 2; @@ -36,14 +36,14 @@ func void test5() } -func void test6() +fn void test6() { char a = 1; char b = 2; char c = (b > a) ? 1 : 0 + a + b; } -func void test7() +fn void test7() { int[100] array = { }; int v = array[1]; @@ -51,21 +51,21 @@ func void test7() define Number = int; -func void test8() +fn void test8() { Number a = 10; ichar c = a; // #error: 'Number' (int) to 'ichar' } -func void test9() +fn void test9() { const char A = 1; char b = A; A = b; // #error: This expression is not assignable, did you make } -func void test10() +fn void test10() { const char B = 1; char* c = &B; @@ -79,31 +79,31 @@ enum Enum : int B, } -func void test11() +fn void test11() { int a = Enum.A; ichar b = Enum.B; // #error: 'Enum' to 'ichar' } -func void test12() +fn void test12() { float f = 3.14; ichar a = f; // #error: 'float' to 'ichar' } -func void test13() +fn void test13() { int a = 1; ichar b = a; // #error: 'int' to 'ichar' } -func void test14() +fn void test14() { char a = 1; ichar b = a; } -func void test15() +fn void test15() { float f = 3.14; ichar c = 1; @@ -111,7 +111,7 @@ func void test15() ichar* b = &c; } -func void test16() +fn void test16() { float f = 3.14; int i = 1; @@ -123,18 +123,18 @@ func void test16() int a = f ? 1 : 0; } -func void test17() +fn void test17() { int a = "test"; // #error: 'string literal' into 'int' } -func void test18() +fn void test18() { char b = 1; int a = b; } -func void test19() +fn void test19() { uint a = 1; int b = a; @@ -147,15 +147,15 @@ func void test1() { i8 a = test.Num; // @error{constant value 200 out-of-bounds for type 'i8', range [-128, 127]} }*/ -func void test21() +fn void test21() { int a = 1; uint b = a; } -func void foo() {} +fn void foo() {} -func void test22() +fn void test22() { ichar a = foo(); // #error: 'void' into 'ichar' short b = foo(); // #error: 'void' into 'short' @@ -171,7 +171,7 @@ func void test22() int num = 10; -func void test23() +fn void test23() { int a = num; int b = test::num; @@ -180,17 +180,17 @@ func void test23() int[2][3] b123; -func void test24() +fn void test24() { int a = b123; // #error: 'int[2][3]' into 'int' } -func void test25() +fn void test25() { const A = void; // #error: Constants cannot be undefined. } -func void test26() +fn void test26() { const int A = void; // #error: Constants cannot be undefined. } diff --git a/test/test_suite/types/enum_errors.c3 b/test/test_suite/types/enum_errors.c3 index 7936d78d8..c701a3816 100644 --- a/test/test_suite/types/enum_errors.c3 +++ b/test/test_suite/types/enum_errors.c3 @@ -4,7 +4,7 @@ enum EnumTestErrorType3 : int A = FOO // #error: 'FOO' could not be found, did you spell it } -func int foo() +fn int foo() { return 10; } diff --git a/test/test_suite/types/enum_inference.c3 b/test/test_suite/types/enum_inference.c3 index 37141955e..80b6e20ef 100644 --- a/test/test_suite/types/enum_inference.c3 +++ b/test/test_suite/types/enum_inference.c3 @@ -16,7 +16,7 @@ enum Inf2 : char define BooInf = Inf; -func void enumInferenceTest() +fn void enumInferenceTest() { Inf x = Inf.A; x = BooInf.B; diff --git a/test/test_suite/types/enum_param.c3 b/test/test_suite/types/enum_param.c3 index c0c00e5b2..f369a64ed 100644 --- a/test/test_suite/types/enum_param.c3 +++ b/test/test_suite/types/enum_param.c3 @@ -3,10 +3,10 @@ enum Foo A, B } -func void test(Foo f) +fn void test(Foo f) {} -func void test2() +fn void test2() { test(Foo.A); } \ No newline at end of file diff --git a/test/test_suite/types/typedefs.c3 b/test/test_suite/types/typedefs.c3 index 6f3259050..354e99554 100644 --- a/test/test_suite/types/typedefs.c3 +++ b/test/test_suite/types/typedefs.c3 @@ -2,7 +2,7 @@ define Arr = int[4]; Arr a = { 3, 4, 5, 6 }; -func void test1() +fn void test1() { Arr b = { 3, 4, 5, 6 }; int c = b; // #error: 'Arr' (int[4]) into 'int' diff --git a/test/test_suite/types/various.c3 b/test/test_suite/types/various.c3 index 91d275d81..19f585b8c 100644 --- a/test/test_suite/types/various.c3 +++ b/test/test_suite/types/various.c3 @@ -1,5 +1,5 @@ func1 a = 1; // #error: declaration before the variable -func void func1() {} +fn void func1() {} uint b = -1; \ No newline at end of file diff --git a/test/test_suite/union/empty_unions.c3 b/test/test_suite/union/empty_unions.c3 index 9ac3af435..a22d5734d 100644 --- a/test/test_suite/union/empty_unions.c3 +++ b/test/test_suite/union/empty_unions.c3 @@ -20,7 +20,7 @@ union Xe } } -func Xe foo(Xe a) +fn Xe foo(Xe a) { a.c = 123; a.a = 39249; diff --git a/test/test_suite/union/union_codegen_const.c3t b/test/test_suite/union/union_codegen_const.c3t index a6c31cd2a..fe8ea6235 100644 --- a/test/test_suite/union/union_codegen_const.c3t +++ b/test/test_suite/union/union_codegen_const.c3t @@ -6,10 +6,10 @@ union Foo double b; } -private Foo f = { .a = 23 }; -private Foo g = { .b = 2.3 }; -private Foo h = { .a = 23, .b = 2.3 }; -Foo i = { .b = 2.3, .a = 23 }; +private global Foo f = { .a = 23 }; +private global Foo g = { .b = 2.3 }; +private global Foo h = { .a = 23, .b = 2.3 }; +global Foo i = { .b = 2.3, .a = 23 }; // #expect: test.ll diff --git a/test/test_suite/union/union_codegen_empty.c3t b/test/test_suite/union/union_codegen_empty.c3t index 75cac11ff..f52d5aa4e 100644 --- a/test/test_suite/union/union_codegen_empty.c3t +++ b/test/test_suite/union/union_codegen_empty.c3t @@ -13,7 +13,7 @@ union UnionB double d; } -func void test() +fn void test() { UnionA a = {}; UnionA a2; diff --git a/test/test_suite/union/union_codegen_overwrite_call.c3t b/test/test_suite/union/union_codegen_overwrite_call.c3t index 5e82f38c7..01521672c 100644 --- a/test/test_suite/union/union_codegen_overwrite_call.c3t +++ b/test/test_suite/union/union_codegen_overwrite_call.c3t @@ -10,9 +10,9 @@ union UnionB double d; } -extern func int bar(); +extern fn int bar(); -func void test() +fn void test() { UnionB b = { .c = bar(), .b = {} }; } diff --git a/test/test_suite/union/union_in_struct.c3t b/test/test_suite/union/union_in_struct.c3t index 2b8cbca66..a57306d86 100644 --- a/test/test_suite/union/union_in_struct.c3t +++ b/test/test_suite/union/union_in_struct.c3t @@ -11,8 +11,8 @@ struct Foo int z; } -Foo foo1 = { .a = 3, .z = 4 }; -Foo foo2 = { .b = 3, .z = 4 }; +global Foo foo1 = { .a = 3, .z = 4 }; +global Foo foo2 = { .b = 3, .z = 4 }; struct Blend_Map_Entry { @@ -22,12 +22,12 @@ struct Blend_Map_Entry } } -Blend_Map_Entry a = { .vals = { .colour = { 1, 2, 3, 4, 5 } } }; -Blend_Map_Entry b = { .vals = { .point_Slope = { 6, 7 } } }; -Blend_Map_Entry c = { .vals.colour[2] = 1 }; -Blend_Map_Entry d = { .vals.colour = { 1, 2, 3, 4, 5 } }; +global Blend_Map_Entry a = { .vals = { .colour = { 1, 2, 3, 4, 5 } } }; +global Blend_Map_Entry b = { .vals = { .point_Slope = { 6, 7 } } }; +global Blend_Map_Entry c = { .vals.colour[2] = 1 }; +global Blend_Map_Entry d = { .vals.colour = { 1, 2, 3, 4, 5 } }; -func void test(Blend_Map_Entry* foo) +fn void test(Blend_Map_Entry* foo) { } diff --git a/test/test_suite/union/union_member_voidcast.c3 b/test/test_suite/union/union_member_voidcast.c3 index cd2e20022..aeea25047 100644 --- a/test/test_suite/union/union_member_voidcast.c3 +++ b/test/test_suite/union/union_member_voidcast.c3 @@ -5,7 +5,7 @@ union Xu void *b; } -func Xu foo() +fn Xu foo() { Xu a; a.b = (void*)(123); diff --git a/test/test_suite/variables/consts.c3 b/test/test_suite/variables/consts.c3 index c772696e3..e3138622f 100644 --- a/test/test_suite/variables/consts.c3 +++ b/test/test_suite/variables/consts.c3 @@ -1,6 +1,6 @@ const int foo = 3; // #error: must be all upper case -func void foo(int i) +fn void foo(int i) { const int x = i; // #error: must be all upper case const int Y = i; diff --git a/test/test_suite/vector/vector_bit.c3t b/test/test_suite/vector/vector_bit.c3t index 3f6efa448..c1969ed1d 100644 --- a/test/test_suite/vector/vector_bit.c3t +++ b/test/test_suite/vector/vector_bit.c3t @@ -2,14 +2,14 @@ import libc; -func void testf() +fn void testf() { float[<4>] y = { 0, 2, 3, 0 }; int[<4>] w = !y; libc::printf("Notf %d %d %d %d\n", w[0], w[1], w[2], w[3]); } -func void testi() +fn void testi() { int[<4>] y = { 1, 2, 3, 4 }; int[<4>] z = { 2, 3, 13, -100 }; @@ -30,7 +30,7 @@ func void testi() libc::printf("Not %d %d %d %d\n", w[0], w[1], w[2], w[3]); } -func void main() +fn void main() { testf(); testi(); diff --git a/test/test_suite/vector/vector_incdec.c3t b/test/test_suite/vector/vector_incdec.c3t index c88b37420..c1718e7c0 100644 --- a/test/test_suite/vector/vector_incdec.c3t +++ b/test/test_suite/vector/vector_incdec.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin import libc; -func void testf() +fn void testf() { float[<4>] y = { 1, 2, 3, 4 }; float[<4>] z = { 2, 2, 2, -100 }; @@ -15,7 +15,7 @@ func void testf() libc::printf("Dec %f %f %f %f\n", y[0], y[1], y[2], y[3]); } -func void testi() +fn void testi() { int[<4>] y = { 1, 2, 3, 4 }; int[<4>] z = { 2, 2, 2, -100 }; @@ -30,7 +30,7 @@ func void testi() libc::printf("Original %d %d %d %d\n", w[0], w[1], w[2], w[3]); } -func void main() +fn void main() { testf(); testi(); diff --git a/test/test_suite/vector/vector_init.c3t b/test/test_suite/vector/vector_init.c3t index 33a2c0675..c3dce2902 100644 --- a/test/test_suite/vector/vector_init.c3t +++ b/test/test_suite/vector/vector_init.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin -int[<4>] baz = { 1, 4, 5, 7 }; +global int[<4>] baz = { 1, 4, 5, 7 }; -func void main() +fn void main() { int[<4>] foo = { 1, 2, 3, 4 }; int z = foo[0]; diff --git a/test/test_suite/vector/vector_ops.c3t b/test/test_suite/vector/vector_ops.c3t index f0df89951..62e23f6a0 100644 --- a/test/test_suite/vector/vector_ops.c3t +++ b/test/test_suite/vector/vector_ops.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin import libc; -func void testf() +fn void testf() { float[<4>] y = { 1, 2, 3, 4 }; float[<4>] z = { 2, 2, 2, -100 }; @@ -17,12 +17,12 @@ func void testf() libc::printf("%d %d %d %d\n", ww[0], ww[1], ww[2], ww[3]); } -func void testb() +fn void testb() { bool[<4>] d = { true, false, true, true }; } -func void testi() +fn void testi() { int[<4>] y = { 1, 2, 3, 4 }; int[<4>] z = { 2, 2, 2, -100 }; @@ -45,7 +45,7 @@ func void testi() libc::printf("%d %d %d %d\n", w[0], w[1], w[2], w[3]); } -func void main() +fn void main() { testf(); testi(); diff --git a/test/test_suite/visibility/ambiguous_var.c3t b/test/test_suite/visibility/ambiguous_var.c3t index 044ed379f..dfad51ace 100644 --- a/test/test_suite/visibility/ambiguous_var.c3t +++ b/test/test_suite/visibility/ambiguous_var.c3t @@ -17,7 +17,7 @@ import bar; int a; -private func void test2() +private fn void test2() { int c = a; // This is fine. c = foo::b; diff --git a/test/test_suite/visibility/no_shared_imports.c3t b/test/test_suite/visibility/no_shared_imports.c3t index 719d90d63..213cb3e2a 100644 --- a/test/test_suite/visibility/no_shared_imports.c3t +++ b/test/test_suite/visibility/no_shared_imports.c3t @@ -1,7 +1,7 @@ // #file: file1.c3 module baz; -func void runBar() +fn void runBar() { visible(); bar::barFunc(); // #error: Unknown module 'bar' @@ -11,7 +11,7 @@ func void runBar() module baz; import bar; -private func void visible() +private fn void visible() { bar::barFunc(); } @@ -19,5 +19,5 @@ private func void visible() // #file: file3.c3 module bar; -func void barFunc() +fn void barFunc() {} \ No newline at end of file diff --git a/test/test_suite/visibility/not_visible.c3t b/test/test_suite/visibility/not_visible.c3t index e844f6398..c6de53295 100644 --- a/test/test_suite/visibility/not_visible.c3t +++ b/test/test_suite/visibility/not_visible.c3t @@ -2,7 +2,7 @@ module baz; import bar; -func void runBar() +fn void runBar() { bar::notVisible(); // #error: 'notVisible' is not visible from this module. } @@ -10,7 +10,7 @@ func void runBar() // #file: file2.c3 module bar; -private func void notVisible() +private fn void notVisible() { } \ No newline at end of file diff --git a/test/test_suite/visibility/private_import.c3 b/test/test_suite/visibility/private_import.c3 index 1520b5694..31d895657 100644 --- a/test/test_suite/visibility/private_import.c3 +++ b/test/test_suite/visibility/private_import.c3 @@ -1,13 +1,13 @@ module foo; -private func void hidden() +private fn void hidden() { } module bar; import foo; -func void test() +fn void test() { foo::hidden(); // #error: The function 'hidden' is not visible from this module. } @@ -15,7 +15,7 @@ func void test() module baz; import private foo; -func void test() +fn void test() { foo::hidden(); } \ No newline at end of file diff --git a/test/test_suite/visibility/private_module.c3 b/test/test_suite/visibility/private_module.c3 index 631dafdf9..5faba9b0b 100644 --- a/test/test_suite/visibility/private_module.c3 +++ b/test/test_suite/visibility/private_module.c3 @@ -1,6 +1,6 @@ module private foo; -func void hidden() +fn void hidden() { } @@ -11,7 +11,7 @@ import foo; // #error: Importing a private module is not allowed (unless 'import module baz; import private foo; -func void test() +fn void test() { foo::hidden(); } \ No newline at end of file diff --git a/test/test_suite/visibility/shared_module.c3t b/test/test_suite/visibility/shared_module.c3t index 2fea64551..3895bec2a 100644 --- a/test/test_suite/visibility/shared_module.c3t +++ b/test/test_suite/visibility/shared_module.c3t @@ -1,7 +1,7 @@ // #file: file1.c3 module baz; -func void runBar() +fn void runBar() { visible(); } @@ -9,7 +9,7 @@ func void runBar() // #file: file2.c3 module baz; -private func void visible() +private fn void visible() { } \ No newline at end of file diff --git a/test/test_suite/visibility/simple_visibility.c3t b/test/test_suite/visibility/simple_visibility.c3t index 5f540c62e..a88afec45 100644 --- a/test/test_suite/visibility/simple_visibility.c3t +++ b/test/test_suite/visibility/simple_visibility.c3t @@ -2,7 +2,7 @@ module baz; import bar; -func void runBar() +fn void runBar() { bar::visible(); } @@ -10,7 +10,7 @@ func void runBar() // #file: file2.c3 module bar; -func void visible() +fn void visible() { }