├── .ci-dockerfiles ├── arm64-unknown-linux-alpine3.21-builder │ ├── Dockerfile │ └── build-and-push.bash ├── arm64-unknown-linux-ubuntu24.04-builder │ ├── Dockerfile │ └── build-and-push.bash ├── cross-arm │ ├── Dockerfile │ └── build-and-push.bash ├── cross-armhf │ ├── Dockerfile │ └── build-and-push.bash ├── cross-riscv64 │ ├── Dockerfile │ └── build-and-push.bash ├── stdlib-builder │ ├── Dockerfile │ └── build-and-push.bash ├── x86-64-unknown-linux-alpine3.20-builder │ ├── Dockerfile │ └── build-and-push.bash ├── x86-64-unknown-linux-alpine3.21-builder │ ├── Dockerfile │ └── build-and-push.bash ├── x86-64-unknown-linux-arch-builder │ ├── Dockerfile │ └── build-and-push.bash ├── x86-64-unknown-linux-fedora41-builder │ ├── Dockerfile │ └── build-and-push.bash ├── x86-64-unknown-linux-musl-builder │ ├── Dockerfile │ └── build-and-push.bash ├── x86-64-unknown-linux-ubuntu22.04-builder │ ├── Dockerfile │ └── build-and-push.bash └── x86-64-unknown-linux-ubuntu24.04-builder │ ├── Dockerfile │ └── build-and-push.bash ├── .ci-scripts ├── arm64-nightly.bash ├── arm64-release.bash ├── build-stdlib-documentation.bash ├── macOS-configure-networking.bash ├── x86-64-nightly.bash └── x86-64-release.bash ├── .dockerfiles ├── latest │ ├── arm64-unknown-linux-musl │ │ ├── Dockerfile │ │ └── build-and-push.bash │ ├── x86-64-pc-windows-msvc │ │ ├── Dockerfile │ │ ├── build-and-push.ps1 │ │ └── git.ini │ ├── x86-64-unknown-linux-gnu │ │ ├── Dockerfile │ │ └── build-and-push.bash │ └── x86-64-unknown-linux-musl │ │ ├── Dockerfile │ │ └── build-and-push.bash └── release │ ├── x86-64-pc-windows-msvc │ ├── Dockerfile │ ├── build-and-push.ps1 │ └── git.ini │ ├── x86-64-unknown-linux-gnu │ ├── Dockerfile │ └── build-and-push.bash │ └── x86-64-unknown-linux-musl │ ├── Dockerfile │ └── build-and-push.bash ├── .github ├── FUNDING.yml ├── actionlint.yaml ├── linters │ ├── .markdown-lint.yml │ └── .yaml-lint.yml └── workflows │ ├── add-discuss-during-sync.yml │ ├── announce-a-release.yml │ ├── arm-builder-test.yml │ ├── changelog-bot.yml │ ├── cloudsmith-package-sychronised.yml │ ├── generate-documentation.yml │ ├── lint-action-workflows.yml │ ├── nightlies.yml │ ├── pr.yml │ ├── prepare-for-a-release.yml │ ├── rebuild-stdlib-builder.yml │ ├── release-notes-reminder.yml │ ├── release-notes.yml │ ├── release.yml │ ├── remove-discuss-during-sync.yml │ ├── stress-test-tcp-open-close-linux.yml │ ├── stress-test-tcp-open-close-macos.yml │ ├── stress-test-tcp-open-close-windows.yml │ ├── stress-test-ubench-linux.yml │ ├── stress-test-ubench-macos.yml │ ├── stress-test-ubench-windows.yml │ ├── test-with-latest-tools.yml │ └── update-lib-cache.yml ├── .gitmodules ├── .markdownlintignore ├── .release-notes ├── 0.37.0.md ├── 0.38.0.md ├── 0.38.1.md ├── 0.38.2.md ├── 0.38.3.md ├── 0.39.0.md ├── 0.39.1.md ├── 0.40.0.md ├── 0.41.0.md ├── 0.41.1.md ├── 0.41.2.md ├── 0.42.0.md ├── 0.43.0.md ├── 0.43.1.md ├── 0.43.2.md ├── 0.44.0.md ├── 0.45.0.md ├── 0.45.1.md ├── 0.45.2.md ├── 0.46.0.md ├── 0.47.0.md ├── 0.48.0.md ├── 0.49.0.md ├── 0.49.1.md ├── 0.50.0.md ├── 0.51.0.md ├── 0.51.1.md ├── 0.51.2.md ├── 0.51.3.md ├── 0.51.4.md ├── 0.52.0.md ├── 0.52.1.md ├── 0.52.2.md ├── 0.52.3.md ├── 0.52.4.md ├── 0.52.5.md ├── 0.53.0.md ├── 0.54.0.md ├── 0.54.1.md ├── 0.55.0.md ├── 0.55.1.md ├── 0.56.0.md ├── 0.56.1.md ├── 0.56.2.md ├── 0.57.0.md ├── 0.57.1.md ├── 0.58.0.md ├── 0.58.1.md ├── 0.58.10.md ├── 0.58.11.md ├── 0.58.12.md ├── 0.58.13.md ├── 0.58.2.md ├── 0.58.3.md ├── 0.58.4.md ├── 0.58.5.md ├── 0.58.6.md ├── 0.58.7.md ├── 0.58.8.md ├── 0.58.9.md ├── 0.59.0.md └── next-release.md ├── BUILD.md ├── CHANGELOG.md ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── EDITORS.md ├── INSTALL.md ├── INSTALL_DOCKER.md ├── LICENSE ├── Makefile ├── README.md ├── RELEASE_PROCESS.md ├── STYLE_GUIDE.md ├── SUPPORT.md ├── SYSTEMATIC_TESTING.md ├── VERSION ├── benchmark ├── README.md ├── libponyc │ ├── CMakeLists.txt │ ├── README.md │ ├── common │ │ └── common.cc │ └── gbenchmark_main.cc └── libponyrt │ ├── CMakeLists.txt │ ├── README.md │ ├── common │ └── common.cc │ ├── ds │ └── hash.cc │ ├── gbenchmark_main.cc │ └── mem │ ├── heap.cc │ └── pool.cc ├── examples ├── circle │ ├── README.md │ └── main.pony ├── commandline │ ├── README.md │ └── main.pony ├── constrained_type │ ├── README.md │ └── main.pony ├── counter │ ├── README.md │ └── main.pony ├── dtrace │ ├── README.md │ ├── gc.d │ ├── mbox-size-all-actor-messages.d │ ├── mbox-size-all-thread-messages.d │ ├── mbox-size.d │ ├── message-types.d │ ├── nanosleep.d │ ├── scheduling.d │ └── telemetry.d ├── echo │ ├── README.md │ └── echo.pony ├── fan-in │ ├── README.md │ └── main.pony ├── ffi-callbacks │ ├── README.md │ ├── callbacks.c │ └── callbacks.pony ├── ffi-struct │ ├── README.md │ ├── struct.c │ └── struct.pony ├── files │ ├── README.md │ └── files.pony ├── gups_basic │ ├── README.md │ └── main.pony ├── gups_opt │ ├── README.md │ └── main.pony ├── helloworld │ ├── README.md │ └── main.pony ├── ifdef │ ├── README.md │ └── ifdef.pony ├── lambda │ ├── README.md │ └── lambda.pony ├── mailbox │ ├── README.md │ └── main.pony ├── mandelbrot │ ├── README.md │ └── mandelbrot.pony ├── message-ubench │ ├── README.md │ └── main.pony ├── mixed │ ├── README.md │ └── main.pony ├── n-body │ ├── README.md │ └── n-body.pony ├── net │ ├── README.md │ ├── client.pony │ ├── listener.pony │ ├── net.pony │ ├── ping.pony │ ├── pong.pony │ └── server.pony ├── overload │ ├── README.md │ └── main.pony ├── pony_bench │ ├── README.md │ └── main.pony ├── pony_check │ ├── README.md │ ├── async_tcp_property.pony │ ├── collection_generators.pony │ ├── custom_class.pony │ ├── list_reverse.pony │ └── main.pony ├── printargs │ ├── README.md │ └── printargs.pony ├── producer-consumer │ ├── README.md │ ├── buffer.pony │ ├── consumer.pony │ ├── main.pony │ ├── producer.pony │ └── product.pony ├── readline │ ├── README.md │ └── main.pony ├── ring │ ├── README.md │ └── main.pony ├── runtime_info │ ├── README.md │ └── main.pony ├── spreader │ ├── README.md │ └── main.pony ├── systemtap │ ├── README.md │ ├── gc.stp │ ├── scheduling.stp │ └── telemetry.stp ├── timers │ ├── README.md │ └── timers.pony ├── under_pressure │ ├── README.md │ └── main.pony └── yield │ ├── README.md │ └── main.pony ├── lib ├── CMakeLists.txt ├── blake2 │ ├── blake2-impl.h │ ├── blake2.h │ └── blake2b-ref.c └── llvm │ └── patches │ ├── .keep │ └── 2025-04-30-gcc-15.diff ├── make.ps1 ├── minimal-cases ├── issue-629 │ └── 629.pony └── issue-647 │ └── 647.pony ├── packages ├── actor_pinning │ ├── _test.pony │ ├── actor_pinning.pony │ └── auth.pony ├── assert │ └── assert.pony ├── backpressure │ ├── auth.pony │ └── backpressure.pony ├── buffered │ ├── _test.pony │ ├── benchmarks │ │ └── main.pony │ ├── buffered.pony │ ├── reader.pony │ └── writer.pony ├── builtin │ ├── _arithmetic.pony │ ├── _to_string.pony │ ├── ambient_auth.pony │ ├── any.pony │ ├── array.pony │ ├── asio_event.pony │ ├── bool.pony │ ├── builtin.pony │ ├── compare.pony │ ├── disposable_actor.pony │ ├── do_not_optimise.pony │ ├── env.pony │ ├── float.pony │ ├── iterator.pony │ ├── none.pony │ ├── nullable_pointer.pony │ ├── platform.pony │ ├── pointer.pony │ ├── read_seq.pony │ ├── real.pony │ ├── runtime_options.pony │ ├── seq.pony │ ├── signed.pony │ ├── source_loc.pony │ ├── std_stream.pony │ ├── stdin.pony │ ├── string.pony │ ├── stringable.pony │ └── unsigned.pony ├── builtin_test │ ├── _test.pony │ └── _test_valtrace.pony ├── bureaucracy │ ├── _test.pony │ ├── bureaucracy.pony │ ├── custodian.pony │ └── registrar.pony ├── capsicum │ ├── cap.pony │ ├── cap_rights.pony │ └── capsicum.pony ├── cli │ ├── _test.pony │ ├── cli.pony │ ├── command.pony │ ├── command_help.pony │ ├── command_parser.pony │ ├── command_spec.pony │ └── env_vars.pony ├── collections │ ├── _test.pony │ ├── collections.pony │ ├── flag.pony │ ├── hashable.pony │ ├── heap.pony │ ├── list.pony │ ├── list_node.pony │ ├── map.pony │ ├── persistent │ │ ├── _bits.pony │ │ ├── _map_node.pony │ │ ├── _test.pony │ │ ├── _vec_node.pony │ │ ├── benchmarks │ │ │ └── main.pony │ │ ├── list.pony │ │ ├── map.pony │ │ ├── persistent.pony │ │ ├── set.pony │ │ └── vec.pony │ ├── range.pony │ ├── reverse.pony │ ├── ring_buffer.pony │ ├── set.pony │ └── sort.pony ├── constrained_types │ ├── _test.pony │ ├── constrained.pony │ └── constrained_types.pony ├── debug │ └── debug.pony ├── encode │ └── base64 │ │ ├── _test.pony │ │ └── base64.pony ├── files │ ├── _file_des.pony │ ├── _test.pony │ ├── auth.pony │ ├── directory.pony │ ├── file.pony │ ├── file_caps.pony │ ├── file_info.pony │ ├── file_lines.pony │ ├── file_mode.pony │ ├── file_path.pony │ ├── file_stream.pony │ ├── files.pony │ └── path.pony ├── format │ ├── _format_float.pony │ ├── _format_int.pony │ ├── _test.pony │ ├── align.pony │ ├── format.pony │ ├── format_spec.pony │ └── prefix_spec.pony ├── ini │ ├── _test.pony │ ├── ini.pony │ └── ini_map.pony ├── itertools │ ├── _test.pony │ ├── iter.pony │ └── itertools.pony ├── math │ ├── _test.pony │ ├── fibonacci.pony │ ├── greatest_common_divisor.pony │ ├── is_prime.pony │ ├── least_common_multiple.pony │ └── math.pony ├── net │ ├── _test.pony │ ├── auth.pony │ ├── dns.pony │ ├── net.pony │ ├── net_address.pony │ ├── ossocket.pony │ ├── ossockopt.pony │ ├── proxy.pony │ ├── tcp_connection.pony │ ├── tcp_connection_notify.pony │ ├── tcp_listen_notify.pony │ ├── tcp_listener.pony │ ├── udp_notify.pony │ └── udp_socket.pony ├── pony_bench │ ├── _aggregator.pony │ ├── _output_manager.pony │ ├── _results.pony │ ├── _runner.pony │ ├── benchmark.pony │ └── pony_bench.pony ├── pony_check │ ├── _test.pony │ ├── ascii_range.pony │ ├── for_all.pony │ ├── generator.pony │ ├── int_properties.pony │ ├── pony_check.pony │ ├── poperator.pony │ ├── property.pony │ ├── property_helper.pony │ ├── property_runner.pony │ ├── property_unit_test.pony │ └── randomness.pony ├── pony_test │ ├── _color.pony │ ├── _group.pony │ ├── _test_record.pony │ ├── _test_runner.pony │ ├── pony_test.pony │ ├── test_helper.pony │ ├── test_list.pony │ └── unit_test.pony ├── process │ ├── _pipe.pony │ ├── _process.pony │ ├── _test.pony │ ├── auth.pony │ ├── process.pony │ ├── process_error.pony │ ├── process_monitor.pony │ └── process_notify.pony ├── promises │ ├── _test.pony │ ├── _then.pony │ ├── fulfill.pony │ ├── promise.pony │ └── promises.pony ├── random │ ├── _test.pony │ ├── benchmarks │ │ └── main.pony │ ├── dice.pony │ ├── mt.pony │ ├── random.pony │ ├── splitmix64.pony │ ├── xoroshiro.pony │ └── xorshift.pony ├── runtime_info │ ├── _actor_stats.pony │ ├── _scheduler_stats.pony │ ├── _test.pony │ ├── actor_stats.pony │ ├── auth.pony │ ├── runtime_info.pony │ ├── scheduler.pony │ └── scheduler_stats.pony ├── serialise │ ├── _test.pony │ └── serialise.pony ├── signals │ ├── _test.pony │ ├── sig.pony │ ├── signal_handler.pony │ ├── signal_notify.pony │ └── signals.pony ├── stdlib │ └── _test.pony ├── strings │ ├── _test.pony │ ├── common_prefix.pony │ └── strings.pony ├── term │ ├── ansi.pony │ ├── ansi_notify.pony │ ├── ansi_term.pony │ ├── readline.pony │ ├── readline_notify.pony │ └── term.pony └── time │ ├── _test.pony │ ├── _timing_wheel.pony │ ├── nanos.pony │ ├── posix_date.pony │ ├── time.pony │ ├── timer.pony │ ├── timer_notify.pony │ └── timers.pony ├── pony.cloc ├── pony.g ├── src ├── common │ ├── dtrace.h │ ├── dtrace_probes.d │ ├── llvm_config_begin.h │ ├── llvm_config_end.h │ ├── paths.h │ ├── platform.h │ ├── pony │ │ └── detail │ │ │ └── atomics.h │ ├── ponyassert.h │ ├── threads.h │ └── vcvars.h ├── libponyc │ ├── CMakeLists.txt │ ├── ast │ │ ├── ast.c │ │ ├── ast.h │ │ ├── astbuild.h │ │ ├── bnfprint.c │ │ ├── bnfprint.h │ │ ├── error.c │ │ ├── error.h │ │ ├── frame.c │ │ ├── frame.h │ │ ├── id.c │ │ ├── id.h │ │ ├── id_internal.h │ │ ├── lexer.c │ │ ├── lexer.h │ │ ├── lexint.c │ │ ├── lexint.h │ │ ├── parser.c │ │ ├── parser.h │ │ ├── parserapi.c │ │ ├── parserapi.h │ │ ├── printbuf.c │ │ ├── printbuf.h │ │ ├── source.c │ │ ├── source.h │ │ ├── stringtab.c │ │ ├── stringtab.h │ │ ├── symtab.c │ │ ├── symtab.h │ │ ├── token.c │ │ ├── token.h │ │ ├── treecheck.c │ │ ├── treecheck.h │ │ └── treecheckdef.h │ ├── codegen │ │ ├── codegen.c │ │ ├── codegen.h │ │ ├── genbox.c │ │ ├── genbox.h │ │ ├── gencall.c │ │ ├── gencall.h │ │ ├── gencontrol.c │ │ ├── gencontrol.h │ │ ├── gendebug.cc │ │ ├── gendebug.h │ │ ├── gendesc.c │ │ ├── gendesc.h │ │ ├── genexe.c │ │ ├── genexe.h │ │ ├── genexpr.c │ │ ├── genexpr.h │ │ ├── genfun.c │ │ ├── genfun.h │ │ ├── genheader.c │ │ ├── genheader.h │ │ ├── genident.c │ │ ├── genident.h │ │ ├── genmatch.c │ │ ├── genmatch.h │ │ ├── genname.c │ │ ├── genname.h │ │ ├── genobj.c │ │ ├── genobj.h │ │ ├── genoperator.c │ │ ├── genoperator.h │ │ ├── genopt.cc │ │ ├── genopt.h │ │ ├── genprim.c │ │ ├── genprim.h │ │ ├── genreference.c │ │ ├── genreference.h │ │ ├── genserialise.c │ │ ├── genserialise.h │ │ ├── gentrace.c │ │ ├── gentrace.h │ │ ├── gentype.c │ │ ├── gentype.h │ │ └── host.cc │ ├── expr │ │ ├── array.c │ │ ├── array.h │ │ ├── call.c │ │ ├── call.h │ │ ├── control.c │ │ ├── control.h │ │ ├── ffi.c │ │ ├── ffi.h │ │ ├── lambda.c │ │ ├── lambda.h │ │ ├── literal.c │ │ ├── literal.h │ │ ├── match.c │ │ ├── match.h │ │ ├── operator.c │ │ ├── operator.h │ │ ├── postfix.c │ │ ├── postfix.h │ │ ├── reference.c │ │ └── reference.h │ ├── logo.h │ ├── options │ │ ├── options.c │ │ └── options.h │ ├── pass │ │ ├── completeness.c │ │ ├── completeness.h │ │ ├── docgen.c │ │ ├── docgen.h │ │ ├── expr.c │ │ ├── expr.h │ │ ├── finalisers.c │ │ ├── finalisers.h │ │ ├── flatten.c │ │ ├── flatten.h │ │ ├── import.c │ │ ├── import.h │ │ ├── names.c │ │ ├── names.h │ │ ├── pass.c │ │ ├── pass.h │ │ ├── refer.c │ │ ├── refer.h │ │ ├── scope.c │ │ ├── scope.h │ │ ├── serialisers.c │ │ ├── serialisers.h │ │ ├── sugar.c │ │ ├── sugar.h │ │ ├── syntax.c │ │ ├── syntax.h │ │ ├── traits.c │ │ ├── traits.h │ │ ├── verify.c │ │ └── verify.h │ ├── pkg │ │ ├── buildflagset.c │ │ ├── buildflagset.h │ │ ├── ifdef.c │ │ ├── ifdef.h │ │ ├── package.c │ │ ├── package.h │ │ ├── platformfuns.c │ │ ├── platformfuns.h │ │ ├── program.c │ │ ├── program.h │ │ ├── use.c │ │ └── use.h │ ├── platform │ │ ├── paths.c │ │ └── vcvars.c │ ├── plugin │ │ ├── plugin.c │ │ └── plugin.h │ ├── ponyc.c │ ├── ponyc.h │ ├── ponydoc.c │ ├── reach │ │ ├── paint.c │ │ ├── paint.h │ │ ├── reach.c │ │ ├── reach.h │ │ ├── subtype.c │ │ └── subtype.h │ ├── type │ │ ├── alias.c │ │ ├── alias.h │ │ ├── assemble.c │ │ ├── assemble.h │ │ ├── cap.c │ │ ├── cap.h │ │ ├── compattype.c │ │ ├── compattype.h │ │ ├── lookup.c │ │ ├── lookup.h │ │ ├── matchtype.c │ │ ├── matchtype.h │ │ ├── reify.c │ │ ├── reify.h │ │ ├── safeto.c │ │ ├── safeto.h │ │ ├── sanitise.c │ │ ├── sanitise.h │ │ ├── subtype.c │ │ ├── subtype.h │ │ ├── typeparam.c │ │ ├── typeparam.h │ │ ├── viewpoint.c │ │ └── viewpoint.h │ └── verify │ │ ├── call.c │ │ ├── call.h │ │ ├── control.c │ │ ├── control.h │ │ ├── fun.c │ │ ├── fun.h │ │ ├── type.c │ │ └── type.h ├── libponyrt │ ├── CMakeLists.txt │ ├── actor │ │ ├── actor.c │ │ ├── actor.h │ │ ├── messageq.c │ │ └── messageq.h │ ├── asio │ │ ├── asio.c │ │ ├── asio.h │ │ ├── emscripten.c │ │ ├── epoll.c │ │ ├── event.c │ │ ├── event.h │ │ ├── iocp.c │ │ └── kqueue.c │ ├── ds │ │ ├── fun.c │ │ ├── fun.h │ │ ├── hash.c │ │ ├── hash.h │ │ ├── list.c │ │ ├── list.h │ │ ├── stack.c │ │ └── stack.h │ ├── gc │ │ ├── actormap.c │ │ ├── actormap.h │ │ ├── cycle.c │ │ ├── cycle.h │ │ ├── delta.c │ │ ├── delta.h │ │ ├── gc.c │ │ ├── gc.h │ │ ├── objectmap.c │ │ ├── objectmap.h │ │ ├── serialise.c │ │ ├── serialise.h │ │ ├── trace.c │ │ └── trace.h │ ├── lang │ │ ├── directory.c │ │ ├── errno.c │ │ ├── errno.h │ │ ├── except_try_catch.ll │ │ ├── io.c │ │ ├── lsda.c │ │ ├── lsda.h │ │ ├── paths.c │ │ ├── posix_except.c │ │ ├── process.c │ │ ├── process.h │ │ ├── socket.c │ │ ├── socket.h │ │ ├── ssl.c │ │ ├── stat.c │ │ ├── stdfd.c │ │ ├── time.c │ │ └── win_except.c │ ├── mem │ │ ├── alloc.c │ │ ├── alloc.h │ │ ├── heap.c │ │ ├── heap.h │ │ ├── heap_chunk_sorting.h │ │ ├── pagemap.c │ │ ├── pagemap.h │ │ ├── pool.c │ │ ├── pool.h │ │ └── pool_memalign.c │ ├── options │ │ ├── options.c │ │ └── options.h │ ├── platform │ │ ├── ponyassert.c │ │ └── threads.c │ ├── pony.h │ ├── sched │ │ ├── cpu.c │ │ ├── cpu.h │ │ ├── mpmcq.c │ │ ├── mpmcq.h │ │ ├── mutemap.c │ │ ├── mutemap.h │ │ ├── scheduler.c │ │ ├── scheduler.h │ │ ├── start.c │ │ ├── systematic_testing.c │ │ └── systematic_testing.h │ └── tracing │ │ ├── tracing.c │ │ └── tracing.h └── ponyc │ ├── CMakeLists.txt │ └── main.c └── test ├── full-program-runner ├── CMakeLists.txt ├── _build_process_notify.pony ├── _cli_options.pony ├── _colors.pony ├── _coordinator.pony ├── _find_executable.pony ├── _test_definitions.pony ├── _test_process_notify.pony ├── _tester.pony ├── _tester_timer_notify.pony └── main.pony ├── full-program-tests ├── CMakeLists.txt ├── actor-final │ ├── expected-exit-code.txt │ └── main.pony ├── annotation-compound-expr │ └── main.pony ├── annotation-methods │ └── main.pony ├── annotation-standard-location-good │ └── main.pony ├── annotation-types │ └── main.pony ├── array-as-iso-consumed-elements │ └── main.pony ├── array-as-iso │ └── main.pony ├── array-as-val │ └── main.pony ├── array-infer-from-apply-interface-box-element-in-tuple │ └── main.pony ├── array-infer-from-apply-interface-val-element-no-arrow-this │ └── main.pony ├── array-infer-from-apply-interface │ └── main.pony ├── array-infer-from-array-iso │ └── main.pony ├── array-infer-from-array-type │ └── main.pony ├── array-infer-from-array-uso-with-as │ └── main.pony ├── array-infer-from-array-val │ └── main.pony ├── array-infer-from-interface-with-type-param │ └── main.pony ├── array-infer-from-read-seq-and-read-element-interface │ └── main.pony ├── array-infer-from-seq │ └── main.pony ├── array-infer-from-values-call-with-iterator-antecedent │ └── main.pony ├── array-infer-from-values-of-array-interface │ └── main.pony ├── array-infer-most-specific-from-union-of-array-types │ ├── expected-exit-code.txt │ └── main.pony ├── array-no-as-iso-consumed-elements │ └── main.pony ├── array-no-as-iso │ └── main.pony ├── array-no-as-val │ └── main.pony ├── bare-function-bare-lambda-callback │ ├── expected-exit-code.txt │ └── main.pony ├── bare-function-call │ ├── expected-exit-code.txt │ └── main.pony ├── bare-function-callback-addressof │ ├── expected-exit-code.txt │ └── main.pony ├── bare-function-callback-partial-application │ ├── expected-exit-code.txt │ └── main.pony ├── bare-function-receiver-side-effect │ ├── expected-exit-code.txt │ └── main.pony ├── bare-function-typeref-call-no-constructor-call │ ├── expected-exit-code.txt │ └── main.pony ├── bare-function-use-of-void-pointers │ ├── expected-exit-code.txt │ └── main.pony ├── bare-function │ └── additional.cc ├── bare-lambda-call │ ├── expected-exit-code.txt │ └── main.pony ├── bare-lambda-use-of-void-pointers │ ├── expected-exit-code.txt │ └── main.pony ├── c-callback │ ├── additional.c │ ├── expected-exit-code.txt │ └── main.pony ├── class-final │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-no-trace │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-number-boxed-sent-through-interface │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-number-boxed │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-object-different-cap │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-object-dynamic │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-object-same-cap │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-object-static │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-struct-field │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-tuple-boxed-sent-through-interface │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-tuple-boxed │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-tuple-dynamic │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-tuple-with-number-boxed-sent-through-interface │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace-tuple │ ├── expected-exit-code.txt │ └── main.pony ├── codegen-trace │ └── additional.cc ├── ctor-autorecover-this │ └── main.pony ├── ctor-autorecover │ └── main.pony ├── custom-serialisation │ ├── additional.c │ ├── expected-exit-code.txt │ └── main.pony ├── cycle-detector │ ├── expected-exit-code.txt │ └── main.pony ├── embed-final │ ├── expected-exit-code.txt │ └── main.pony ├── ffi-call-in-initializer │ ├── additional.c │ └── main.pony ├── ffi-different-returns │ ├── additional.c │ ├── expected-exit-code.txt │ └── main.pony ├── ffi-libponyc-standalone │ └── main.pony ├── ffi-return-arg-reachable │ ├── additional.c │ ├── expected-exit-code.txt │ └── main.pony ├── identity-abstract-type-no-subtyping │ ├── expected-exit-code.txt │ └── main.pony ├── identity-boxed-numeric-is-boxed-numeric │ ├── expected-exit-code.txt │ └── main.pony ├── identity-boxed-tuple-is-boxed-tuple │ ├── expected-exit-code.txt │ └── main.pony ├── identity-digestof-boxed-numeric │ ├── expected-exit-code.txt │ └── main.pony ├── identity-digestof-boxed-tuple │ ├── expected-exit-code.txt │ └── main.pony ├── identity-digestof-numeric │ ├── expected-exit-code.txt │ └── main.pony ├── identity-digestof-object │ ├── additional.c │ ├── expected-exit-code.txt │ └── main.pony ├── identity-digestof-tuple │ ├── expected-exit-code.txt │ └── main.pony ├── identity-nested-tuple │ ├── expected-exit-code.txt │ └── main.pony ├── identity-numeric-is-boxed-numeric │ ├── expected-exit-code.txt │ └── main.pony ├── identity-numeric-is-numeric │ ├── expected-exit-code.txt │ └── main.pony ├── identity-object-is-object │ ├── expected-exit-code.txt │ └── main.pony ├── identity-tuple-cardinality │ ├── expected-exit-code.txt │ └── main.pony ├── identity-tuple-different-types │ ├── expected-exit-code.txt │ └── main.pony ├── identity-tuple-is-boxed-tuple │ ├── expected-exit-code.txt │ └── main.pony ├── identity-tuple-is-tuple │ ├── expected-exit-code.txt │ └── main.pony ├── if-block-ending-with-dont-care-assign │ ├── expected-exit-code.txt │ └── main.pony ├── if-block-ending-with-embed-assign │ ├── expected-exit-code.txt │ └── main.pony ├── iftype-else-if-true │ ├── expected-exit-code.txt │ └── main.pony ├── iftype-false │ ├── expected-exit-code.txt │ └── main.pony ├── iftype-true │ ├── expected-exit-code.txt │ └── main.pony ├── issue-4475-case-1 │ └── main.pony ├── issue-4475-case-2 │ └── main.pony ├── lambda-with-return-in-behaviour │ └── main.pony ├── lambda-with-return-in-constructor │ └── main.pony ├── large-dependent-finalisers │ ├── additional.cc │ ├── expected-exit-code.txt │ └── main.pony ├── match-exhaustive-all-cases-including-dont-care-and-tuple │ ├── expected-exit-code.txt │ └── main.pony ├── match-exhaustive-all-cases-of-union │ ├── expected-exit-code.txt │ └── main.pony ├── match-exhaustive-all-cases-primitive-values │ ├── expected-exit-code.txt │ └── main.pony ├── object-literal-with-return-in-behaviour │ └── main.pony ├── object-literal-with-return-in-constructor │ └── main.pony ├── optimisation-merge-send-message-reordering │ ├── expected-exit-code.txt │ └── main.pony ├── pinned-actor │ ├── expected-exit-code.txt │ └── main.pony ├── primitive-final │ ├── expected-exit-code.txt │ └── main.pony ├── primitive-init │ ├── expected-exit-code.txt │ └── main.pony ├── private-type-as-default-argument-in-public-function │ ├── lib │ │ └── lib.pony │ └── main.pony ├── promise-flatten-next-regression-3856 │ └── main.pony ├── regression-1118 │ └── main.pony ├── regression-1222 │ └── main.pony ├── regression-2150 │ ├── bar.pony │ ├── foo.pony │ └── main.pony ├── regression-2408 │ └── main.pony ├── regression-2976 │ ├── expected-exit-code.txt │ └── main.pony ├── regression-3447 │ └── main.pony ├── regression-3615 │ └── main.pony ├── regression-3658 │ └── main.pony ├── regression-3737 │ ├── lib │ │ └── lib.pony │ └── main.pony ├── regression-3765 │ └── main.pony ├── regression-3840 │ └── main.pony ├── regression-4059 │ └── main.pony ├── regression-4174 │ ├── expected-exit-code.txt │ └── main.pony ├── regression-4284 │ └── main.pony ├── regression-4340 │ └── main.pony ├── regression-4369 │ └── main.pony ├── regression-4412 │ ├── expected-exit-code.txt │ └── main.pony ├── regression-4479 │ └── main.pony ├── regression-4480 │ └── main.pony ├── regression-4582 │ ├── expected-exit-code.txt │ └── main.pony ├── regression-4612 │ └── main.pony ├── regression-4613 │ ├── main.pony │ ├── pkg │ │ └── trait.pony │ └── regression-4613 ├── regression-623-case-1 │ └── main.pony ├── regression-623-case-2 │ └── main.pony ├── regression-849 │ └── main.pony ├── small-dependent-finalisers │ ├── additional.cc │ ├── expected-exit-code.txt │ └── main.pony ├── small-finalisers │ ├── additional.cc │ ├── expected-exit-code.txt │ └── main.pony ├── string-serialisation │ ├── expected-exit-code.txt │ └── main.pony ├── try-block-cant-catch-cpp-exception │ ├── additional.cc │ ├── expected-exit-code.txt │ └── main.pony ├── try-else-can-initialize-fields │ └── main.pony ├── try-then-can-initialize-fields │ └── main.pony ├── try-then-clause-break-nested │ ├── expected-exit-code.txt │ └── main.pony ├── try-then-clause-break │ ├── expected-exit-code.txt │ └── main.pony ├── try-then-clause-continue-nested │ ├── expected-exit-code.txt │ └── main.pony ├── try-then-clause-continue │ ├── expected-exit-code.txt │ └── main.pony ├── try-then-clause-return-nested │ ├── expected-exit-code.txt │ └── main.pony ├── try-then-clause-return │ ├── expected-exit-code.txt │ └── main.pony ├── union-value-for-tuple-return-type │ ├── expected-exit-code.txt │ └── main.pony ├── while-else-can-initialize-fields │ └── main.pony ├── while-else-trigger-else-clause │ ├── expected-exit-code.txt │ └── main.pony ├── while-else-trigger-while-body │ ├── expected-exit-code.txt │ └── main.pony ├── with-as-expression │ ├── expected-exit-code.txt │ └── main.pony ├── with-error-from-function │ ├── expected-exit-code.txt │ └── main.pony ├── with-error-in-block │ ├── expected-exit-code.txt │ └── main.pony ├── with-in-loop-with-break │ ├── expected-exit-code.txt │ └── main.pony ├── with-in-loop-with-continue │ ├── expected-exit-code.txt │ └── main.pony └── with-standard │ ├── expected-exit-code.txt │ └── main.pony ├── libponyc ├── CMakeLists.txt ├── annotations.cc ├── array.cc ├── badpony.cc ├── bare.cc ├── buildflagset.cc ├── cap.cc ├── cap_safety.cc ├── chain.cc ├── codegen.cc ├── codegen_ffi.cc ├── codegen_optimisation.cc ├── compiler_serialisation.cc ├── dontcare.cc ├── ffi.cc ├── finalisers.cc ├── flatten.cc ├── id.cc ├── iftype.cc ├── lambda.cc ├── lexer.cc ├── lexint.cc ├── literal_inference.cc ├── literal_limits.cc ├── local_inference.cc ├── matchtype.cc ├── object.cc ├── option_parser.cc ├── paint.cc ├── parse_entity.cc ├── parse_expr.cc ├── program.cc ├── reach.cc ├── recover.cc ├── refer.cc ├── scope.cc ├── signature.cc ├── stable_type.cc ├── sugar.cc ├── sugar_expr.cc ├── sugar_traits.cc ├── suggest_alt_name.cc ├── symtab.cc ├── token.cc ├── traits.cc ├── type_check_bind.cc ├── type_check_subtype.cc ├── use.cc ├── util.cc ├── util.h ├── verify.cc └── with.cc ├── libponyrt ├── CMakeLists.txt ├── ds │ ├── fun.cc │ ├── hash.cc │ └── list.cc ├── lang │ └── error.cc ├── mem │ ├── heap.cc │ ├── pagemap.cc │ └── pool.cc ├── util.cc └── util.h └── rt-stress ├── string-message-ubench └── main.pony └── tcp-open-close ├── README.md └── tcp-open-close.pony /.ci-dockerfiles/arm64-unknown-linux-alpine3.21-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.21 2 | 3 | LABEL org.opencontainers.image.source="https://github.com/ponylang/ponyc" 4 | 5 | RUN apk update \ 6 | && apk upgrade \ 7 | && apk add --update --no-cache \ 8 | alpine-sdk \ 9 | binutils-gold \ 10 | clang \ 11 | clang-dev \ 12 | coreutils \ 13 | linux-headers \ 14 | cmake \ 15 | git \ 16 | zlib-dev \ 17 | bash \ 18 | curl \ 19 | py3-pip \ 20 | gdb \ 21 | lldb \ 22 | py3-lldb \ 23 | && pip install --break-system-packages cloudsmith-cli 24 | 25 | # add user pony in order to not run tests as root 26 | RUN adduser -D -u 1001 -s /bin/sh -h /home/pony -g root pony 27 | USER pony 28 | WORKDIR /home/pony 29 | -------------------------------------------------------------------------------- /.ci-dockerfiles/arm64-unknown-linux-alpine3.21-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | NAME="ghcr.io/ponylang/ponyc-ci-arm64-unknown-linux-alpine3.21-builder" 11 | TODAY=$(date +%Y%m%d) 12 | DOCKERFILE_DIR="$(dirname "$0")" 13 | BUILDER="arm64-builder-$(date +%s)" 14 | 15 | docker buildx create --use --name "${BUILDER}" 16 | docker buildx build --provenance false --sbom false --platform linux/arm64 --pull --push -t "${NAME}:${TODAY}" "${DOCKERFILE_DIR}" 17 | docker buildx rm "${BUILDER}" 18 | -------------------------------------------------------------------------------- /.ci-dockerfiles/arm64-unknown-linux-ubuntu24.04-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | NAME="ghcr.io/ponylang/ponyc-ci-arm64-unknown-linux-ubuntu24.04-builder" 11 | TODAY=$(date +%Y%m%d) 12 | DOCKERFILE_DIR="$(dirname "$0")" 13 | BUILDER="arm64-builder-$(date +%s)" 14 | 15 | docker buildx create --use --name "${BUILDER}" 16 | docker buildx build --provenance false --sbom false --platform linux/arm64 --pull --push -t "${NAME}:${TODAY}" "${DOCKERFILE_DIR}" 17 | docker buildx rm "${BUILDER}" 18 | -------------------------------------------------------------------------------- /.ci-dockerfiles/cross-arm/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | NAME="ghcr.io/ponylang/ponyc-ci-cross-arm" 11 | TODAY=$(date +%Y%m%d) 12 | DOCKERFILE_DIR="$(dirname "$0")" 13 | 14 | docker build --pull -t "${NAME}:${TODAY}" "${DOCKERFILE_DIR}" 15 | docker push "${NAME}:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-dockerfiles/cross-armhf/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | NAME="ghcr.io/ponylang/ponyc-ci-cross-armhf" 11 | TODAY=$(date +%Y%m%d) 12 | DOCKERFILE_DIR="$(dirname "$0")" 13 | 14 | docker build --pull -t "${NAME}:${TODAY}" "${DOCKERFILE_DIR}" 15 | docker push "${NAME}:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-dockerfiles/cross-riscv64/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-ubuntu24.04-builder:20240425 2 | 3 | LABEL org.opencontainers.image.source="https://github.com/ponylang/ponyc" 4 | 5 | USER root 6 | 7 | RUN apt-get update \ 8 | && apt-get install -y --no-install-recommends \ 9 | gdb-multiarch \ 10 | qemu-user \ 11 | gcc-10-riscv64-linux-gnu \ 12 | g++-10-riscv64-linux-gnu \ 13 | lldb \ 14 | && rm -rf /var/lib/apt/lists/* \ 15 | && apt-get -y autoremove --purge \ 16 | && apt-get -y clean \ 17 | && ln -s /usr/riscv64-linux-gnu/lib/* /lib 18 | 19 | RUN cmake --version 20 | 21 | USER pony 22 | WORKDIR /home/pony 23 | -------------------------------------------------------------------------------- /.ci-dockerfiles/cross-riscv64/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | NAME="ghcr.io/ponylang/ponyc-ci-cross-riscv64" 11 | TODAY=$(date +%Y%m%d) 12 | DOCKERFILE_DIR="$(dirname "$0")" 13 | 14 | docker build --pull -t "${NAME}:${TODAY}" "${DOCKERFILE_DIR}" 15 | docker push "${NAME}:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-dockerfiles/stdlib-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_TAG=release-alpine 2 | FROM ghcr.io/ponylang/ponyc:${FROM_TAG} 3 | 4 | LABEL org.opencontainers.image.source="https://github.com/ponylang/ponyc" 5 | 6 | ARG MATERIAL_INSIDERS_ACCESS=fail 7 | 8 | RUN apk update \ 9 | && apk upgrade \ 10 | && apk add --update --no-cache \ 11 | bash \ 12 | git-fast-import \ 13 | libffi \ 14 | libffi-dev \ 15 | libressl \ 16 | libressl-dev \ 17 | python3 \ 18 | python3-dev \ 19 | py3-pip \ 20 | tar \ 21 | && pip3 install --upgrade --break-system-packages pip \ 22 | && pip3 install --break-system-packages mkdocs \ 23 | && pip3 install --break-system-packages git+https://${MATERIAL_INSIDERS_ACCESS}@github.com/squidfunk/mkdocs-material-insiders.git 24 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-alpine3.20-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.20 2 | 3 | LABEL org.opencontainers.image.source="https://github.com/ponylang/ponyc" 4 | 5 | RUN apk update \ 6 | && apk upgrade \ 7 | && apk add --update --no-cache \ 8 | alpine-sdk \ 9 | binutils-gold \ 10 | clang \ 11 | clang-dev \ 12 | coreutils \ 13 | linux-headers \ 14 | cmake \ 15 | git \ 16 | zlib-dev \ 17 | bash \ 18 | curl \ 19 | py3-pip \ 20 | gdb \ 21 | lldb \ 22 | py3-lldb \ 23 | && pip install --break-system-packages cloudsmith-cli 24 | 25 | # add user pony in order to not run tests as root 26 | RUN adduser -D -u 1001 -s /bin/sh -h /home/pony -g root pony 27 | USER pony 28 | WORKDIR /home/pony 29 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-alpine3.20-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | TODAY=$(date +%Y%m%d) 11 | DOCKERFILE_DIR="$(dirname "$0")" 12 | 13 | docker build --pull -t "ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-alpine3.20-builder:${TODAY}" \ 14 | "${DOCKERFILE_DIR}" 15 | docker push "ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-alpine3.20-builder:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-alpine3.21-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.21 2 | 3 | LABEL org.opencontainers.image.source="https://github.com/ponylang/ponyc" 4 | 5 | RUN apk update \ 6 | && apk upgrade \ 7 | && apk add --update --no-cache \ 8 | alpine-sdk \ 9 | binutils-gold \ 10 | clang \ 11 | clang-dev \ 12 | coreutils \ 13 | linux-headers \ 14 | cmake \ 15 | git \ 16 | zlib-dev \ 17 | bash \ 18 | curl \ 19 | py3-pip \ 20 | gdb \ 21 | lldb \ 22 | py3-lldb \ 23 | && pip install --break-system-packages cloudsmith-cli 24 | 25 | # add user pony in order to not run tests as root 26 | RUN adduser -D -u 1001 -s /bin/sh -h /home/pony -g root pony 27 | USER pony 28 | WORKDIR /home/pony 29 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-alpine3.21-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | TODAY=$(date +%Y%m%d) 11 | DOCKERFILE_DIR="$(dirname "$0")" 12 | 13 | docker build --pull -t "ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-alpine3.21-builder:${TODAY}" \ 14 | "${DOCKERFILE_DIR}" 15 | docker push "ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-alpine3.21-builder:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-arch-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM archlinux:base 2 | 3 | LABEL org.opencontainers.image.source="https://github.com/ponylang/ponyc" 4 | 5 | RUN pacman -Syyu --noconfirm \ 6 | && pacman -S --noconfirm \ 7 | clang \ 8 | cmake \ 9 | diffutils \ 10 | git \ 11 | lldb \ 12 | make 13 | 14 | # add user pony in order to not run tests as root 15 | RUN useradd -u 1001 -ms /bin/sh -d /home/pony -g root pony 16 | USER pony 17 | WORKDIR /home/pony 18 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-arch-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | DOCKERFILE_DIR="$(dirname "$0")" 11 | NAME="ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-arch-builder" 12 | 13 | # with latest as tag 14 | TAG_AS=latest 15 | docker build -t "${NAME}:${TAG_AS}" "${DOCKERFILE_DIR}" 16 | docker push "${NAME}:${TAG_AS}" 17 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-fedora41-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora:41 2 | 3 | LABEL org.opencontainers.image.source="https://github.com/ponylang/ponyc" 4 | 5 | RUN dnf install -y binutils-gold \ 6 | clang \ 7 | cmake \ 8 | diffutils \ 9 | git \ 10 | make \ 11 | zlib \ 12 | curl \ 13 | python3-pip \ 14 | lldb \ 15 | libstdc++-static \ 16 | && dnf -y autoremove \ 17 | && dnf -y clean all \ 18 | && rm -rf /var/cache/dnf/* \ 19 | && pip3 install cloudsmith-cli 20 | 21 | # needed for GitHub actions 22 | RUN git config --global --add safe.directory /__w/ponyc/ponyc 23 | 24 | # add user pony in order to not run tests as root 25 | RUN useradd -u 1001 -ms /bin/bash -d /home/pony -g root pony 26 | USER pony 27 | WORKDIR /home/pony 28 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-fedora41-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | NAME="ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-fedora41-builder" 11 | TODAY=$(date +%Y%m%d) 12 | DOCKERFILE_DIR="$(dirname "$0")" 13 | 14 | docker build --pull -t "${NAME}:${TODAY}" "${DOCKERFILE_DIR}" 15 | docker push "${NAME}:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-musl-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.20 2 | 3 | 4 | RUN apk update \ 5 | && apk upgrade \ 6 | && apk add --update --no-cache \ 7 | alpine-sdk \ 8 | binutils-gold \ 9 | clang \ 10 | clang-dev \ 11 | coreutils \ 12 | linux-headers \ 13 | cmake \ 14 | git \ 15 | zlib-dev \ 16 | bash \ 17 | curl \ 18 | py3-pip \ 19 | gdb \ 20 | lldb \ 21 | py3-lldb \ 22 | && pip install --break-system-packages cloudsmith-cli 23 | 24 | # add user pony in order to not run tests as root 25 | RUN adduser -D -u 1001 -s /bin/sh -h /home/pony -g root pony 26 | USER pony 27 | WORKDIR /home/pony 28 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-musl-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | TODAY=$(date +%Y%m%d) 11 | DOCKERFILE_DIR="$(dirname "$0")" 12 | 13 | docker build --pull -t "ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-musl-builder:${TODAY}" \ 14 | "${DOCKERFILE_DIR}" 15 | docker push "ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-musl-builder:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-ubuntu22.04-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | NAME="ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-ubuntu22.04-builder" 11 | TODAY=$(date +%Y%m%d) 12 | DOCKERFILE_DIR="$(dirname "$0")" 13 | 14 | docker build --pull -t "${NAME}:${TODAY}" "${DOCKERFILE_DIR}" 15 | docker push "${NAME}:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-dockerfiles/x86-64-unknown-linux-ubuntu24.04-builder/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GHCR when you run this *** 8 | # 9 | 10 | NAME="ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-ubuntu24.04-builder" 11 | TODAY=$(date +%Y%m%d) 12 | DOCKERFILE_DIR="$(dirname "$0")" 13 | 14 | docker build --pull -t "${NAME}:${TODAY}" "${DOCKERFILE_DIR}" 15 | docker push "${NAME}:${TODAY}" 16 | -------------------------------------------------------------------------------- /.ci-scripts/build-stdlib-documentation.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | export LC_ALL=C.UTF-8 7 | export LANG=C.UTF-8 8 | 9 | ponyc packages/stdlib --docs-public --pass expr 10 | sed -i 's/site_name:\ stdlib/site_name:\ Pony Standard Library/' stdlib-docs/mkdocs.yml 11 | 12 | echo "Building docs using mkdocs..." 13 | pushd stdlib-docs 14 | mkdocs build 15 | popd 16 | -------------------------------------------------------------------------------- /.ci-scripts/macOS-configure-networking.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Why? 4 | # See: https://web.archive.org/web/20180129235834/http://danielmendel.github.io/blog/2013/04/07/benchmarkers-beware-the-ephemeral-port-limit/ 5 | 6 | sudo sysctl -w net.inet.tcp.msl=1000 7 | sudo sysctl -w net.inet.ip.portrange.first=32768 8 | sudo sysctl -w net.inet.ip.portrange.hifirst=32768 9 | -------------------------------------------------------------------------------- /.dockerfiles/latest/arm64-unknown-linux-musl/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GitHub Container Registry when you run 8 | # this *** 9 | # 10 | 11 | DOCKERFILE_DIR="$(dirname "$0")" 12 | NAME="ghcr.io/ponylang/ponyc:alpine-arm64" 13 | BUILDER="arm64-builder-$(date +%s)" 14 | 15 | docker buildx create --use --name "${BUILDER}" 16 | docker buildx build --provenance false --sbom false --platform linux/arm64 --pull --push -t "${NAME}" "${DOCKERFILE_DIR}" 17 | docker buildx rm "${BUILDER}" 18 | -------------------------------------------------------------------------------- /.dockerfiles/latest/x86-64-pc-windows-msvc/build-and-push.ps1: -------------------------------------------------------------------------------- 1 | # You should already be logged in to GitHub Container Registry when you run 2 | # this. 3 | $ErrorActionPreference = 'Stop' 4 | 5 | $dockerfileDir = Split-Path $script:MyInvocation.MyCommand.Path 6 | 7 | ## GitHub Container Registry 8 | 9 | docker build --pull -t "ghcr.io/ponylang/ponyc:windows" $dockerfileDir 10 | docker push "ghcr.io/ponylang/ponyc:windows" 11 | -------------------------------------------------------------------------------- /.dockerfiles/latest/x86-64-pc-windows-msvc/git.ini: -------------------------------------------------------------------------------- 1 | [Setup] 2 | Lang=default 3 | Dir=C:\Program Files\Git 4 | Group=Git 5 | NoIcons=0 6 | SetupType=default 7 | Components= 8 | Tasks= 9 | PathOption=Cmd 10 | SSHOption=OpenSSH 11 | CRLFOption=CRLFAlways -------------------------------------------------------------------------------- /.dockerfiles/latest/x86-64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | ENV PATH="/root/.local/share/ponyup/bin:$PATH" 4 | 5 | RUN apt-get update \ 6 | && apt-get install -y --no-install-recommends \ 7 | ca-certificates \ 8 | clang \ 9 | curl \ 10 | g++ \ 11 | git \ 12 | lsb-release \ 13 | make \ 14 | && rm -rf /var/lib/apt/lists/* 15 | 16 | RUN sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/ponylang/ponyup/latest-release/ponyup-init.sh)" \ 17 | && ponyup update ponyc nightly \ 18 | && ponyup update corral nightly \ 19 | && ponyup update changelog-tool nightly 20 | 21 | WORKDIR /src/main 22 | 23 | CMD ["ponyc"] 24 | -------------------------------------------------------------------------------- /.dockerfiles/latest/x86-64-unknown-linux-gnu/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GitHub Container Registry when you run 8 | # this *** 9 | # 10 | 11 | DOCKERFILE_DIR="$(dirname "$0")" 12 | 13 | ## GitHub Container Registry 14 | 15 | docker build --pull -t "ghcr.io/ponylang/ponyc:latest" "${DOCKERFILE_DIR}" 16 | docker push "ghcr.io/ponylang/ponyc:latest" 17 | -------------------------------------------------------------------------------- /.dockerfiles/latest/x86-64-unknown-linux-musl/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.20 2 | 3 | ENV PATH="/root/.local/share/ponyup/bin:$PATH" 4 | 5 | RUN apk add --update --no-cache \ 6 | clang \ 7 | curl \ 8 | build-base \ 9 | binutils-gold \ 10 | git 11 | 12 | RUN sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/ponylang/ponyup/latest-release/ponyup-init.sh)" \ 13 | && ponyup update ponyc nightly \ 14 | && ponyup update corral nightly \ 15 | && ponyup update changelog-tool nightly 16 | 17 | WORKDIR /src/main 18 | 19 | CMD ["ponyc"] 20 | -------------------------------------------------------------------------------- /.dockerfiles/latest/x86-64-unknown-linux-musl/build-and-push.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | # 7 | # *** You should already be logged in to GitHub Container Registry when you run 8 | # this *** 9 | # 10 | 11 | DOCKERFILE_DIR="$(dirname "$0")" 12 | 13 | ## GitHub Container Registry 14 | 15 | docker build --pull -t "ghcr.io/ponylang/ponyc:alpine" "${DOCKERFILE_DIR}" 16 | docker push "ghcr.io/ponylang/ponyc:alpine" 17 | -------------------------------------------------------------------------------- /.dockerfiles/release/x86-64-pc-windows-msvc/git.ini: -------------------------------------------------------------------------------- 1 | [Setup] 2 | Lang=default 3 | Dir=C:\Program Files\Git 4 | Group=Git 5 | NoIcons=0 6 | SetupType=default 7 | Components= 8 | Tasks= 9 | PathOption=Cmd 10 | SSHOption=OpenSSH 11 | CRLFOption=CRLFAlways -------------------------------------------------------------------------------- /.dockerfiles/release/x86-64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | ENV PATH="/root/.local/share/ponyup/bin:$PATH" 4 | 5 | RUN apt-get update \ 6 | && apt-get install -y --no-install-recommends \ 7 | ca-certificates \ 8 | clang \ 9 | curl \ 10 | g++ \ 11 | git \ 12 | lsb-release \ 13 | make \ 14 | && rm -rf /var/lib/apt/lists/* 15 | 16 | RUN sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/ponylang/ponyup/latest-release/ponyup-init.sh)" \ 17 | && ponyup update ponyc release \ 18 | && ponyup update corral release \ 19 | && ponyup update changelog-tool release 20 | 21 | WORKDIR /src/main 22 | 23 | CMD ["ponyc"] 24 | -------------------------------------------------------------------------------- /.dockerfiles/release/x86-64-unknown-linux-musl/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.20 2 | 3 | ENV PATH="/root/.local/share/ponyup/bin:$PATH" 4 | 5 | RUN apk add --update --no-cache \ 6 | clang \ 7 | curl \ 8 | build-base \ 9 | binutils-gold \ 10 | git 11 | 12 | RUN sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/ponylang/ponyup/latest-release/ponyup-init.sh)" \ 13 | && ponyup update ponyc release \ 14 | && ponyup update corral release \ 15 | && ponyup update changelog-tool release 16 | 17 | WORKDIR /src/main 18 | 19 | CMD ["ponyc"] 20 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: ponyc 2 | -------------------------------------------------------------------------------- /.github/actionlint.yaml: -------------------------------------------------------------------------------- 1 | # Configuration related to self-hosted runner. 2 | self-hosted-runner: 3 | labels: 4 | - windows-11-arm 5 | -------------------------------------------------------------------------------- /.github/linters/.markdown-lint.yml: -------------------------------------------------------------------------------- 1 | { 2 | "MD013": false 3 | } 4 | -------------------------------------------------------------------------------- /.github/linters/.yaml-lint.yml: -------------------------------------------------------------------------------- 1 | rules: 2 | line-length: disable 3 | -------------------------------------------------------------------------------- /.github/workflows/add-discuss-during-sync.yml: -------------------------------------------------------------------------------- 1 | name: Add discuss during sync label 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - reopened 8 | issue_comment: 9 | types: 10 | - created 11 | pull_request_target: 12 | types: 13 | - opened 14 | - edited 15 | - ready_for_review 16 | - reopened 17 | pull_request_review: 18 | types: 19 | - submitted 20 | 21 | permissions: 22 | pull-requests: write 23 | 24 | jobs: 25 | add-label: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - name: Add "discuss during sync" label to active GH entity 29 | uses: andymckay/labeler@467347716a3bdbca7f277cb6cd5fa9c5205c5412 30 | with: 31 | repo-token: ${{ secrets.PONYLANG_MAIN_API_TOKEN }} 32 | add-labels: "discuss during sync" 33 | -------------------------------------------------------------------------------- /.github/workflows/lint-action-workflows.yml: -------------------------------------------------------------------------------- 1 | name: Lint GitHub Action Workflows 2 | 3 | on: pull_request 4 | 5 | concurrency: 6 | group: lint-actions-${{ github.ref }} 7 | cancel-in-progress: true 8 | 9 | permissions: 10 | packages: read 11 | 12 | jobs: 13 | lint: 14 | name: Lint 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4.1.1 19 | - name: Check workflow files 20 | uses: docker://ghcr.io/ponylang/shared-docker-ci-actionlint:20250119 21 | with: 22 | args: -color 23 | -------------------------------------------------------------------------------- /.github/workflows/rebuild-stdlib-builder.yml: -------------------------------------------------------------------------------- 1 | name: Manually rebuild stdlib-builder 2 | 3 | on: 4 | workflow_dispatch 5 | 6 | concurrency: 7 | group: "rebuild-stdlib-builder" 8 | cancel-in-progress: true 9 | 10 | permissions: 11 | packages: write 12 | 13 | jobs: 14 | rebuild-stdlib-builder: 15 | name: Update stdlib-builder Docker image 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Login to GitHub Container Registry 19 | # v2.2.0 20 | uses: docker/login-action@5139682d94efc37792e6b54386b5b470a68a4737 21 | with: 22 | registry: ghcr.io 23 | username: ${{ github.repository_owner }} 24 | password: ${{ secrets.GITHUB_TOKEN }} 25 | - name: Checkout 26 | uses: actions/checkout@v4.1.1 27 | - name: Build and push 28 | run: bash .ci-dockerfiles/stdlib-builder/build-and-push.bash 29 | env: 30 | MATERIAL_INSIDERS_ACCESS: ${{ secrets.MATERIAL_INSIDERS_ACCESS }} 31 | -------------------------------------------------------------------------------- /.github/workflows/release-notes-reminder.yml: -------------------------------------------------------------------------------- 1 | name: Release Notes Reminder 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - labeled 7 | 8 | permissions: 9 | packages: read 10 | pull-requests: write 11 | 12 | jobs: 13 | release-note-reminder: 14 | runs-on: ubuntu-latest 15 | name: Prompt to add release notes 16 | steps: 17 | - name: Prompt to add release notes 18 | uses: docker://ghcr.io/ponylang/release-notes-reminder-bot-action:0.1.1 19 | env: 20 | API_CREDENTIALS: ${{ secrets.PONYLANG_MAIN_API_TOKEN }} 21 | 22 | -------------------------------------------------------------------------------- /.github/workflows/remove-discuss-during-sync.yml: -------------------------------------------------------------------------------- 1 | name: Remove discuss during sync label 2 | 3 | on: 4 | issues: 5 | types: 6 | - closed 7 | pull_request_target: 8 | types: 9 | - closed 10 | 11 | permissions: 12 | pull-requests: write 13 | 14 | jobs: 15 | remove-label: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Remove label 19 | uses: andymckay/labeler@467347716a3bdbca7f277cb6cd5fa9c5205c5412 20 | with: 21 | repo-token: ${{ secrets.PONYLANG_MAIN_API_TOKEN }} 22 | remove-labels: "discuss during sync" 23 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/llvm/src"] 2 | path = lib/llvm/src 3 | url = https://github.com/llvm/llvm-project 4 | ignore = dirty 5 | -------------------------------------------------------------------------------- /.markdownlintignore: -------------------------------------------------------------------------------- 1 | benchmark/* 2 | CHANGELOG.md 3 | CODE_OF_CONDUCT.md 4 | .release-notes/ 5 | -------------------------------------------------------------------------------- /.release-notes/0.38.1.md: -------------------------------------------------------------------------------- 1 | ## Fix race condition that can result in a segfault 2 | 3 | We recently introduced some improvements to the handling of garbage collection for short-lived actors when the cycle detector is running. In the process, we introduced a race condition in the runtime that could result in an actor being garbage collected twice which if it were to occur, would result in a crashing program. 4 | 5 | -------------------------------------------------------------------------------- /.release-notes/0.38.3.md: -------------------------------------------------------------------------------- 1 | ## Fix memory safety problem with Array.from_cpointer 2 | 3 | Previously, the `from_cpointer` method in arrays would trust the user to pass a valid pointer. This created an issue where the user could pass a null pointer using `Pointer.create`, leading to a situation where memory safety could be violated by trying to access an element of the array. This change makes it safe to pass a null pointer to `from_cpointer`, which will create a zero-length array. 4 | 5 | ## Fix bad package names in generated documentation 6 | 7 | Previously when you used ponyc's documentation generation functions on a code base that used relative imports like `use "../foo"`, the package name in the generated documentation would be incorrect. 8 | 9 | -------------------------------------------------------------------------------- /.release-notes/0.40.0.md: -------------------------------------------------------------------------------- 1 | ## Add `IsPrime` to `math` package 2 | 3 | Quickly determine if a given number is prime using the 6k ± 1 method. 4 | 5 | All integers (excluding 2 and 3), can be expressed as (6k + i), where i = -1, 0, 1, 2, 3, or 4. Since 2 divides (6k + 0), (6k + 2), and (6k + 4), while 3 divides (6k + 3) that leaves only (6k - 1) and (6k + 1) for expressing primes 6 | 7 | ## Fix possible memory leak 8 | 9 | A possible memory leak in the process package was fixed. 10 | 11 | ## Update supported FreeBSD to FreeBSD 13.0 12 | 13 | As of this release, we now do all FreeBSD testing on FreeBSD 13.0 and all ponyc prebuilt packages are built on FreeBSD 13.0. We will make a best effort to not break prior versions of FreeBSD while they are "supported". 14 | 15 | -------------------------------------------------------------------------------- /.release-notes/0.41.1.md: -------------------------------------------------------------------------------- 1 | ## Fix type constraint check against NullablePointer being omitted in FFI declarations 2 | 3 | This release fixes an issue where the compiler would not perform some type checks against FFI declarations. Specifically, the compiler would fail to validate that the type parameter to the `NullablePointer` type had to be a struct type. This check is important since a program that used a non-struct type in a `NullablePointer` could theoretically segfault at runtime. 4 | 5 | -------------------------------------------------------------------------------- /.release-notes/0.49.1.md: -------------------------------------------------------------------------------- 1 | ## Fix soundness bug introduced 2 | 3 | We previously switched our underlying type system model. In the process, a 4 | soundness hole was introduced where users could assign values to variables with 5 | an ephemeral capability. This could lead to "very bad things". 6 | 7 | The hole was introduced in May of 2021 by [PR #3643](https://github.com/ponylang/ponyc/pull/3643). We've closed the hole so that code such as the following will again be rejected by the compiler. 8 | 9 | ```pony 10 | let map: Map[String, Array[String]] trn^ = recover trn Map[String, Array[String]] end 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /.release-notes/0.51.4.md: -------------------------------------------------------------------------------- 1 | ## Reverts Ansi.erase to erase to the right, not the left 2 | 3 | With the release of 0.49.0, we changed `Ansi.erase` to be erasing left rather than right. This made sense based on the comment on the `Ansi.erase` method. However, the actual usage in the standard library of `Ansi.erase` was expecting it to erase to the right. Because of this change, since 0.49.0, the readline support in the `term` package has been broken. 4 | 5 | We've reverted the changes from the [original PR](https://github.com/ponylang/ponyc/pull/4022) and updated the comment on `Ansi.erase` to note that it erases to right, not the left. 6 | 7 | We would welcome an RFC to discuss supporting both left and right erasure as part of the `Ansi` primitive. 8 | 9 | -------------------------------------------------------------------------------- /.release-notes/0.52.5.md: -------------------------------------------------------------------------------- 1 | ## Fix compiler crash when attempting to mutate a val field 2 | 3 | In Pony 0.52.4 we fixed an unsoundness bug that had been introduced over the summer. While fixing that bug, an error case was missed and as a result, a compiler crash was created where an error message should have been generated. 4 | 5 | We've fixed the crash and it now displays a "left side is immutable" error message. 6 | 7 | -------------------------------------------------------------------------------- /.release-notes/0.56.2.md: -------------------------------------------------------------------------------- 1 | ## "No op" release to get Windows release out 2 | 3 | When we moved from CirrusCI to GitHub Actions, we had some issues with the Windows releases that were do to tiny typos in the config that linting didn't catch. 4 | 5 | This resulted in there being no 0.56.0 and 0.56.1 Windows releases. Because 0.56.1 was primarily to fix a Windows bug, we are doing a 0.56.2 release that should hopefully work for Windows as we think we have found all the tiny typos. 6 | -------------------------------------------------------------------------------- /.release-notes/0.57.1.md: -------------------------------------------------------------------------------- 1 | ## Fix compiling Pony programs on x86 MacOS when XCode 15 is the linker 2 | 3 | With the introduction of XCode 15, you could no longer link Pony programs on x86 MacOS. We've fixed the issue. Apple Silicon was uneffected. 4 | 5 | -------------------------------------------------------------------------------- /.release-notes/0.58.1.md: -------------------------------------------------------------------------------- 1 | ## Fix missing "runtime_info" package documentation 2 | 3 | The documentation for the "runtime_info" package wasn't being generated. We've fixed that oversight. 4 | 5 | ## Use the correct LLVM intrinsics for `powi` on *nix. 6 | 7 | We were using outdated LLVM intrinsics `llvm.powi.f32`j and `llvm.powi.f64`; updated to use `llvm.powi.f32.i32` and `llvm.powi.f64.i32`. 8 | 9 | -------------------------------------------------------------------------------- /.release-notes/0.58.13.md: -------------------------------------------------------------------------------- 1 | ## Make sure systematic testing doesn't switch to suspended thread 2 | 3 | Previously, the systematic testing next thread logic would consider switching to the pinned actor thread even if it was suspended. This was very wasteful since the suspended pinned actor thread would not do any meaningful work and almost immediately re-suspend itself. 4 | 5 | We have changed things so that the next thread logic properly takes into account whether the pinned actor thread is suspended or not when selecting the next thread to activate. 6 | 7 | ## Fix race condition in epoll ASIO system 8 | 9 | We've fixed a race condition in the epoll ASIO subsystem that could result in "unexpected behavior" when using one-shot epoll events. At the time the bug was fixed, this means that only the `TCPConnection` actor was impacted part of the standard library. 10 | -------------------------------------------------------------------------------- /.release-notes/0.58.3.md: -------------------------------------------------------------------------------- 1 | ## Fix incorrect markdown formatting for types from documentation generation 2 | 3 | Previously, we were incorrectly creating field types in markdown documentation. The markdown for the type should have been on a single line but for long union types, it would end up crossing lines. That resulted in broken markdown that wouldn't display correctly. 4 | 5 | -------------------------------------------------------------------------------- /.release-notes/0.58.5.md: -------------------------------------------------------------------------------- 1 | ## Update the base image for our ponyc images 2 | 3 | Our Docker images have had their base image updated from Ubuntu 22.04 to Ubuntu 24.04. 4 | 5 | -------------------------------------------------------------------------------- /.release-notes/0.58.9.md: -------------------------------------------------------------------------------- 1 | ## Fixed an issue that caused the `actor_pinning` documentation to not be built 2 | 3 | We fixed an issue that caused the `actor_pinning` documentation to not be built. This issue has been resolved and the documentation is now available. 4 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.59.0 2 | -------------------------------------------------------------------------------- /benchmark/README.md: -------------------------------------------------------------------------------- 1 | Benchmarks for pony runtime 2 | 3 | Under this directory are benchmarks for the pony runtime that 4 | use the Google Benchmark Library. Run via `make benchmark` target. 5 | 6 | For details Google Benchmark Library readme at: ../lib/gbenchmark/README.md 7 | Google Benchmark examples can be found at: ../lib/gbenchmark/test/ 8 | -------------------------------------------------------------------------------- /benchmark/libponyc/README.md: -------------------------------------------------------------------------------- 1 | Benchmarks for libponyc. 2 | -------------------------------------------------------------------------------- /benchmark/libponyrt/README.md: -------------------------------------------------------------------------------- 1 | Benchmarks for libponyrt. 2 | -------------------------------------------------------------------------------- /examples/circle/main.pony: -------------------------------------------------------------------------------- 1 | use "collections" 2 | 3 | class Circle 4 | var _radius: F32 5 | 6 | new create(radius': F32) => 7 | _radius = radius' 8 | 9 | fun ref get_radius(): F32 => 10 | _radius 11 | 12 | fun ref get_area(): F32 => 13 | F32.pi() * _radius.pow(2) 14 | 15 | fun ref get_circumference(): F32 => 16 | 2 * _radius * F32.pi() 17 | 18 | actor Main 19 | new create(env: Env) => 20 | 21 | for i in Range[F32](1.0, 101.0) do 22 | let c = Circle(i) 23 | 24 | var str = 25 | recover val 26 | "Radius: " + c.get_radius().string() + "\n" + 27 | "Circumference: " + c.get_circumference().string() + "\n" + 28 | "Area: " + c.get_area().string() + "\n" 29 | end 30 | 31 | env.out.print(str) 32 | end 33 | -------------------------------------------------------------------------------- /examples/counter/main.pony: -------------------------------------------------------------------------------- 1 | use "collections" 2 | 3 | actor Counter 4 | var _count: U32 5 | 6 | new create() => 7 | _count = 0 8 | 9 | be increment() => 10 | _count = _count + 1 11 | 12 | be get_and_reset(main: Main) => 13 | main.display(_count) 14 | _count = 0 15 | 16 | actor Main 17 | var _env: Env 18 | 19 | new create(env: Env) => 20 | _env = env 21 | 22 | var count: U32 = try env.args(1)?.u32()? else 10 end 23 | var counter = Counter 24 | 25 | for i in Range[U32](0, count) do 26 | counter.increment() 27 | end 28 | 29 | counter.get_and_reset(this) 30 | 31 | be display(result: U32) => 32 | _env.out.print(result.string()) 33 | -------------------------------------------------------------------------------- /examples/dtrace/gc.d: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env dtrace -s 2 | 3 | #pragma D option quiet 4 | #pragma D option dynvarsize=64m 5 | 6 | pony$target:::gc-start 7 | { 8 | @count["GC Passes"] = count(); 9 | self->start_gc = timestamp; 10 | } 11 | 12 | pony$target:::gc-end 13 | /self->start_gc != 0/ 14 | { 15 | @quant["Time in GC (ns)"] = quantize(timestamp - self->start_gc); 16 | @times["Total time"] = sum(timestamp - self->start_gc); 17 | self->start_gc = 0; 18 | } 19 | 20 | END 21 | { 22 | printa(@count); 23 | printa(@quant); 24 | printa(@times); 25 | } 26 | -------------------------------------------------------------------------------- /examples/dtrace/mbox-size.d: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env dtrace -s 2 | 3 | #pragma D option quiet 4 | 5 | /* 6 | * This script only tracks user actor -> user actor messages. 7 | * Messages such as ACTORMSG_ACK and ACTORMSG_CONF (see telemetry.d) 8 | * aren't caused directly by Pony code that is visible to the 9 | * programmer. Invisible system messages are detected with the 10 | * 0xffffff00 mask. 11 | */ 12 | 13 | pony$target:::actor-msg-send 14 | /(arg1 & 0xffffff00)!= 0xffffff00/ 15 | { 16 | @in[arg3] = count(); 17 | } 18 | 19 | pony$target:::actor-msg-run 20 | { 21 | @out[arg1] = count(); 22 | } 23 | 24 | tick-1sec 25 | { 26 | printf("Into mbox (actor-msg-send):\n"); 27 | printa(@in); 28 | clear(@in); 29 | printf("Out of mbox (actor-msg-run):\n"); 30 | printa(@out); 31 | clear(@out); 32 | printf("\n"); 33 | } 34 | -------------------------------------------------------------------------------- /examples/dtrace/message-types.d: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env dtrace -s 2 | 3 | #pragma D option quiet 4 | 5 | pony$target:::actor-msg-send 6 | { 7 | @type[arg1] = count(); 8 | } 9 | 10 | tick-1sec 11 | { 12 | printa(@type); 13 | clear(@type); 14 | printf("\n"); 15 | } 16 | -------------------------------------------------------------------------------- /examples/dtrace/nanosleep.d: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env dtrace -s 2 | 3 | #pragma D option quiet 4 | 5 | pony$target:::cpu-nanosleep 6 | { 7 | @sleep[cpu] = quantize(arg0 / 1000); 8 | } 9 | 10 | tick-1sec 11 | { 12 | printf("nanosleep call times, in microseconds, per CPU\n"); 13 | printa(@sleep); 14 | clear(@sleep); 15 | } 16 | -------------------------------------------------------------------------------- /examples/dtrace/scheduling.d: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env dtrace -x aggsortkey -x aggsortkeypos=1 -s 2 | 3 | #pragma D option quiet 4 | 5 | pony$target:::cpu-nanosleep 6 | { 7 | @timer["Nanosleep (ns)"] = sum(arg0) 8 | } 9 | 10 | pony$target:::actor-scheduled 11 | { 12 | @counter["Actor Scheduled", arg1] = count(); 13 | } 14 | 15 | pony$target:::actor-descheduled 16 | { 17 | @counter["Actor De-Scheduled", arg1] = count(); 18 | } 19 | 20 | pony$target:::actor-msg-run 21 | { 22 | @counter["Actor Messages", arg1] = count(); 23 | } 24 | 25 | pony$target:::work-steal-successful 26 | { 27 | @work["Successful Work Stealing", arg0] = count(); 28 | } 29 | 30 | pony$target:::work-steal-failure 31 | { 32 | @work["Failed Work Stealing", arg0] = count(); 33 | } 34 | 35 | END 36 | { 37 | printa(@counter); 38 | printa(@work); 39 | printa(@timer); 40 | } 41 | -------------------------------------------------------------------------------- /examples/ffi-callbacks/callbacks.c: -------------------------------------------------------------------------------- 1 | typedef void(*CB)(void*, int); 2 | 3 | void do_callback(CB callback, void* env) 4 | { 5 | callback(env, 10); 6 | } 7 | -------------------------------------------------------------------------------- /examples/ffi-struct/struct.c: -------------------------------------------------------------------------------- 1 | typedef struct Inner 2 | { 3 | int x; 4 | } Inner; 5 | 6 | typedef struct Outer 7 | { 8 | struct Inner inner_embed; 9 | struct Inner* inner_var; 10 | } Outer; 11 | 12 | void modify_via_outer(Outer* s) 13 | { 14 | s->inner_embed.x = 10; 15 | s->inner_var->x = 15; 16 | } 17 | 18 | void modify_inner(Inner* s) 19 | { 20 | s->x = 5; 21 | } 22 | -------------------------------------------------------------------------------- /examples/files/files.pony: -------------------------------------------------------------------------------- 1 | use "files" 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let caps = recover val FileCaps.>set(FileRead).>set(FileStat) end 6 | 7 | try 8 | with file = OpenFile( 9 | FilePath(FileAuth(env.root), env.args(1)?, caps)) as File 10 | do 11 | env.out.print(file.path.path) 12 | for line in file.lines() do 13 | env.out.print(consume line) 14 | end 15 | end 16 | else 17 | try 18 | env.out.print("Couldn't open " + env.args(1)?) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /examples/helloworld/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | env.out.print("Hello, world.") 4 | -------------------------------------------------------------------------------- /examples/net/client.pony: -------------------------------------------------------------------------------- 1 | use "net" 2 | 3 | class ClientSide is TCPConnectionNotify 4 | let _env: Env 5 | 6 | new iso create(env: Env) => 7 | _env = env 8 | 9 | fun ref connecting(conn: TCPConnection ref, count: U32) => 10 | _env.out.print("connecting: " + count.string()) 11 | 12 | fun ref connected(conn: TCPConnection ref) => 13 | try 14 | (let host, let service) = conn.remote_address().name()? 15 | _env.out.print("connected to " + host + ":" + service) 16 | conn.set_nodelay(true) 17 | conn.set_keepalive(10) 18 | conn.write("client says hi") 19 | end 20 | 21 | fun ref connect_failed(conn: TCPConnection ref) => 22 | _env.out.print("connect failed") 23 | 24 | fun ref received(conn: TCPConnection ref, data: Array[U8] iso, 25 | times: USize): Bool 26 | => 27 | _env.out.print(consume data) 28 | true 29 | 30 | fun ref closed(conn: TCPConnection ref) => 31 | _env.out.print("client closed") 32 | -------------------------------------------------------------------------------- /examples/net/net.pony: -------------------------------------------------------------------------------- 1 | use "net" 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let limit = try 6 | env.args(1)?.usize()? 7 | else 8 | 1 9 | end 10 | 11 | TCPListener(TCPListenAuth(env.root), recover Listener(env, limit) end) 12 | UDPSocket(UDPAuth(env.root), recover Pong(env) end) 13 | -------------------------------------------------------------------------------- /examples/net/server.pony: -------------------------------------------------------------------------------- 1 | use "net" 2 | 3 | class ServerSide is TCPConnectionNotify 4 | let _env: Env 5 | 6 | new iso create(env: Env) => 7 | _env = env 8 | 9 | fun ref accepted(conn: TCPConnection ref) => 10 | try 11 | (let host, let service) = conn.remote_address().name()? 12 | _env.out.print("accepted from " + host + ":" + service) 13 | conn.write("server says hi") 14 | end 15 | 16 | fun ref received(conn: TCPConnection ref, data: Array[U8] iso, 17 | times: USize): Bool 18 | => 19 | _env.out.print(consume data) 20 | conn.dispose() 21 | true 22 | 23 | fun ref closed(conn: TCPConnection ref) => 24 | _env.out.print("server closed") 25 | 26 | fun ref connect_failed(conn: TCPConnection ref) => 27 | _env.out.print("connect failed") 28 | -------------------------------------------------------------------------------- /examples/pony_check/main.pony: -------------------------------------------------------------------------------- 1 | use "pony_test" 2 | use "pony_check" 3 | 4 | actor Main is TestList 5 | new create(env: Env) => 6 | PonyTest(env, this) 7 | 8 | new make() => None 9 | 10 | fun tag tests(test: PonyTest) => 11 | test(Property1UnitTest[Array[USize]](_ListReverseProperty)) 12 | test(Property1UnitTest[Array[USize]](_ListReverseOneProperty)) 13 | test(_ListReverseMultipleProperties) 14 | test(Property1UnitTest[MyLittlePony](_CustomClassFlatMapProperty)) 15 | test(Property1UnitTest[MyLittlePony](_CustomClassMapProperty)) 16 | test(Property1UnitTest[MyLittlePony](_CustomClassCustomGeneratorProperty)) 17 | test(Property1UnitTest[String](_AsyncTCPSenderProperty)) 18 | test(Property1UnitTest[(USize, Array[_OperationOnCollection[String]])](_OperationOnCollectionProperty)) 19 | -------------------------------------------------------------------------------- /examples/printargs/printargs.pony: -------------------------------------------------------------------------------- 1 | use "cli" 2 | 3 | actor Main 4 | new create(env: Env) => 5 | var str = recover String end 6 | 7 | for s in env.args.values() do 8 | str.append(s) 9 | str.append(" ") 10 | end 11 | 12 | env.out.print(consume str) 13 | 14 | let envvars = EnvVars(env.vars) 15 | 16 | for (k, v) in envvars.pairs() do 17 | env.out.print(k + " = " + v) 18 | end 19 | -------------------------------------------------------------------------------- /examples/producer-consumer/consumer.pony: -------------------------------------------------------------------------------- 1 | use "collections" 2 | 3 | actor Consumer 4 | var _quantity_to_consume: U32 5 | let _buffer: Buffer 6 | let _out: OutStream 7 | 8 | new create(quantity_to_consume: U32, buffer: Buffer, out: OutStream) => 9 | _quantity_to_consume = quantity_to_consume 10 | _buffer = buffer 11 | _out = out 12 | 13 | be start_consuming(count: U32 = 0) => 14 | _buffer.permission_to_consume(this) 15 | if count < _quantity_to_consume then start_consuming(count + 1) end 16 | 17 | be consuming(product: Product) => 18 | _out.print("**Consumer** Consuming product " + product.id.string()) 19 | _quantity_to_consume = _quantity_to_consume -1 20 | -------------------------------------------------------------------------------- /examples/producer-consumer/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | """ 3 | Producer-Consumer concurrency problem. 4 | 5 | Pony has no blocking operations. 6 | The Pony standard library is structured in this way to use notifier objects, 7 | callbacks and promises to make programming in this style easier. 8 | """ 9 | 10 | new create(env: Env) => 11 | let buffer = Buffer(20, env.out) 12 | 13 | let producer = Producer(2, buffer, env.out) 14 | let consumer = Consumer(3, buffer, env.out) 15 | 16 | consumer.start_consuming() 17 | producer.start_producing() 18 | 19 | env.out.print("**Main** Finished.") 20 | -------------------------------------------------------------------------------- /examples/producer-consumer/producer.pony: -------------------------------------------------------------------------------- 1 | use "collections" 2 | 3 | actor Producer 4 | var _quantity_to_produce: U32 5 | let _buffer: Buffer 6 | var _num: U32 = 0 7 | let _out: OutStream 8 | 9 | new create(quantity_to_produce: U32, buffer: Buffer, out: OutStream) => 10 | _quantity_to_produce = quantity_to_produce 11 | _buffer = buffer 12 | _out = out 13 | 14 | be start_producing(count: U32 = 0) => 15 | _buffer.permission_to_produce(this) 16 | if count < _quantity_to_produce then start_producing(count + 1) end 17 | 18 | be produce() => 19 | _out.print("**Producer** Producing product " + _num.string()) 20 | let prod: Product = Product(_num, "Description of product " + _num.string()) 21 | _buffer.store_product(prod) 22 | _num = _num + 1 23 | -------------------------------------------------------------------------------- /examples/producer-consumer/product.pony: -------------------------------------------------------------------------------- 1 | class val Product 2 | let id: U32 3 | let description: String 4 | 5 | new val create(id': U32, description': String) => 6 | id = id' 7 | description = description' 8 | -------------------------------------------------------------------------------- /examples/systemtap/gc.stp: -------------------------------------------------------------------------------- 1 | global time_in_gc, tmp_ts 2 | 3 | probe process.mark("gc-start") 4 | { 5 | tmp_ts[$arg1] = gettimeofday_ns(); 6 | } 7 | 8 | probe process.mark("gc-end") 9 | { 10 | delta = gettimeofday_ns() - tmp_ts[$arg1]; 11 | time_in_gc <<< delta; 12 | delete tmp_ts[$arg1]; 13 | } 14 | 15 | probe end 16 | { 17 | printf("Total GC passes: %d\n", @count(time_in_gc)); 18 | print(@hist_log(time_in_gc)); 19 | printf("Total time spent in GC (in nano seconds): %d\n", @sum(time_in_gc)); 20 | } 21 | -------------------------------------------------------------------------------- /examples/timers/timers.pony: -------------------------------------------------------------------------------- 1 | use "time" 2 | 3 | class TimerPrint is TimerNotify 4 | var _env: Env 5 | var _count: U64 = 0 6 | 7 | new iso create(env: Env) => 8 | _env = env 9 | 10 | fun ref apply(timer: Timer, count: U64): Bool => 11 | _count = _count + count 12 | _env.out.print("timer: " + _count.string()) 13 | _count < 10 14 | 15 | fun ref cancel(timer: Timer) => 16 | _env.out.print("timer cancelled") 17 | 18 | actor Main 19 | new create(env: Env) => 20 | let timers = Timers 21 | 22 | let t1 = Timer(TimerPrint(env), 500000000, 500000000) // 500 ms 23 | let t1' = t1 24 | timers(consume t1) 25 | timers.cancel(t1') 26 | 27 | let t2 = Timer(TimerPrint(env), 500000000, 500000000) // 500 ms 28 | timers(consume t2) 29 | -------------------------------------------------------------------------------- /lib/llvm/patches/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ponylang/ponyc/65a06e20509a5db94859742e587520446258283d/lib/llvm/patches/.keep -------------------------------------------------------------------------------- /packages/actor_pinning/_test.pony: -------------------------------------------------------------------------------- 1 | use "pony_test" 2 | 3 | actor \nodoc\ Main is TestList 4 | new create(env: Env) => PonyTest(env, this) 5 | new make() => None 6 | 7 | fun tag tests(test: PonyTest) => 8 | None 9 | -------------------------------------------------------------------------------- /packages/actor_pinning/auth.pony: -------------------------------------------------------------------------------- 1 | primitive PinUnpinActorAuth 2 | new create(from: AmbientAuth) => 3 | None 4 | -------------------------------------------------------------------------------- /packages/backpressure/auth.pony: -------------------------------------------------------------------------------- 1 | primitive ApplyReleaseBackpressureAuth 2 | new create(from: AmbientAuth) => 3 | None 4 | -------------------------------------------------------------------------------- /packages/buffered/buffered.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Buffered Package 3 | 4 | The Buffered package provides two classes, `Writer` and `Reader`, for 5 | writing and reading messages using common encodings. These classes are 6 | useful when dealing with things like network data and binary file 7 | formats. 8 | 9 | ## Example program 10 | 11 | ```pony 12 | use "buffered" 13 | 14 | actor Main 15 | new create(env: Env) => 16 | let reader = Reader 17 | let writer = Writer 18 | 19 | writer.u32_be(42) 20 | writer.f32_be(3.14) 21 | 22 | let b = recover iso Array[U8] end 23 | 24 | for chunk in writer.done().values() do 25 | b.append(chunk) 26 | end 27 | 28 | reader.append(consume b) 29 | 30 | try 31 | env.out.print(reader.u32_be()?.string()) // prints 42 32 | env.out.print(reader.f32_be()?.string()) // prints 3.14 33 | end 34 | ``` 35 | """ 36 | -------------------------------------------------------------------------------- /packages/builtin/ambient_auth.pony: -------------------------------------------------------------------------------- 1 | primitive AmbientAuth 2 | """ 3 | This type represents the root capability. When a Pony program starts, the 4 | Env passed to the Main actor contains an instance of the root capability. 5 | 6 | Ambient access to the root capability is denied outside of the builtin 7 | package. Inside the builtin package, only Env creates a Root. 8 | 9 | The root capability can be used by any package that wants to establish a 10 | principle of least authority. A typical usage is to have a parameter on a 11 | constructor for some resource that expects a limiting capability specific to 12 | the package, but will also accept the root capability as representing 13 | unlimited access. 14 | """ 15 | new _create() => 16 | None 17 | -------------------------------------------------------------------------------- /packages/builtin/any.pony: -------------------------------------------------------------------------------- 1 | interface tag Any 2 | -------------------------------------------------------------------------------- /packages/builtin/bool.pony: -------------------------------------------------------------------------------- 1 | primitive Bool is Stringable 2 | new create(from: Bool) => from 3 | 4 | fun eq(y: Bool): Bool => this == y 5 | fun ne(y: Bool): Bool => this != y 6 | fun op_and(y: Bool): Bool => this and y 7 | fun op_or(y: Bool): Bool => this or y 8 | fun op_xor(y: Bool): Bool => this xor y 9 | fun op_not(): Bool => not this 10 | 11 | fun string(): String iso^ => 12 | (if this then "true" else "false" end).string() 13 | -------------------------------------------------------------------------------- /packages/builtin/builtin.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Builtin package 3 | 4 | The builtin package is home to the following standard library members: 5 | 6 | 1. Types the compiler needs to know exist, such as None. 7 | 2. Types with "magic" internal workings that must be supplied directly by the 8 | compiler, such as U32. 9 | 3. Any types needed by others in builtin. 10 | 11 | The public types that are defined in this package will always be in scope for 12 | every Pony source file. For details on specific packages, see their individual 13 | entity entries. 14 | """ 15 | 16 | use @pony_ctx[Pointer[None]]() 17 | use @pony_alloc[Pointer[U8]](ctx: Pointer[None], size: USize) 18 | use @pony_alloc_final[Pointer[U8]](ctx: Pointer[None], size: USize) 19 | use @pony_exitcode[None](code: I32) 20 | use @pony_get_exitcode[I32]() 21 | use @pony_triggergc[None](ctx: Pointer[None]) 22 | use @ponyint_hash_block[USize](ptr: Pointer[None] tag, size: USize) 23 | use @ponyint_hash_block64[U64](ptr: Pointer[None] tag, size: USize) 24 | -------------------------------------------------------------------------------- /packages/builtin/disposable_actor.pony: -------------------------------------------------------------------------------- 1 | interface tag DisposableActor 2 | """ 3 | An interface used to asynchronously dispose of an actor. 4 | """ 5 | be dispose() 6 | -------------------------------------------------------------------------------- /packages/builtin/do_not_optimise.pony: -------------------------------------------------------------------------------- 1 | primitive DoNotOptimise 2 | """ 3 | Contains functions preventing some compiler optimisations, namely dead code 4 | removal. This is useful for benchmarking purposes. 5 | """ 6 | 7 | fun apply[A](obj: A) => 8 | """ 9 | Prevent the compiler from optimising out obj and any computation it is 10 | derived from. This doesn't prevent constant propagation. 11 | """ 12 | compile_intrinsic 13 | 14 | fun observe() => 15 | """ 16 | Prevent the compiler from optimising out writes to an object marked by 17 | the apply function. 18 | """ 19 | compile_intrinsic 20 | -------------------------------------------------------------------------------- /packages/builtin/none.pony: -------------------------------------------------------------------------------- 1 | primitive None is Stringable 2 | fun string(): String iso^ => 3 | "None".string() 4 | -------------------------------------------------------------------------------- /packages/builtin/read_seq.pony: -------------------------------------------------------------------------------- 1 | interface box ReadSeq[A] 2 | """ 3 | The readable interface of a sequence. 4 | """ 5 | fun size(): USize 6 | """ 7 | Returns the number of elements in the sequence. 8 | """ 9 | 10 | fun apply(i: USize): this->A ? 11 | """ 12 | Returns the i-th element of the sequence. Raises an error if the index 13 | is out of bounds. Note that this returns this->A, not A. 14 | """ 15 | 16 | fun values(): Iterator[this->A]^ 17 | """ 18 | Returns an iterator over the elements of the sequence. Note that this 19 | iterates over this->A, not A. 20 | """ 21 | 22 | interface box ReadElement[A] 23 | """ 24 | Used to show that a ReadSeq can return an element of a specific unmodified 25 | type. 26 | """ 27 | fun apply(i: USize): A ? 28 | -------------------------------------------------------------------------------- /packages/builtin/source_loc.pony: -------------------------------------------------------------------------------- 1 | interface val SourceLoc 2 | """ 3 | Represents a location in a Pony source file, as reported by `__loc`. 4 | """ 5 | fun file(): String 6 | """ 7 | Name and path of source file. 8 | """ 9 | 10 | fun type_name(): String 11 | """ 12 | Name of nearest class, actor, primitive, struct, interface, or trait. 13 | """ 14 | 15 | fun method_name(): String 16 | """ 17 | Name of containing method. 18 | """ 19 | 20 | fun line(): USize 21 | """ 22 | Line number within file. 23 | Line numbers start at 1. 24 | """ 25 | 26 | fun pos(): USize 27 | """ 28 | Character position on line. 29 | Character positions start at 1. 30 | """ 31 | -------------------------------------------------------------------------------- /packages/builtin/stringable.pony: -------------------------------------------------------------------------------- 1 | interface box Stringable 2 | """ 3 | Things that can be turned into a String. 4 | """ 5 | fun string(): String iso^ 6 | """ 7 | Generate a string representation of this object. 8 | """ 9 | -------------------------------------------------------------------------------- /packages/bureaucracy/bureaucracy.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Bureaucracy package 3 | 4 | It happens to almost every program. It starts small, tiny if you will, like a 5 | village where every actor knows every other actor and shutdown is easy. One day 6 | you realize your program is no longer a cute seaside hamlet, its a bustling 7 | metropolis and you are doing way too much work to keep track of everything. 8 | What do you do? Call for a little bureaucracy. 9 | 10 | The bureaucracy contains objects designed to ease your bookkeeping burdens. 11 | Need to shutdown a number of actors together? Check out `Custodian`. Need 12 | to keep track of a lot of stuff and be able to look it up by name? Check out 13 | `Registrar`. 14 | 15 | Put bureaucracy to use today and before long, your sprawling metropolis of a 16 | code base will be manageable again in no time. 17 | """ 18 | -------------------------------------------------------------------------------- /packages/capsicum/capsicum.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Capsicum package 3 | 4 | Access to Capsicum capabilities for UNIX systems -- primarily in use by BSD-based systems. 5 | """ 6 | -------------------------------------------------------------------------------- /packages/collections/collections.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Collections package 3 | 4 | The Collections package provides a variety of collection classes, 5 | including map, set, range, heap, ring buffer, list, and flags. 6 | 7 | `Map` - Hashmap by strutural equality (use `MapIs` for identity equality). 8 | 9 | `Set` - A set built on top of `Map` using structural equility (use `SetIs` for identity equality). 10 | 11 | `Range` - Iterate over a range of numbers with optional step size. 12 | 13 | `BinaryHeap` - A priority queue implemented as a binary heap -- use a `BinaryHeapPriority` parameter to determine priority. 14 | 15 | `RingBuffer` - A ring buffer with fixed size. 16 | 17 | `List` - A doubly linked list. 18 | 19 | `Flags` - A set of single bit flags (size determined upon creation). 20 | """ 21 | -------------------------------------------------------------------------------- /packages/collections/persistent/_bits.pony: -------------------------------------------------------------------------------- 1 | primitive _Bits 2 | fun collision_depth(): U32 => 6 3 | 4 | fun set_bit(bm: U32, i: U32): U32 => 5 | bm or (U32(1) <<~ i) 6 | 7 | fun clear_bit(bm: U32, i: U32): U32 => 8 | bm and (not (U32(1) <<~ i)) 9 | 10 | fun check_bit(bm: U32, i: U32): Bool => 11 | (bm and (U32(1) <<~ i)) != 0 12 | 13 | fun mask32(n: U32, d: U32): U32 => 14 | (n >> (d *~ 5)) and 0b11111 15 | 16 | fun mask(n: USize, d: USize): USize => 17 | (n >> (d *~ 5)) and 0b11111 18 | 19 | fun next_pow32(n: USize): USize => 20 | USize(32) << (n *~ 5) 21 | -------------------------------------------------------------------------------- /packages/collections/persistent/persistent.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Persistent Collections Package 3 | 4 | `List` - A persistent list with functional transformations. 5 | 6 | `Map` - A persistent map based on the Compressed Hash Array Mapped Prefix-tree 7 | from 'Optimizing Hash-Array Mapped Tries for Fast and Lean Immutable JVM 8 | Collections' by Michael J. Steindorfer and Jurgen J. Vinju. 9 | 10 | `Set` - A persistent set implemented as a persistent map of an alias of a type 11 | to itself. 12 | 13 | `Vec` - A persistent vector based on the Hash Array Mapped Trie from 'Ideal Hash 14 | Trees' by Phil Bagwell. 15 | """ 16 | -------------------------------------------------------------------------------- /packages/files/auth.pony: -------------------------------------------------------------------------------- 1 | primitive FileAuth 2 | new create(from: AmbientAuth) => 3 | None 4 | -------------------------------------------------------------------------------- /packages/format/align.pony: -------------------------------------------------------------------------------- 1 | primitive AlignLeft 2 | primitive AlignRight 3 | primitive AlignCenter 4 | 5 | type Align is 6 | ( AlignLeft 7 | | AlignRight 8 | | AlignCenter ) 9 | -------------------------------------------------------------------------------- /packages/format/prefix_spec.pony: -------------------------------------------------------------------------------- 1 | trait val PrefixSpec 2 | 3 | primitive PrefixDefault is PrefixSpec 4 | 5 | primitive PrefixSpace is PrefixSpec 6 | primitive PrefixSign is PrefixSpec 7 | 8 | type PrefixNumber is 9 | ( PrefixDefault 10 | | PrefixSpace 11 | | PrefixSign ) 12 | -------------------------------------------------------------------------------- /packages/math/greatest_common_divisor.pony: -------------------------------------------------------------------------------- 1 | primitive GreatestCommonDivisor 2 | """ 3 | Get greatest common divisor of x and y. 4 | 5 | Providing 0 will result in an error. 6 | 7 | Example usage: 8 | 9 | ```pony 10 | use "math" 11 | 12 | actor Main 13 | new create(env: Env) => 14 | try 15 | let gcd = GreatestCommonDivisor[I64](10, 20)? 16 | env.out.print(gcd.string()) 17 | else 18 | env.out.print("No GCD") 19 | end 20 | ``` 21 | """ 22 | fun apply[A: Integer[A] val](x: A, y: A): A ? => 23 | let zero = A.from[U8](0) 24 | if (x == zero) or (y == zero) then 25 | error 26 | end 27 | 28 | var x': A = x 29 | var y': A = y 30 | 31 | while y' != zero do 32 | let z = y' 33 | y' = x' % y' 34 | x' = z 35 | end 36 | 37 | x' 38 | -------------------------------------------------------------------------------- /packages/math/least_common_multiple.pony: -------------------------------------------------------------------------------- 1 | primitive LeastCommonMultiple 2 | """ 3 | Get the least common multiple of x and y where both x and y >= 1. 4 | 5 | Providing 0 or numbers that overflow the integer width will result in an 6 | error. 7 | 8 | Example usage: 9 | 10 | ```pony 11 | use "math" 12 | 13 | actor Main 14 | new create(env: Env) => 15 | try 16 | let lcm = LeastCommonMultiple[U64](10, 20)? 17 | env.out.print(lcm.string()) 18 | else 19 | env.out.print("No LCM") 20 | end 21 | ``` 22 | """ 23 | fun apply[A: (Integer[A] val & Unsigned)](x: A, y: A): A ? => 24 | (x / GreatestCommonDivisor[A](x, y)?) *? y 25 | -------------------------------------------------------------------------------- /packages/math/math.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Math package 3 | 4 | Given the name `Math` for this package, you'd expect it have a broad and grand 5 | scope. Surprise! Not currently. However, we do have the most useful of all 6 | programming language math constructs: fibonacci! 7 | 8 | People like to make fun of fibonacci but let's face it, no fibonacci, no 9 | benchmarks. We hear from some of our engineer friends that math is very 10 | important to programming, we call upon that particular class of engineer friends 11 | to help us fill out this package with more maths than you can shake a stick at. 12 | Btw, in case you are wondering, yes we can shake a stick at a lot of maths. 13 | """ 14 | -------------------------------------------------------------------------------- /packages/net/auth.pony: -------------------------------------------------------------------------------- 1 | primitive NetAuth 2 | new create(from: AmbientAuth) => 3 | None 4 | 5 | primitive DNSAuth 6 | new create(from: (AmbientAuth | NetAuth)) => 7 | None 8 | 9 | primitive UDPAuth 10 | new create(from: (AmbientAuth | NetAuth)) => 11 | None 12 | 13 | primitive TCPAuth 14 | new create(from: (AmbientAuth | NetAuth)) => 15 | None 16 | 17 | primitive TCPListenAuth 18 | new create(from: (AmbientAuth | NetAuth | TCPAuth)) => 19 | None 20 | 21 | primitive TCPConnectAuth 22 | new create(from: (AmbientAuth | NetAuth | TCPAuth)) => 23 | None 24 | -------------------------------------------------------------------------------- /packages/net/net.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Net package 3 | 4 | The Net package provides support for creating UDP and TCP clients and 5 | servers, reading and writing network data, and establishing UDP and 6 | TCP connections. 7 | """ 8 | 9 | use @pony_os_sockname[Bool](fd: U32, ip: NetAddress tag) 10 | -------------------------------------------------------------------------------- /packages/net/proxy.pony: -------------------------------------------------------------------------------- 1 | 2 | interface Proxy 3 | fun apply(wrap: TCPConnectionNotify iso): TCPConnectionNotify iso^ 4 | 5 | class val NoProxy is Proxy 6 | """ 7 | Default implementation of a proxy that does not alter the supplied `TCPConnectionNotify`. 8 | 9 | ```pony 10 | actor MyClient 11 | new create(host: String, service: String, proxy: Proxy = NoProxy) => 12 | let conn: TCPConnection = TCPConnection.create( 13 | TCPConnectAuth(env.root), 14 | proxy.apply(MyConnectionNotify.create()), 15 | "localhost", 16 | "80") 17 | ``` 18 | """ 19 | fun apply(wrap: TCPConnectionNotify iso): TCPConnectionNotify iso^ => wrap 20 | -------------------------------------------------------------------------------- /packages/pony_check/poperator.pony: -------------------------------------------------------------------------------- 1 | class ref Poperator[T] is Iterator[T^] 2 | """ 3 | Iterate over a [Seq](builtin-Seq.md) descructively by `pop`ing its elements. 4 | 5 | Once `has_next()` returns `false`, the [Seq](builtin-Seq.md) is empty. 6 | 7 | Nominee for the annual pony class-naming awards. 8 | """ 9 | 10 | let _seq: Seq[T] 11 | 12 | new create(seq: Seq[T]) => 13 | _seq = seq 14 | 15 | new empty() => 16 | _seq = Array[T](0) 17 | 18 | fun ref has_next(): Bool => 19 | _seq.size() > 0 20 | 21 | fun ref next(): T^ ? => 22 | _seq.pop()? 23 | 24 | -------------------------------------------------------------------------------- /packages/pony_test/_color.pony: -------------------------------------------------------------------------------- 1 | primitive _Color 2 | """ 3 | Strings to embedded in text to specify colours. These are copies of the 4 | strings defined in packages/term. They are duplicated here to avoid a 5 | dependency. 6 | """ 7 | fun reset(): String => 8 | """ 9 | Resets all colours and text styles to the default. 10 | """ 11 | "\x1B[0m" 12 | 13 | fun red(): String => 14 | """ 15 | Bright red text. 16 | """ 17 | "\x1B[91m" 18 | 19 | fun green(): String => 20 | """ 21 | Bright green text. 22 | """ 23 | "\x1B[92m" 24 | -------------------------------------------------------------------------------- /packages/pony_test/test_list.pony: -------------------------------------------------------------------------------- 1 | trait TestList 2 | """ 3 | Source of unit tests for a PonyTest object. 4 | See package doc string for further information and example use. 5 | """ 6 | 7 | fun tag tests(test: PonyTest) 8 | """ 9 | Add all the tests in this suite to the given test object. 10 | Typically the implementation of this function will be of the form: 11 | ```pony 12 | fun tests(test: PonyTest) => 13 | test(_TestClass1) 14 | test(_TestClass2) 15 | test(_TestClass3) 16 | ``` 17 | """ 18 | -------------------------------------------------------------------------------- /packages/process/auth.pony: -------------------------------------------------------------------------------- 1 | primitive StartProcessAuth 2 | new create(from: AmbientAuth) => 3 | None 4 | -------------------------------------------------------------------------------- /packages/promises/fulfill.pony: -------------------------------------------------------------------------------- 1 | primitive _Pending 2 | primitive _Reject 3 | 4 | interface iso Fulfill[A: Any #share, B: Any #share] 5 | """ 6 | A function from A to B that is called when a promise is fulfilled. 7 | """ 8 | fun ref apply(value: A): B ? 9 | 10 | interface iso Reject[A: Any #share] 11 | """ 12 | A function on A that is called when a promise is rejected. 13 | """ 14 | fun ref apply(): A ? 15 | 16 | class iso FulfillIdentity[A: Any #share] 17 | """ 18 | An identity function for fulfilling promises. 19 | """ 20 | fun ref apply(value: A): A => 21 | consume value 22 | 23 | class iso RejectAlways[A: Any #share] 24 | """ 25 | A reject that always raises an error. 26 | """ 27 | fun ref apply(): A ? => 28 | error 29 | -------------------------------------------------------------------------------- /packages/random/dice.pony: -------------------------------------------------------------------------------- 1 | class Dice 2 | """ 3 | A simple dice roller. 4 | """ 5 | var r: Random 6 | 7 | new create(from: Random) => 8 | """ 9 | Initialise with a random number generator. 10 | """ 11 | r = from 12 | 13 | fun ref apply(count: U64, sides: U64): U64 => 14 | """ 15 | Return the sum of `count` rolls of a die with the given number of `sides`. 16 | The die is numbered from 1 to `sides`. For example, count = 2 and 17 | sides = 6 will return a value between 2 and 12. 18 | """ 19 | var sum = count 20 | var i: U64 = 0 21 | 22 | while i < count do 23 | sum = sum + r.int(sides) 24 | i = i + 1 25 | end 26 | sum 27 | -------------------------------------------------------------------------------- /packages/random/splitmix64.pony: -------------------------------------------------------------------------------- 1 | class SplitMix64 is Random 2 | """ 3 | Very fast Pseudo-Random-Number-Generator 4 | using only 64 bit of state, as detailed at: 5 | 6 | http://xoshiro.di.unimi.it/ and http://gee.cs.oswego.edu/dl/papers/oopsla14.pdf 7 | 8 | Using [XorOshiro128StarStar](random-XorOshiro128StarStar.md) or [XorOshiro128Plus](random-XorOshiro128Plus.md) 9 | should be prefered unless using only 64 bit of state is a requirement. 10 | """ 11 | // state 12 | var _x: U64 13 | 14 | new from_u64(x: U64 = 5489) => 15 | _x = x 16 | 17 | new create(x: U64 = 5489, y: U64 = 0) => 18 | """ 19 | Only x is used, y is discarded. 20 | """ 21 | _x = x 22 | 23 | fun ref next(): U64 => 24 | _x = _x + U64(0x9e3779b97f4a7c15) 25 | var z: U64 = _x 26 | z = (z xor (z >> 30)) * U64(0xbf58476d1ce4e5b9) 27 | z = (z xor (z >> 27)) * U64(0x94d049bb133111eb) 28 | z xor (z >> 31) 29 | 30 | -------------------------------------------------------------------------------- /packages/runtime_info/auth.pony: -------------------------------------------------------------------------------- 1 | primitive SchedulerInfoAuth 2 | new create(auth: AmbientAuth) => None 3 | 4 | primitive ActorStatsAuth 5 | new create(auth: AmbientAuth) => None 6 | 7 | primitive SchedulerStatsAuth 8 | new create(auth: AmbientAuth) => None 9 | -------------------------------------------------------------------------------- /packages/runtime_info/runtime_info.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Runtime Info package 3 | 4 | The runtime information package exposes information about the Pony runtime that 5 | can be queried at runtime. The most common usage at this time is limiting the 6 | number of work based on the number of available schedulers. 7 | 8 | For example, in an application that is doing parallel processing and wants to 9 | limit the number of processing actors to the maximum number that could be run 10 | at one time, you can use `Scheduler.schedulers` to get the scheduler 11 | information. 12 | 13 | ```pony 14 | use "collections" 15 | use "runtime_info" 16 | 17 | actor Processor 18 | 19 | actor Main 20 | new create(env: Env) => 21 | let s = Scheduler.schedulers(SchedulerInfoAuth(env.root)) 22 | for i in Range(0, s) do 23 | Processor 24 | end 25 | ``` 26 | """ 27 | -------------------------------------------------------------------------------- /packages/signals/_test.pony: -------------------------------------------------------------------------------- 1 | use "pony_test" 2 | 3 | actor \nodoc\ Main is TestList 4 | new create(env: Env) => PonyTest(env, this) 5 | new make() => None 6 | 7 | fun tag tests(test: PonyTest) => 8 | test(_TestSignalINT) 9 | 10 | class \nodoc\ _TestSighupNotify is SignalNotify 11 | let _h: TestHelper 12 | 13 | new iso create(h: TestHelper) => 14 | _h = h 15 | 16 | fun ref apply(count: U32): Bool => 17 | _h.complete(true) 18 | false 19 | 20 | class \nodoc\ iso _TestSignalINT is UnitTest 21 | var _signal: (SignalHandler | None) = None 22 | 23 | fun name(): String => "signals/INT" 24 | 25 | fun ref apply(h: TestHelper) => 26 | let signal = SignalHandler(_TestSighupNotify(h), Sig.int()) 27 | signal.raise() 28 | _signal = signal 29 | h.long_test(2_000_000_000) // 2 second timeout 30 | 31 | fun timed_out(h: TestHelper) => 32 | try 33 | (_signal as SignalHandler).dispose() 34 | end 35 | 36 | h.fail("timeout") 37 | h.complete(false) 38 | -------------------------------------------------------------------------------- /packages/strings/common_prefix.pony: -------------------------------------------------------------------------------- 1 | primitive CommonPrefix 2 | """ 3 | Creates a string that is the common prefix of the supplied strings, possibly 4 | empty. 5 | """ 6 | 7 | fun apply(data: ReadSeq[Stringable]): String iso^ => 8 | var res = "".clone() 9 | try 10 | let iter = data.values() 11 | if iter.has_next() then 12 | res = iter.next()?.string() 13 | for d in iter do 14 | var idx: USize = 0 15 | let s = d.string() 16 | while (idx < res.size()) and (idx < s.size()) do 17 | if res(idx)? != s(idx)? then 18 | break 19 | end 20 | idx = idx + 1 21 | end 22 | res = res.substring(0, idx.isize()) 23 | end 24 | end 25 | end 26 | res 27 | -------------------------------------------------------------------------------- /packages/strings/strings.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Strings package 3 | 4 | The Strings package provides utilities for working with sequences of strings. 5 | """ 6 | -------------------------------------------------------------------------------- /packages/term/readline_notify.pony: -------------------------------------------------------------------------------- 1 | use "promises" 2 | 3 | interface ReadlineNotify 4 | """ 5 | Notifier for readline. 6 | """ 7 | fun ref apply(line: String, prompt: Promise[String]) => 8 | """ 9 | Receives finished lines. The next prompt is set by fulfilling the promise. 10 | If the promise is rejected, readline will stop handling input. 11 | """ 12 | None 13 | 14 | fun ref tab(line: String): Seq[String] box => 15 | """ 16 | Return tab completion possibilities. 17 | """ 18 | Array[String] 19 | -------------------------------------------------------------------------------- /packages/term/term.pony: -------------------------------------------------------------------------------- 1 | """ 2 | # Term package 3 | 4 | The Term package provides support for building text-based user interfaces in ANSI terminals. 5 | """ 6 | -------------------------------------------------------------------------------- /packages/time/nanos.pony: -------------------------------------------------------------------------------- 1 | 2 | primitive Nanos 3 | """ 4 | Collection of utility functions for converting various durations of time 5 | to nanoseconds, for passing to other functions in the time package. 6 | """ 7 | fun from_seconds(t: U64): U64 => 8 | t * 1_000_000_000 9 | 10 | fun from_millis(t: U64): U64 => 11 | t * 1_000_000 12 | 13 | fun from_micros(t: U64): U64 => 14 | t * 1_000 15 | 16 | fun from_seconds_f(t: F64): U64 => 17 | (t * 1_000_000_000).trunc().u64() 18 | 19 | fun from_millis_f(t: F64): U64 => 20 | (t * 1_000_000).trunc().u64() 21 | 22 | fun from_micros_f(t: F64): U64 => 23 | (t * 1_000).trunc().u64() 24 | 25 | fun from_wall_clock(wall: (I64, I64)): U64 => 26 | ((wall._1 * 1000000000) + wall._2).u64() 27 | -------------------------------------------------------------------------------- /pony.cloc: -------------------------------------------------------------------------------- 1 | Pony 2 | filter remove_matches ^\s*// 3 | filter call_regexp_common C 4 | filter remove_inline //.*$ 5 | extension pony 6 | 3rd_gen_scale 1.0 7 | -------------------------------------------------------------------------------- /src/common/llvm_config_begin.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Include this before including any llvm headers 3 | * And then include llvm_config_end.h after those 4 | * headers. 5 | */ 6 | 7 | #ifndef LLVM_CONFIG_BEGIN_H 8 | #define LLVM_CONFIG_BEGIN_H 9 | 10 | // Valid LLVM_BULD_MODE's must match corresponding names in Makefile-ponyc 11 | #define LLVM_BUILD_MODE_Release 1 12 | #define LLVM_BUILD_MODE_RelWithDebInfo 2 13 | #define LLVM_BUILD_MODE_MinSizeRel 3 14 | #define LLVM_BUILD_MODE_Debug 4 15 | 16 | #ifdef _MSC_VER 17 | # pragma warning(push) 18 | 19 | //because LLVM IR Builder code is broken: e.g. Instructions.h:521-527 20 | # pragma warning(disable:4244) 21 | # pragma warning(disable:4800) 22 | # pragma warning(disable:4267) 23 | # pragma warning(disable:4624) 24 | # pragma warning(disable:4141) 25 | # pragma warning(disable:4291) 26 | # pragma warning(disable:4146) 27 | 28 | // LLVM claims DEBUG as a macro name. Conflicts with MSVC headers. 29 | # pragma warning(disable:4005) 30 | #endif 31 | #endif 32 | -------------------------------------------------------------------------------- /src/common/llvm_config_end.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Used to undo any changes llvm_config_begin.h has done 3 | */ 4 | #ifndef LLVM_CONFIG_END_H 5 | #define LLVM_CONFIG_END_H 6 | 7 | #ifdef _MSC_VER 8 | # pragma warning(pop) 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/common/ponyassert.h: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_PONYASSERT_H 2 | #define PLATFORM_PONYASSERT_H 3 | 4 | #include "platform.h" 5 | 6 | PONY_EXTERN_C_BEGIN 7 | 8 | #if !defined(PONY_NDEBUG) && defined(NDEBUG) 9 | # define PONY_NDEBUG 10 | #endif 11 | 12 | #if defined(PONY_NDEBUG) && !defined(PONY_ALWAYS_ASSERT) 13 | # define pony_assert(expr) ((void)0) 14 | #else 15 | # define pony_assert(expr) \ 16 | ((expr) ? (void)0 : \ 17 | ponyint_assert_fail(#expr, __FILE__, __LINE__, __func__)) 18 | #endif 19 | 20 | void ponyint_assert_fail(const char* expr, const char* file, size_t line, 21 | const char* func); 22 | 23 | void ponyint_assert_disable_popups(); 24 | 25 | PONY_EXTERN_C_END 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/common/vcvars.h: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_VCVARS_H 2 | #define PLATFORM_VCVARS_H 3 | 4 | typedef struct compile_t compile_t; 5 | typedef struct errors_t errors_t; 6 | 7 | typedef struct vcvars_t 8 | { 9 | char link[MAX_PATH]; 10 | char ar[MAX_PATH]; 11 | char kernel32[MAX_PATH]; 12 | char ucrt[MAX_PATH]; 13 | char msvcrt[MAX_PATH]; 14 | char default_libs[MAX_PATH]; 15 | } vcvars_t; 16 | 17 | bool vcvars_get(compile_t *c, vcvars_t* vcvars, errors_t* errors); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/libponyc/ast/bnfprint.h: -------------------------------------------------------------------------------- 1 | #ifndef BNFPRINT_H 2 | #define BNFPRINT_H 3 | 4 | 5 | PONY_EXTERN_C_BEGIN 6 | 7 | 8 | // Print our grammar in human readable BNF / ANTLR file format 9 | void print_grammar(bool antlr, bool clean); 10 | 11 | 12 | PONY_EXTERN_C_END 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libponyc/ast/id_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef ID_INTERNAL_H 2 | #define ID_INTERNAL_H 3 | 4 | // This file exists purely to make the id checker visible to unit tests 5 | 6 | #include 7 | #include "ast.h" 8 | #include "../pass/pass.h" 9 | 10 | PONY_EXTERN_C_BEGIN 11 | 12 | // ID spec flags 13 | #define START_UPPER 0x01 14 | #define START_LOWER 0x02 15 | #define ALLOW_LEADING_UNDERSCORE 0x04 16 | #define ALLOW_UNDERSCORE 0x08 17 | #define ALLOW_TICK 0x10 18 | #define ALLOW_DONTCARE 0x20 19 | 20 | 21 | /* Check that the name in the given ID node meets the given spec. 22 | * If name is illegal an error will be generated. 23 | * The spec is supplied as a set of the above #defined flags. 24 | */ 25 | bool check_id(pass_opt_t* opt, ast_t* id_node, const char* desc, int spec); 26 | 27 | PONY_EXTERN_C_END 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/libponyc/ast/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSER_H 2 | #define PARSER_H 3 | 4 | #include "ast.h" 5 | #include "source.h" 6 | 7 | bool pass_parse(ast_t* package, source_t* source, errors_t* errors, 8 | bool allow_test_symbols, bool trace); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/libponyc/ast/printbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTBUF_H 2 | #define PRINTBUF_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | typedef struct printbuf_t 11 | { 12 | char* m; 13 | size_t size; 14 | size_t offset; 15 | } printbuf_t; 16 | 17 | printbuf_t* printbuf_new(); 18 | 19 | void printbuf_free(printbuf_t* buf); 20 | 21 | void printbuf(printbuf_t* buf, const char* fmt, ...); 22 | 23 | PONY_EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/libponyc/ast/treecheck.h: -------------------------------------------------------------------------------- 1 | #ifndef TREE_CHECK_H 2 | #define TREE_CHECK_H 3 | 4 | #include 5 | 6 | PONY_EXTERN_C_BEGIN 7 | 8 | typedef struct ast_t ast_t; 9 | typedef struct pass_opt_t pass_opt_t; 10 | 11 | // Check that the given AST is well formed. 12 | // Does nothing in release builds of the compiler. 13 | void check_tree(ast_t* tree, pass_opt_t* opt); 14 | 15 | PONY_EXTERN_C_END 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libponyc/codegen/genbox.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENBOX_H 2 | #define CODEGEN_GENBOX_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | /** 10 | * If the value is not a pointer, box it as the specified type. Otherwise return 11 | * the value. 12 | */ 13 | LLVMValueRef gen_box(compile_t* c, ast_t* type, LLVMValueRef value); 14 | 15 | /** 16 | * If the value is a pointer, unbox it as the specified type. Otherwise return 17 | * the value. 18 | */ 19 | LLVMValueRef gen_unbox(compile_t* c, ast_t* type, LLVMValueRef object); 20 | 21 | PONY_EXTERN_C_END 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/libponyc/codegen/genexe.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENEXE_H 2 | #define CODEGEN_GENEXE_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | LLVMValueRef gen_main(compile_t* c, reach_type_t* t_main, reach_type_t* t_env); 10 | 11 | bool genexe(compile_t* c, ast_t* program); 12 | 13 | PONY_EXTERN_C_END 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libponyc/codegen/genexpr.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENEXPR_H 2 | #define CODEGEN_GENEXPR_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | LLVMValueRef gen_expr(compile_t* c, ast_t* ast); 10 | 11 | /** 12 | * Returns r_value cast to l_type. 13 | * 14 | * This will box primitives when necessary. 15 | */ 16 | LLVMValueRef gen_assign_cast(compile_t* c, LLVMTypeRef l_type, 17 | LLVMValueRef r_value, ast_t* type); 18 | 19 | PONY_EXTERN_C_END 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/libponyc/codegen/genheader.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENHEADER_H 2 | #define CODEGEN_GENHEADER_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | bool genheader(compile_t* c); 10 | 11 | PONY_EXTERN_C_END 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/libponyc/codegen/genident.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENIDENT_H 2 | #define CODEGEN_GENIDENT_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | LLVMValueRef gen_is(compile_t* c, ast_t* ast); 10 | 11 | LLVMValueRef gen_isnt(compile_t* c, ast_t* ast); 12 | 13 | void gen_is_tuple_fun(compile_t* c, reach_type_t* t); 14 | 15 | LLVMValueRef gen_numeric_size_table(compile_t* c); 16 | 17 | PONY_EXTERN_C_END 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/libponyc/codegen/genmatch.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENMATCH_H 2 | #define CODEGEN_GENMATCH_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | LLVMValueRef gen_match(compile_t* c, ast_t* ast); 10 | 11 | PONY_EXTERN_C_END 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/libponyc/codegen/genobj.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENOBJ_H 2 | #define CODEGEN_GENOBJ_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | const char* genobj(compile_t* c); 10 | 11 | PONY_EXTERN_C_END 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/libponyc/codegen/genserialise.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENSERIALISE_H 2 | #define CODEGEN_GENSERIALISE_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | typedef struct compile_type_t compile_type_t; 10 | 11 | void genserialise_element(compile_t* c, reach_type_t* t, bool embed, 12 | LLVMValueRef ctx, LLVMValueRef ptr, LLVMValueRef offset); 13 | 14 | void genserialise_serialiseid(compile_t* c, reach_type_t* t, LLVMValueRef offset); 15 | 16 | void gendeserialise_serialiseid(compile_t* c, compile_type_t* t, LLVMValueRef offset); 17 | 18 | void gendeserialise_element(compile_t* c, reach_type_t* t, bool embed, 19 | LLVMValueRef ctx, LLVMValueRef ptr); 20 | 21 | bool genserialise(compile_t* c, reach_type_t* t); 22 | 23 | PONY_EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/libponyc/codegen/gentrace.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEGEN_GENTRACE_H 2 | #define CODEGEN_GENTRACE_H 3 | 4 | #include 5 | #include "codegen.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | bool gentrace_needed(compile_t* c, ast_t* src_type, ast_t* dst_type); 10 | 11 | void gentrace_prototype(compile_t* c, reach_type_t* t); 12 | 13 | void gentrace(compile_t* c, LLVMValueRef ctx, LLVMValueRef src_value, 14 | LLVMValueRef dst_value, ast_t* src_type, ast_t* dst_type); 15 | 16 | PONY_EXTERN_C_END 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/libponyc/expr/array.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPR_ARRAY_H 2 | #define EXPR_ARRAY_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | ast_result_t expr_pre_array(pass_opt_t* opt, ast_t** astp); 11 | 12 | bool expr_array(pass_opt_t* opt, ast_t** astp); 13 | 14 | PONY_EXTERN_C_END 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/libponyc/expr/call.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPR_CALL_H 2 | #define EXPR_CALL_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool method_check_type_params(pass_opt_t* opt, ast_t** astp); 11 | bool check_auto_recover_newref(ast_t* dest_type, ast_t* ast); 12 | 13 | bool expr_call(pass_opt_t* opt, ast_t** astp); 14 | 15 | PONY_EXTERN_C_END 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libponyc/expr/control.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPR_CONTROL_H 2 | #define EXPR_CONTROL_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool expr_seq(pass_opt_t* opt, ast_t* ast); 11 | bool expr_if(pass_opt_t* opt, ast_t* ast); 12 | bool expr_iftype(pass_opt_t* opt, ast_t* ast); 13 | bool expr_while(pass_opt_t* opt, ast_t* ast); 14 | bool expr_repeat(pass_opt_t* opt, ast_t* ast); 15 | bool expr_try(pass_opt_t* opt, ast_t* ast); 16 | bool expr_disposing_block(pass_opt_t* opt, ast_t* ast); 17 | bool expr_recover(pass_opt_t* opt, ast_t* ast); 18 | bool expr_break(pass_opt_t* opt, ast_t* ast); 19 | bool expr_return(pass_opt_t* opt, ast_t* ast); 20 | bool expr_error(pass_opt_t* opt, ast_t* ast); 21 | bool expr_compile_error(pass_opt_t* opt, ast_t* ast); 22 | bool expr_location(pass_opt_t* opt, ast_t* ast); 23 | 24 | PONY_EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/libponyc/expr/ffi.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPR_FFI_H 2 | #define EXPR_FFI_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool expr_ffi(pass_opt_t* opt, ast_t* ast); 11 | bool void_star_param(ast_t* param_type, ast_t* arg_type); 12 | 13 | PONY_EXTERN_C_END 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libponyc/expr/lambda.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPR_LAMBDA_H 2 | #define EXPR_LAMBDA_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool expr_lambda(pass_opt_t* opt, ast_t** astp); 11 | 12 | bool expr_object(pass_opt_t* opt, ast_t** astp); 13 | 14 | PONY_EXTERN_C_END 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/libponyc/expr/match.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPR_MATCH_H 2 | #define EXPR_MATCH_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool expr_match(pass_opt_t* opt, ast_t* ast); 11 | bool expr_cases(pass_opt_t* opt, ast_t* ast); 12 | bool expr_case(pass_opt_t* opt, ast_t* ast); 13 | bool expr_match_capture(pass_opt_t* opt, ast_t* ast); 14 | 15 | PONY_EXTERN_C_END 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libponyc/expr/operator.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPR_OPERATOR_H 2 | #define EXPR_OPERATOR_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool expr_identity(pass_opt_t* opt, ast_t* ast); 11 | bool expr_assign(pass_opt_t* opt, ast_t* ast); 12 | bool expr_as(pass_opt_t* opt, ast_t** astp); 13 | bool expr_consume(pass_opt_t* opt, ast_t* ast); 14 | 15 | PONY_EXTERN_C_END 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libponyc/expr/postfix.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPR_POSTFIX_H 2 | #define EXPR_POSTFIX_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool expr_qualify(pass_opt_t* opt, ast_t** astp); 11 | bool expr_dot(pass_opt_t* opt, ast_t** astp); 12 | bool expr_tilde(pass_opt_t* opt, ast_t** astp); 13 | bool expr_chain(pass_opt_t* opt, ast_t** astp); 14 | 15 | PONY_EXTERN_C_END 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libponyc/options/options.h: -------------------------------------------------------------------------------- 1 | #ifndef PONYC_OPTIONS_H 2 | #define PONYC_OPTIONS_H 3 | 4 | #include "../libponyc/pass/pass.h" 5 | #include "../libponyrt/options/options.h" 6 | 7 | #include 8 | #include 9 | 10 | opt_arg_t* ponyc_opt_std_args(void); 11 | 12 | typedef enum 13 | { 14 | EXIT_0, 15 | EXIT_255, 16 | CONTINUE 17 | } ponyc_opt_process_t; 18 | 19 | ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt, 20 | /*OUT*/ bool* print_program_ast, 21 | /*OUT*/ bool* print_package_ast); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/libponyc/pass/completeness.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_COMPLETENESS_H 2 | #define PASS_COMPLETENESS_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | ast_result_t pass_completeness(ast_t** astp, pass_opt_t* options); 11 | 12 | PONY_EXTERN_C_END 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libponyc/pass/docgen.h: -------------------------------------------------------------------------------- 1 | #ifndef DOCGEN_H 2 | #define DOCGEN_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "pass.h" 7 | #include "../logo.h" 8 | 9 | PONY_EXTERN_C_BEGIN 10 | 11 | #define PONYLANG_MKDOCS_ASSETS_DIR "assets/" 12 | #define PONYLANG_MKDOCS_CSS_FILE "ponylang.css" 13 | #define PONYLANG_MKDOCS_LOGO_FILE "logo.png" 14 | #define PONYLANG_MKDOCS_CSS "[data-md-color-scheme=\"ponylang\"] {\n"\ 15 | " --md-typeset-a-color: var(--md-primary-fg-color);\n"\ 16 | "}" 17 | 18 | 19 | // Generate docs for the given program 20 | void generate_docs(ast_t* program, pass_opt_t* options); 21 | 22 | PONY_EXTERN_C_END 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/libponyc/pass/expr.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_EXPR_H 2 | #define PASS_EXPR_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool is_result_needed(ast_t* ast); 11 | 12 | bool is_method_result(typecheck_t* t, ast_t* ast); 13 | 14 | bool is_method_return(typecheck_t* t, ast_t* ast); 15 | 16 | bool is_typecheck_error(ast_t* type); 17 | 18 | ast_t* find_antecedent_type(pass_opt_t* opt, ast_t* ast, bool* is_recovered); 19 | 20 | ast_result_t pass_pre_expr(ast_t** astp, pass_opt_t* options); 21 | 22 | ast_result_t pass_expr(ast_t** astp, pass_opt_t* options); 23 | 24 | PONY_EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/libponyc/pass/finalisers.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_FINALISERS_H 2 | #define PASS_FINALISERS_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool pass_finalisers(ast_t* program, pass_opt_t* options); 11 | 12 | PONY_EXTERN_C_END 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libponyc/pass/flatten.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_FLATTEN_H 2 | #define PASS_FLATTEN_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | ast_result_t flatten_typeparamref(pass_opt_t* opt, ast_t* ast); 11 | 12 | ast_result_t pass_flatten(ast_t** astp, pass_opt_t* options); 13 | 14 | PONY_EXTERN_C_END 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/libponyc/pass/import.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_IMPORT_H 2 | #define PASS_IMPORT_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | /** 11 | * Imports packages, either with qualifying names or by merging them into the 12 | * current scope. 13 | */ 14 | ast_result_t pass_import(ast_t** astp, pass_opt_t* options); 15 | 16 | PONY_EXTERN_C_END 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/libponyc/pass/names.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_NAMES_H 2 | #define PASS_NAMES_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | ast_t* names_def(pass_opt_t* opt, ast_t* ast); 11 | 12 | bool names_nominal(pass_opt_t* opt, ast_t* scope, ast_t** astp, bool expr); 13 | 14 | ast_result_t pass_names(ast_t** astp, pass_opt_t* options); 15 | 16 | PONY_EXTERN_C_END 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/libponyc/pass/refer.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_REFER_H 2 | #define PASS_REFER_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool def_before_use(pass_opt_t* opt, ast_t* def, ast_t* use, const char* name); 11 | bool refer_reference(pass_opt_t* opt, ast_t** astp); 12 | bool refer_dot(pass_opt_t* opt, ast_t* ast); 13 | bool refer_qualify(pass_opt_t* opt, ast_t* ast); 14 | ast_result_t pass_pre_refer(ast_t** astp, pass_opt_t* options); 15 | ast_result_t pass_refer(ast_t** astp, pass_opt_t* options); 16 | 17 | PONY_EXTERN_C_END 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/libponyc/pass/scope.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_SCOPE_H 2 | #define PASS_SCOPE_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | /** 11 | * Inserts entries in scopes. When this is complete, all scopes are fully 12 | * populated, including package imports, type names, type parameters in types, 13 | * field names, method names, type parameters in methods, parameters in methods, 14 | * and local variables. 15 | */ 16 | ast_result_t pass_scope(ast_t** astp, pass_opt_t* options); 17 | 18 | /** 19 | * Import a package, either with a qualifying name or by merging it into the 20 | * current scope. 21 | */ 22 | bool use_package(ast_t* ast, const char* path, ast_t* name, 23 | pass_opt_t* options); 24 | 25 | PONY_EXTERN_C_END 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libponyc/pass/serialisers.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_SERIALISERS_H 2 | #define PASS_SERIALISERS_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool pass_serialisers(ast_t* program, pass_opt_t* options); 11 | 12 | PONY_EXTERN_C_END 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libponyc/pass/sugar.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_SUGAR_H 2 | #define PASS_SUGAR_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | // Report whether the given member list contains a member with the given name. 11 | bool has_member(ast_t* members, const char* name); 12 | 13 | // Apply default receiver capability and return value, if needed, for the given 14 | // function. 15 | void fun_defaults(ast_t* ast); 16 | 17 | // Create expanded location information about the given node. 18 | // The resulting tree must be caught up with passes and freed by the caller. 19 | ast_t* expand_location(ast_t* location); 20 | 21 | ast_result_t pass_sugar(ast_t** astp, pass_opt_t* options); 22 | 23 | PONY_EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/libponyc/pass/syntax.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_PARSEFIX_H 2 | #define PASS_PARSEFIX_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | ast_result_t pass_syntax(ast_t** astp, pass_opt_t* options); 11 | 12 | PONY_EXTERN_C_END 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libponyc/pass/traits.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_TRAITS_H 2 | #define PASS_TRAITS_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | /** Process traits provided by each actor, class and data class, adding the 11 | * required methods. 12 | */ 13 | ast_result_t pass_traits(ast_t** astp, pass_opt_t* options); 14 | 15 | PONY_EXTERN_C_END 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libponyc/pass/verify.h: -------------------------------------------------------------------------------- 1 | #ifndef PASS_VERIFY_H 2 | #define PASS_VERIFY_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | ast_result_t pass_verify(ast_t** astp, pass_opt_t* options); 11 | 12 | PONY_EXTERN_C_END 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libponyc/pkg/use.h: -------------------------------------------------------------------------------- 1 | #ifndef USE_H 2 | #define USE_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | /// Process a use command 11 | /// @return true on success, false on failure 12 | ast_result_t use_command(ast_t* ast, pass_opt_t* options); 13 | 14 | 15 | typedef bool(*use_handler_t)(ast_t* use, const char* locator, ast_t* name, 16 | pass_opt_t* options); 17 | 18 | // Set the test handler. This is for use only for testing. 19 | void use_test_handler(use_handler_t handler, bool allow_alias, 20 | bool allow_guard); 21 | 22 | PONY_EXTERN_C_END 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/libponyc/ponyc.c: -------------------------------------------------------------------------------- 1 | #include "ponyc.h" 2 | #include "ast/error.h" 3 | #include "codegen/codegen.h" 4 | #include "pkg/package.h" 5 | 6 | bool ponyc_init(pass_opt_t* options) 7 | { 8 | if(!codegen_llvm_init()) 9 | return false; 10 | 11 | if(!codegen_pass_init(options)) 12 | return false; 13 | 14 | if(!package_init(options)) 15 | return false; 16 | 17 | return true; 18 | } 19 | 20 | void ponyc_shutdown(pass_opt_t* options) 21 | { 22 | errors_print(options->check.errors); 23 | package_done(options); 24 | codegen_pass_cleanup(options); 25 | codegen_llvm_shutdown(); 26 | stringtab_done(); 27 | } 28 | -------------------------------------------------------------------------------- /src/libponyc/ponyc.h: -------------------------------------------------------------------------------- 1 | #ifndef PONYC_H 2 | #define PONYC_H 3 | 4 | #include 5 | #include "pass/pass.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | bool ponyc_init(pass_opt_t* options); 10 | void ponyc_shutdown(pass_opt_t* options); 11 | 12 | PONY_EXTERN_C_END 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libponyc/reach/paint.h: -------------------------------------------------------------------------------- 1 | #ifndef PAINT_H 2 | #define PAINT_H 3 | 4 | #include 5 | #include "reach.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | /** Perform colour allocation for vtable index assignment on the given set of 10 | * reachable types. The resulting vtable indices and sizes are written back 11 | * into the given set. 12 | */ 13 | void paint(reach_types_t* types); 14 | 15 | 16 | PONY_EXTERN_C_END 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/libponyc/reach/subtype.h: -------------------------------------------------------------------------------- 1 | #ifndef REACH_SUBTYPE_H 2 | #define REACH_SUBTYPE_H 3 | 4 | #include "reach.h" 5 | 6 | PONY_EXTERN_C_BEGIN 7 | 8 | enum subtype_kind_t 9 | { 10 | SUBTYPE_KIND_NONE, 11 | SUBTYPE_KIND_NUMERIC = 1 << 0, 12 | SUBTYPE_KIND_TUPLE = 1 << 1, 13 | SUBTYPE_KIND_UNBOXED = 1 << 2, 14 | 15 | SUBTYPE_KIND_BOXED = SUBTYPE_KIND_NUMERIC | SUBTYPE_KIND_TUPLE, 16 | SUBTYPE_KIND_ALL = SUBTYPE_KIND_BOXED | SUBTYPE_KIND_UNBOXED 17 | }; 18 | 19 | int subtype_kind(reach_type_t* type); 20 | 21 | int subtype_kind_overlap(reach_type_t* left, reach_type_t* right); 22 | 23 | PONY_EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/libponyc/type/alias.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPE_ALIAS_H 2 | #define TYPE_ALIAS_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../ast/frame.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | // Alias a type in expression handling. 11 | ast_t* alias(ast_t* type); 12 | 13 | ast_t* consume_type(ast_t* type, token_id cap, bool keep_double_ephemeral); 14 | 15 | ast_t* recover_type(ast_t* type, token_id cap); 16 | 17 | ast_t* chain_type(ast_t* type, token_id fun_cap, bool recovered_call); 18 | 19 | bool sendable(ast_t* type); 20 | 21 | bool immutable_or_opaque(ast_t* type); 22 | 23 | PONY_EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/libponyc/type/compattype.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPATTYPE_H 2 | #define COMPATTYPE_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | /** 10 | * Returns true if these types are locally compatible, false otherwise. This 11 | * does not examine subtyping at all: it checks purely for rcap local 12 | * compatibility. 13 | * 14 | * This is used to check for valid intesection types, since intersection types 15 | * represent two separate ways to view an object. Even though those views are 16 | * encapsulated in a single reference, the views must still be locally 17 | * compatible. 18 | */ 19 | bool is_compat_type(ast_t* a, ast_t* b); 20 | 21 | PONY_EXTERN_C_END 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/libponyc/type/lookup.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPE_LOOKUP_H 2 | #define TYPE_LOOKUP_H 3 | 4 | #include 5 | #include "reify.h" 6 | #include "../ast/ast.h" 7 | #include "../pass/pass.h" 8 | 9 | PONY_EXTERN_C_BEGIN 10 | 11 | deferred_reification_t* lookup(pass_opt_t* opt, ast_t* from, ast_t* type, 12 | const char* name); 13 | 14 | deferred_reification_t* lookup_try(pass_opt_t* opt, ast_t* from, ast_t* type, 15 | const char* name, bool allow_private); 16 | 17 | PONY_EXTERN_C_END 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/libponyc/type/safeto.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPE_SAFETO_H 2 | #define TYPE_SAFETO_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "cap.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool safe_to_move(ast_t* ast, ast_t* type, direction direction); 11 | bool safe_to_mutate(ast_t* ast); 12 | 13 | bool safe_to_autorecover(ast_t* receiver, ast_t* type, direction direction); 14 | 15 | PONY_EXTERN_C_END 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libponyc/verify/call.h: -------------------------------------------------------------------------------- 1 | #ifndef VERIFY_CALL_H 2 | #define VERIFY_CALL_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool verify_function_call(pass_opt_t* opt, ast_t* ast); 11 | bool verify_behaviour_call(pass_opt_t* opt, ast_t* ast); 12 | bool verify_ffi_call(pass_opt_t* opt, ast_t* ast); 13 | 14 | PONY_EXTERN_C_END 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/libponyc/verify/control.h: -------------------------------------------------------------------------------- 1 | #ifndef VERIFY_CONTROL_H 2 | #define VERIFY_CONTROL_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool verify_try(pass_opt_t* opt, ast_t* ast); 11 | bool verify_disposing_block(ast_t* ast); 12 | 13 | PONY_EXTERN_C_END 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libponyc/verify/fun.h: -------------------------------------------------------------------------------- 1 | #ifndef VERIFY_FUN_H 2 | #define VERIFY_FUN_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../pass/pass.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | bool verify_fun(pass_opt_t* opt, ast_t* ast); 11 | bool verify_fields_are_defined_in_constructor(pass_opt_t* opt, ast_t* ast); 12 | 13 | PONY_EXTERN_C_END 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libponyc/verify/type.h: -------------------------------------------------------------------------------- 1 | #ifndef VERIFY_TYPE_H 2 | #define VERIFY_TYPE_H 3 | 4 | #include 5 | #include "../ast/ast.h" 6 | #include "../ast/id.h" 7 | #include "../pass/pass.h" 8 | 9 | PONY_EXTERN_C_BEGIN 10 | 11 | bool verify_struct(pass_opt_t* opt, ast_t* ast); 12 | bool verify_interface(pass_opt_t* opt, ast_t* ast); 13 | 14 | PONY_EXTERN_C_END 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/libponyrt/ds/stack.c: -------------------------------------------------------------------------------- 1 | #include "stack.h" 2 | #include "../mem/pool.h" 3 | #include "ponyassert.h" 4 | 5 | static Stack* stack_new(Stack* prev, void* data) 6 | { 7 | Stack* stack = (Stack*)POOL_ALLOC(Stack); 8 | stack->index = 1; 9 | stack->data[0] = data; 10 | stack->prev = prev; 11 | 12 | return stack; 13 | } 14 | 15 | Stack* ponyint_stack_pop(Stack* stack, void** data) 16 | { 17 | pony_assert(stack != NULL); 18 | pony_assert(data != NULL); 19 | 20 | stack->index--; 21 | *data = stack->data[stack->index]; 22 | 23 | if(stack->index == 0) 24 | { 25 | Stack* prev = stack->prev; 26 | POOL_FREE(Stack, stack); 27 | return prev; 28 | } 29 | 30 | return stack; 31 | } 32 | 33 | Stack* ponyint_stack_push(Stack* stack, void* data) 34 | { 35 | if((stack != NULL) && (stack->index < STACK_COUNT)) 36 | { 37 | stack->data[stack->index] = data; 38 | stack->index++; 39 | } else { 40 | stack = stack_new(stack, data); 41 | } 42 | 43 | return stack; 44 | } 45 | -------------------------------------------------------------------------------- /src/libponyrt/gc/cycle.h: -------------------------------------------------------------------------------- 1 | #ifndef gc_cycle_h 2 | #define gc_cycle_h 3 | 4 | #include "gc.h" 5 | #include "../pony.h" 6 | #include 7 | #include 8 | #include 9 | 10 | PONY_EXTERN_C_BEGIN 11 | 12 | void ponyint_cycle_create(pony_ctx_t* ctx, uint32_t detect_interval, bool force_cycle_detector_tracing); 13 | 14 | bool ponyint_cycle_check_blocked(uint64_t tsc, uint64_t tsc2); 15 | 16 | void ponyint_cycle_block(pony_actor_t* actor, gc_t* gc); 17 | 18 | void ponyint_cycle_unblock(pony_actor_t* actor); 19 | 20 | void ponyint_cycle_ack(size_t token); 21 | 22 | void ponyint_cycle_terminate(pony_ctx_t* ctx); 23 | 24 | bool ponyint_is_cycle(pony_actor_t* actor); 25 | 26 | #ifdef USE_RUNTIMESTATS 27 | size_t ponyint_cycle_mem_size(); 28 | 29 | size_t ponyint_cycle_alloc_size(); 30 | #endif 31 | 32 | PONY_EXTERN_C_END 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/libponyrt/gc/delta.h: -------------------------------------------------------------------------------- 1 | #ifndef gc_delta_h 2 | #define gc_delta_h 3 | 4 | #include "../ds/hash.h" 5 | #include "../pony.h" 6 | #include 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | typedef struct delta_t delta_t; 11 | 12 | pony_actor_t* ponyint_delta_actor(delta_t* delta); 13 | 14 | size_t ponyint_delta_rc(delta_t* delta); 15 | 16 | DECLARE_HASHMAP(ponyint_deltamap, deltamap_t, delta_t); 17 | 18 | deltamap_t* ponyint_deltamap_update(deltamap_t* map, pony_actor_t* actor, 19 | size_t rc); 20 | 21 | void ponyint_deltamap_free(deltamap_t* map); 22 | 23 | #ifdef USE_RUNTIMESTATS 24 | size_t ponyint_deltamap_total_mem_size(deltamap_t* map); 25 | 26 | size_t ponyint_deltamap_total_alloc_size(deltamap_t* map); 27 | #endif 28 | 29 | PONY_EXTERN_C_END 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/libponyrt/gc/objectmap.h: -------------------------------------------------------------------------------- 1 | #ifndef gc_objectmap_h 2 | #define gc_objectmap_h 3 | 4 | #include "../ds/hash.h" 5 | #include 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | typedef struct object_t 10 | { 11 | void* address; 12 | size_t rc; 13 | uint32_t mark; 14 | bool immutable; 15 | pony_type_t* type; 16 | } object_t; 17 | 18 | DECLARE_HASHMAP(ponyint_objectmap, objectmap_t, object_t); 19 | 20 | object_t* ponyint_objectmap_getobject(objectmap_t* map, void* address, size_t* index); 21 | 22 | object_t* ponyint_objectmap_getorput(objectmap_t* map, void* address, 23 | pony_type_t* type, uint32_t mark); 24 | 25 | void ponyint_objectmap_sweep(objectmap_t* map); 26 | 27 | #ifdef USE_RUNTIMESTATS 28 | size_t ponyint_objectmap_total_mem_size(objectmap_t* map); 29 | 30 | size_t ponyint_objectmap_total_alloc_size(objectmap_t* map); 31 | #endif 32 | 33 | PONY_EXTERN_C_END 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/libponyrt/gc/trace.h: -------------------------------------------------------------------------------- 1 | #ifndef gc_trace_h 2 | #define gc_trace_h 3 | 4 | #include "../pony.h" 5 | #include 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | void ponyint_gc_mark(pony_ctx_t* ctx); 10 | 11 | void ponyint_mark_done(pony_ctx_t* ctx); 12 | 13 | PONY_EXTERN_C_END 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libponyrt/lang/errno.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "errno.h" 3 | 4 | PONY_EXTERN_C_BEGIN 5 | 6 | PONY_API void pony_os_clear_errno() 7 | { 8 | errno = 0; 9 | } 10 | 11 | PONY_API int pony_os_errno() 12 | { 13 | return errno; 14 | } 15 | 16 | PONY_EXTERN_C_END 17 | -------------------------------------------------------------------------------- /src/libponyrt/lang/errno.h: -------------------------------------------------------------------------------- 1 | #ifndef lang_errno_h 2 | #define lang_errno_h 3 | 4 | #include 5 | #include 6 | 7 | PONY_EXTERN_C_BEGIN 8 | 9 | PONY_API void pony_os_clear_errno(); 10 | PONY_API int pony_os_errno(); 11 | 12 | PONY_EXTERN_C_END 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libponyrt/lang/except_try_catch.ll: -------------------------------------------------------------------------------- 1 | ; This file implements the `pony_try` function in LLVM IR as it cannot be 2 | ; implemented in C. 3 | ; Since the LLVM project doesn't particularly care about IR backwards 4 | ; compatibility, please try to keep this file as minimal as possible in order 5 | ; to minimise the chances of breakage with newer LLVM versions. 6 | 7 | declare i32 @ponyint_personality_v0(...) 8 | 9 | define i1 @pony_try(void (i8*)* %fun, i8* %ctx) personality i32 (...)* @ponyint_personality_v0 { 10 | entry: 11 | invoke void %fun(i8* %ctx) 12 | to label %post unwind label %unwind 13 | 14 | unwind: 15 | %lp = landingpad { i8*, i32 } 16 | catch i8* null 17 | br label %post 18 | 19 | post: 20 | %ret = phi i1 [ true, %entry ], [ false, %unwind ] 21 | ret i1 %ret 22 | } 23 | -------------------------------------------------------------------------------- /src/libponyrt/lang/lsda.h: -------------------------------------------------------------------------------- 1 | #ifndef lang_lsda_h 2 | #define lang_lsda_h 3 | 4 | #include 5 | 6 | #if defined(PLATFORM_IS_CLANG_OR_GCC) 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | PONY_EXTERN_C_BEGIN 14 | 15 | #ifdef PLATFORM_IS_POSIX_BASED 16 | typedef struct _Unwind_Context exception_context_t; 17 | #elif defined(PLATFORM_IS_VISUAL_STUDIO) 18 | typedef DISPATCHER_CONTEXT exception_context_t; 19 | #endif 20 | 21 | bool ponyint_lsda_scan(exception_context_t* context, uintptr_t* lp); 22 | 23 | PONY_EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/libponyrt/lang/paths.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | PONY_EXTERN_C_BEGIN 6 | 7 | PONY_API char* pony_os_realpath(const char* path) 8 | { 9 | #ifdef PLATFORM_IS_WINDOWS 10 | char resolved[FILENAME_MAX]; 11 | 12 | if(GetFullPathName(path, FILENAME_MAX, resolved, NULL) == 0 || 13 | GetFileAttributes(resolved) == INVALID_FILE_ATTRIBUTES) 14 | return NULL; 15 | #elif defined(PLATFORM_IS_POSIX_BASED) 16 | char resolved[PATH_MAX]; 17 | 18 | if(realpath(path, resolved) == NULL) 19 | return NULL; 20 | #endif 21 | 22 | size_t len = strlen(resolved) + 1; 23 | 24 | #ifdef PLATFORM_IS_WINDOWS 25 | for(; resolved[len - 1] == '\\'; --len) 26 | resolved[len - 1] = '\0'; 27 | #endif 28 | 29 | char* cstring = (char*)pony_alloc(pony_ctx(), len); 30 | memcpy(cstring, resolved, len); 31 | return cstring; 32 | } 33 | 34 | PONY_EXTERN_C_END 35 | -------------------------------------------------------------------------------- /src/libponyrt/lang/process.h: -------------------------------------------------------------------------------- 1 | #ifndef lang_process_h 2 | #define lang_process_h 3 | 4 | #include 5 | 6 | PONY_EXTERN_C_BEGIN 7 | 8 | #ifdef PLATFORM_IS_WINDOWS 9 | 10 | PONY_API uint32_t ponyint_win_pipe_create(uint32_t* near_fd, uint32_t* far_fd, 11 | bool outgoing); 12 | 13 | PONY_API size_t ponyint_win_process_create(char* appname, char* cmdline, 14 | char* environ, char* wdir, uint32_t stdin_fd, uint32_t stdout_fd, 15 | uint32_t stderr_fd, uint32_t* error_code, char** error_msg); 16 | 17 | PONY_API int32_t ponyint_win_process_wait(size_t hProcess, int32_t* exit_code_ptr); 18 | 19 | PONY_API int32_t ponyint_win_process_kill(size_t hProcess); 20 | 21 | #elif defined(PLATFORM_IS_POSIX_BASED) 22 | 23 | PONY_API int32_t ponyint_wnohang(); 24 | 25 | #endif 26 | 27 | PONY_EXTERN_C_END 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/libponyrt/lang/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef lang_socket_h 2 | #define lang_socket_h 3 | 4 | PONY_EXTERN_C_BEGIN 5 | 6 | bool ponyint_os_sockets_init(); 7 | 8 | void ponyint_os_sockets_final(); 9 | 10 | PONY_EXTERN_C_END 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/libponyrt/mem/alloc.h: -------------------------------------------------------------------------------- 1 | #ifndef mem_alloc_h 2 | #define mem_alloc_h 3 | 4 | /** 5 | * Allocates memory in the virtual address space. 6 | */ 7 | void* ponyint_virt_alloc(size_t bytes); 8 | 9 | /** 10 | * Deallocates a chunk of memory that was previously allocated with 11 | * ponyint_virt_alloc. 12 | */ 13 | void ponyint_virt_free(void* p, size_t bytes); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libponyrt/mem/pagemap.h: -------------------------------------------------------------------------------- 1 | #ifndef mem_pagemap_h 2 | #define mem_pagemap_h 3 | 4 | #include 5 | 6 | PONY_EXTERN_C_BEGIN 7 | 8 | typedef struct chunk_t chunk_t; 9 | typedef struct pony_actor_t pony_actor_t; 10 | 11 | chunk_t* ponyint_pagemap_get_chunk(const void* addr); 12 | 13 | chunk_t* ponyint_pagemap_get(const void* addr, pony_actor_t** actor); 14 | 15 | void ponyint_pagemap_set(const void* addr, chunk_t* chunk, pony_actor_t* actor); 16 | 17 | void ponyint_pagemap_set_bulk(const void* addr, chunk_t* chunk, pony_actor_t* actor, size_t size); 18 | 19 | #ifdef USE_RUNTIMESTATS 20 | /** Get the memory used by the pagemap. 21 | */ 22 | size_t ponyint_pagemap_mem_size(); 23 | 24 | /** Get the memory allocated by the pagemap. 25 | */ 26 | size_t ponyint_pagemap_alloc_size(); 27 | #endif 28 | 29 | PONY_EXTERN_C_END 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/libponyrt/sched/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef sched_cpu_h 2 | #define sched_cpu_h 3 | 4 | #include "scheduler.h" 5 | #include 6 | #include 7 | #include 8 | 9 | PONY_EXTERN_C_BEGIN 10 | 11 | void ponyint_cpu_init(); 12 | 13 | uint32_t ponyint_cpu_count(); 14 | 15 | uint32_t ponyint_cpu_assign(uint32_t count, scheduler_t* scheduler, 16 | bool nopin, bool pinasio, bool pinpat, bool pin_tracing_thread, 17 | uint32_t* tracing_cpu); 18 | 19 | void ponyint_cpu_affinity(uint32_t cpu); 20 | 21 | void ponyint_cpu_core_pause(uint64_t tsc, uint64_t tsc2, bool yield); 22 | 23 | void ponyint_cpu_relax(); 24 | 25 | uint64_t ponyint_cpu_tick(); 26 | 27 | uint64_t ponyint_cpu_tick_diff(uint64_t supposedly_earlier, 28 | uint64_t supposedly_later); 29 | 30 | PONY_EXTERN_C_END 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/libponyrt/sched/mpmcq.h: -------------------------------------------------------------------------------- 1 | #ifndef sched_mpmcq_h 2 | #define sched_mpmcq_h 3 | 4 | #include 5 | #ifndef __cplusplus 6 | # include 7 | #endif 8 | #include 9 | #include 10 | 11 | PONY_EXTERN_C_BEGIN 12 | 13 | typedef struct mpmcq_node_t mpmcq_node_t; 14 | 15 | PONY_ABA_PROTECTED_PTR_DECLARE(mpmcq_node_t) 16 | 17 | typedef struct mpmcq_t 18 | { 19 | alignas(64) PONY_ATOMIC(mpmcq_node_t*) head; 20 | PONY_ATOMIC_ABA_PROTECTED_PTR(mpmcq_node_t) tail; 21 | } mpmcq_t; 22 | 23 | void ponyint_mpmcq_init(mpmcq_t* q); 24 | 25 | void ponyint_mpmcq_destroy(mpmcq_t* q); 26 | 27 | void ponyint_mpmcq_push(mpmcq_t* q, void* data); 28 | 29 | void ponyint_mpmcq_push_single(mpmcq_t* q, void* data); 30 | 31 | void* ponyint_mpmcq_pop(mpmcq_t* q); 32 | 33 | PONY_EXTERN_C_END 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/libponyrt/sched/mutemap.h: -------------------------------------------------------------------------------- 1 | #ifndef sched_mutemap_h 2 | #define sched_mutemap_h 3 | 4 | #include "../pony.h" 5 | #include 6 | #include "../ds/hash.h" 7 | 8 | PONY_EXTERN_C_BEGIN 9 | 10 | DECLARE_HASHMAP(ponyint_muteset, muteset_t, pony_actor_t); 11 | 12 | typedef struct muteref_t 13 | { 14 | pony_actor_t* key; 15 | muteset_t value; 16 | } muteref_t; 17 | 18 | DECLARE_HASHMAP(ponyint_mutemap, mutemap_t, muteref_t); 19 | 20 | muteref_t* ponyint_muteref_alloc(pony_actor_t* key); 21 | 22 | void ponyint_muteref_free(muteref_t* mref); 23 | 24 | #ifdef USE_RUNTIMESTATS 25 | size_t ponyint_mutemap_total_mem_size(mutemap_t* map); 26 | 27 | size_t ponyint_mutemap_total_alloc_size(mutemap_t* map); 28 | #endif 29 | 30 | PONY_EXTERN_C_END 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /test/full-program-runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libponyc.tests.runner) 2 | 3 | set(RUNNER_EXECUTABLE "full-program-runner${CMAKE_EXECUTABLE_SUFFIX}") 4 | 5 | add_custom_target(tests.runner ALL DEPENDS ${RUNNER_EXECUTABLE}) 6 | 7 | add_custom_command(OUTPUT ${RUNNER_EXECUTABLE} 8 | COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR} 9 | DEPENDS 10 | main.pony 11 | _build_process_notify.pony 12 | _cli_options.pony 13 | _colors.pony 14 | _coordinator.pony 15 | _find_executable.pony 16 | _test_definitions.pony 17 | _test_process_notify.pony 18 | _tester_timer_notify.pony 19 | _tester.pony 20 | $ 21 | ) 22 | -------------------------------------------------------------------------------- /test/full-program-runner/_colors.pony: -------------------------------------------------------------------------------- 1 | primitive _Colors 2 | fun green(): String => "\x1b[0;32m" 3 | fun red(): String => "\x1b[0;31m" 4 | fun yellow(): String => "\x1b[0;33m" 5 | fun none(): String => "\x1b[0m" 6 | 7 | fun info(msg: String, double: Bool = false): String => 8 | green() 9 | + (if double then "[==========] " else "[----------] " end) 10 | + none() + msg 11 | 12 | fun warn(msg: String): String => 13 | yellow() + "[----------] " + none() + msg 14 | 15 | fun err(msg: String): String => 16 | red() + "[----------] " + none() + msg 17 | 18 | fun run(msg: String): String => 19 | green() + "[ RUN ] " + none() + msg 20 | 21 | fun ok(msg: String): String => 22 | green() + "[ OK ] " + none() + msg 23 | 24 | fun pass(msg: String): String => 25 | green() + "[ PASSED ] " + none() + msg 26 | 27 | fun fail(msg: String): String => 28 | red() + "[ FAILED ] " + none() + msg 29 | -------------------------------------------------------------------------------- /test/full-program-runner/_tester_timer_notify.pony: -------------------------------------------------------------------------------- 1 | use "time" 2 | 3 | class iso _TesterTimerNotify is TimerNotify 4 | let _tester: _Tester 5 | 6 | new iso create(tester: _Tester) => 7 | _tester = tester 8 | 9 | fun ref apply(timer: Timer, count: U64 val): Bool => 10 | _tester.timeout() 11 | false 12 | -------------------------------------------------------------------------------- /test/full-program-runner/main.pony: -------------------------------------------------------------------------------- 1 | use "files" 2 | use "time" 3 | 4 | actor Main 5 | var _num_completed: USize = 0 6 | 7 | new create(env: Env) => 8 | let options = 9 | try 10 | _CliOptions(env)? 11 | else 12 | env.exitcode(1) 13 | return 14 | end 15 | 16 | var exit_code = I32(0) 17 | if FilePath(FileAuth(env.root), options.output).exists() then 18 | let td = _TestDefinitions(options.verbose, options.exclude, env.out, 19 | env.err) 20 | match td.find(FileAuth(env.root), options.test_path) 21 | | let test_definitions: Array[_TestDefinition] val => 22 | _Coordinator(env, options, test_definitions) 23 | else 24 | env.err.print(_Colors.err("Unable to get test definitions.")) 25 | exit_code = 1 26 | end 27 | else 28 | env.err.print( 29 | _Colors.err(options.output + ": Output directory does not exist.")) 30 | exit_code = 1 31 | end 32 | env.exitcode(exit_code) 33 | -------------------------------------------------------------------------------- /test/full-program-tests/actor-final/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/actor-final/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | None 6 | 7 | fun _final() => 8 | @pony_exitcode(1) 9 | -------------------------------------------------------------------------------- /test/full-program-tests/annotation-compound-expr/main.pony: -------------------------------------------------------------------------------- 1 | class C 2 | fun apply() => 3 | let foo = true 4 | let bar = true 5 | let x = true 6 | 7 | if \a, b\ foo then 8 | None 9 | elseif \a, b\ bar then 10 | None 11 | else \a, b\ 12 | None 13 | end 14 | 15 | ifdef \a, b\ "foo" then 16 | None 17 | elseif \a, b\ "bar" then 18 | None 19 | else \a, b\ 20 | None 21 | end 22 | 23 | while \a, b\ foo do 24 | None 25 | else \a, b\ 26 | None 27 | end 28 | 29 | repeat \a, b\ 30 | None 31 | until \a, b\ foo else \a, b\ 32 | None 33 | end 34 | 35 | match \a, b\ x 36 | | \a, b\ foo => None 37 | else \a, b\ 38 | None 39 | end 40 | 41 | try \a, b\ 42 | error 43 | else \a, b\ 44 | None 45 | then \a, b\ 46 | None 47 | end 48 | 49 | recover \a, b\ foo end 50 | 51 | actor Main 52 | new create(env: Env) => 53 | None 54 | -------------------------------------------------------------------------------- /test/full-program-tests/annotation-methods/main.pony: -------------------------------------------------------------------------------- 1 | actor A 2 | new \a, b\ create() => None 3 | be \a, b\ b() => None 4 | fun \a, b\ f() => None 5 | 6 | actor Main 7 | new create(env: Env) => 8 | None 9 | -------------------------------------------------------------------------------- /test/full-program-tests/annotation-standard-location-good/main.pony: -------------------------------------------------------------------------------- 1 | struct \packed\ Foo 2 | fun foo() => 3 | let bar = true 4 | 5 | if \likely\ bar then None end 6 | while \unlikely\ bar do None end 7 | repeat None until \likely\ bar end 8 | match bar | \unlikely\ bar => None end 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/annotation-types/main.pony: -------------------------------------------------------------------------------- 1 | actor \a, b\ A 2 | class \a, b\ C 3 | primitive \a, b\ P 4 | struct \a, b\ S 5 | interface \a, b\ I 6 | trait \a, b\ T 7 | 8 | actor Main 9 | new create(env: Env) => 10 | None 11 | -------------------------------------------------------------------------------- /test/full-program-tests/array-as-iso-consumed-elements/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[T] => 8 | let c1: C1 iso = C1 9 | let c2: C2 iso = C2 10 | let c3: C3 iso = C3 11 | [as T: consume c1; consume c2; consume c3] 12 | 13 | actor Main 14 | new create(env: Env) => 15 | None 16 | -------------------------------------------------------------------------------- /test/full-program-tests/array-as-iso/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[T] => 8 | [as T: C1; C2; C3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/array-as-val/main.pony: -------------------------------------------------------------------------------- 1 | trait val T 2 | primitive P1 is T 3 | primitive P2 is T 4 | primitive P3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[T] => 8 | [as T: P1; P2; P3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-apply-interface-box-element-in-tuple/main.pony: -------------------------------------------------------------------------------- 1 | // from issue #2233 2 | trait box T 3 | class box C1 is T 4 | new box create() => None 5 | class box C2 is T 6 | new box create() => None 7 | class box C3 is T 8 | new box create() => None 9 | 10 | interface ArrayishOfTAndU64 11 | fun apply(index: USize): this->(T, U64) ? 12 | 13 | primitive Foo 14 | fun apply(): ArrayishOfTAndU64 => 15 | [(C1, 1); (C2, 2); (C3, 3)] 16 | 17 | actor Main 18 | new create(env: Env) => 19 | None 20 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-apply-interface-val-element-no-arrow-this/main.pony: -------------------------------------------------------------------------------- 1 | trait val T 2 | primitive P1 is T 3 | primitive P2 is T 4 | primitive P3 is T 5 | 6 | interface ArrayishOfT 7 | fun apply(index: USize): T ? 8 | 9 | primitive Foo 10 | fun apply(): ArrayishOfT => 11 | [P1; P2; P3] 12 | 13 | actor Main 14 | new create(env: Env) => 15 | None 16 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-apply-interface/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | interface ArrayishOfT 7 | fun apply(index: USize): this->T ? 8 | 9 | primitive Foo 10 | fun apply(): ArrayishOfT => 11 | [C1; C2; C3] 12 | 13 | actor Main 14 | new create(env: Env) => 15 | None 16 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-array-iso/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[T] iso^ => 8 | [C1; C2; C3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-array-type/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[T] => 8 | [C1; C2; C3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-array-uso-with-as/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[T] iso^ => 8 | [as T: C1; C2; C3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-array-val/main.pony: -------------------------------------------------------------------------------- 1 | trait val T 2 | primitive P1 is T 3 | primitive P2 is T 4 | primitive P3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[T] val => 8 | [P1; P2; P3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-interface-with-type-param/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | interface Arrayish[A] 7 | fun apply(index: USize): this->A ? 8 | 9 | primitive Foo 10 | fun apply(): Arrayish[T] => 11 | [C1; C2; C3] 12 | 13 | actor Main 14 | new create(env: Env) => 15 | None 16 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-read-seq-and-read-element-interface/main.pony: -------------------------------------------------------------------------------- 1 | primitive Foo 2 | fun apply(): (ReadSeq[U8] & ReadElement[U8]) => 3 | [1; 2; 3] 4 | 5 | actor Main 6 | new create(env: Env) => 7 | None 8 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-seq/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | primitive Foo 7 | fun apply(): Seq[T] => 8 | [C1; C2; C3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-values-call-with-iterator-antecedent/main.pony: -------------------------------------------------------------------------------- 1 | primitive Foo 2 | fun apply(): (Iterator[U8] | None) => 3 | [1; 2; 3].values() 4 | 5 | actor Main 6 | new create(env: Env) => 7 | None 8 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-from-values-of-array-interface/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | interface ArrayishOfArrayOfT 7 | fun values(): Iterator[this->Array[T]]^ 8 | 9 | primitive Foo 10 | fun apply(): ArrayishOfArrayOfT => 11 | [[C1]; [C2]; [C3]] 12 | 13 | actor Main 14 | new create(env: Env) => 15 | None 16 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-most-specific-from-union-of-array-types/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/full-program-tests/array-infer-most-specific-from-union-of-array-types/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | trait iso T1 4 | trait iso T2 5 | trait iso T3 is T1 6 | trait iso T4 is T2 7 | class iso C1 is T3 8 | class iso C2 is T4 9 | 10 | primitive Foo 11 | fun apply(): (Array[T1] | Array[T2] | Array[T3] | Array[T4]) => 12 | [C1] 13 | 14 | actor Main 15 | new create(env: Env) => 16 | match Foo() 17 | | let a: Array[T1] => @pony_exitcode(1) 18 | | let a: Array[T2] => @pony_exitcode(2) 19 | | let a: Array[T3] => @pony_exitcode(3) 20 | | let a: Array[T4] => @pony_exitcode(4) 21 | end 22 | -------------------------------------------------------------------------------- /test/full-program-tests/array-no-as-iso-consumed-elements/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[(C1 | C2 | C3)] => 8 | let c1: C1 iso = C1 9 | let c2: C2 iso = C2 10 | let c3: C3 iso = C3 11 | [consume c1; consume c2; consume c3] 12 | 13 | actor Main 14 | new create(env: Env) => 15 | None 16 | -------------------------------------------------------------------------------- /test/full-program-tests/array-no-as-iso/main.pony: -------------------------------------------------------------------------------- 1 | trait iso T 2 | class iso C1 is T 3 | class iso C2 is T 4 | class iso C3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[(C1 | C2 | C3)] => 8 | [C1; C2; C3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/array-no-as-val/main.pony: -------------------------------------------------------------------------------- 1 | trait val T 2 | primitive P1 is T 3 | primitive P2 is T 4 | primitive P3 is T 5 | 6 | primitive Foo 7 | fun apply(): Array[(P1 | P2 | P3)] => 8 | [P1; P2; P3] 9 | 10 | actor Main 11 | new create(env: Env) => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-bare-lambda-callback/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-bare-lambda-callback/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:bare-function-additional" 2 | 3 | use @baretest_callback[None](cb: Pointer[None], size: USize) 4 | use @pony_exitcode[None](code: I32) 5 | 6 | actor Main 7 | new create(env: Env) => 8 | let lbd = @{(x: USize) => 9 | if x == 42 then 10 | @pony_exitcode(1) 11 | end 12 | } 13 | @baretest_callback(lbd, 42) 14 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-call/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-call/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | foo(42) 6 | 7 | fun @foo(x: USize) => 8 | if x == 42 then 9 | @pony_exitcode(1) 10 | end 11 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-callback-addressof/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-callback-addressof/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:bare-function-additional" 2 | 3 | use @baretest_callback[None](cb: Pointer[None], size: USize) 4 | use @pony_exitcode[None](code: I32) 5 | 6 | actor Main 7 | new create(env: Env) => 8 | @baretest_callback(addressof foo, 42) 9 | 10 | fun @foo(x: USize) => 11 | if x == 42 then 12 | @pony_exitcode(1) 13 | end 14 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-callback-partial-application/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-callback-partial-application/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:bare-function-additional" 2 | 3 | use @baretest_callback[None](cb: Pointer[None], size: USize) 4 | use @pony_exitcode[None](code: I32) 5 | 6 | actor Main 7 | new create(env: Env) => 8 | @baretest_callback(this~foo(), 42) 9 | 10 | fun @foo(x: USize) => 11 | if x == 42 then 12 | @pony_exitcode(1) 13 | end 14 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-receiver-side-effect/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-receiver-side-effect/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | foo().bar() 6 | 7 | fun foo(): Main => 8 | @pony_exitcode(1) 9 | this 10 | 11 | fun @bar() => 12 | None 13 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-typeref-call-no-constructor-call/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-typeref-call-no-constructor-call/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class C 4 | new create() => 5 | // This should't be executed 6 | @pony_exitcode(1) 7 | 8 | fun @foo() => 9 | None 10 | 11 | actor Main 12 | new create(env: Env) => 13 | C.foo() 14 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-use-of-void-pointers/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 2 -------------------------------------------------------------------------------- /test/full-program-tests/bare-function-use-of-void-pointers/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let cb = this~foo() 6 | let sum = cb(Pointer[U8].create(), 1) + cb(Pointer[U32].create(), 1) 7 | @pony_exitcode(sum) // expected 2 8 | 9 | fun @foo(p: Pointer[None], n: I32): I32 => n 10 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-function/additional.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef _MSC_VER 4 | # define EXPORT_SYMBOL __declspec(dllexport) 5 | #else 6 | # define EXPORT_SYMBOL 7 | #endif 8 | 9 | extern "C" 10 | { 11 | 12 | typedef void (*baretest_callback_fn)(size_t value); 13 | 14 | EXPORT_SYMBOL extern void baretest_callback(baretest_callback_fn cb, size_t value) 15 | { 16 | cb(value); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-lambda-call/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/bare-lambda-call/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let lbd = @{(x: USize) => 6 | if x == 42 then 7 | @pony_exitcode(1) 8 | end 9 | } 10 | lbd(42) 11 | -------------------------------------------------------------------------------- /test/full-program-tests/bare-lambda-use-of-void-pointers/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 2 -------------------------------------------------------------------------------- /test/full-program-tests/bare-lambda-use-of-void-pointers/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let cb = @{(p: Pointer[None], n: I32): I32 => n} 6 | let sum = cb(Pointer[U8].create(), 1) + cb(Pointer[U32].create(), 1) 7 | @pony_exitcode(sum) // should be 2 8 | -------------------------------------------------------------------------------- /test/full-program-tests/c-callback/additional.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | # define EXPORT_SYMBOL __declspec(dllexport) 3 | #else 4 | # define EXPORT_SYMBOL 5 | #endif 6 | 7 | typedef int (*codegentest_ccallback_fn)(void* self, int value); 8 | 9 | EXPORT_SYMBOL int codegentest_ccallback(void* self, codegentest_ccallback_fn cb, 10 | int value) 11 | { 12 | return cb(self, value); 13 | } 14 | -------------------------------------------------------------------------------- /test/full-program-tests/c-callback/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 6 -------------------------------------------------------------------------------- /test/full-program-tests/c-callback/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:c-callback-additional" 2 | 3 | use @codegentest_ccallback[I32](self: Callback, cb: Pointer[None], value: I32) 4 | use @pony_exitcode[None](code: I32) 5 | 6 | class Callback 7 | fun apply(value: I32): I32 => 8 | value * 2 9 | 10 | actor Main 11 | new create(env: Env) => 12 | let cb: Callback = Callback 13 | let r = @codegentest_ccallback(cb, addressof cb.apply, 3) 14 | @pony_exitcode(r) 15 | -------------------------------------------------------------------------------- /test/full-program-tests/class-final/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/class-final/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class ClassFinal 4 | fun _final() => 5 | @pony_exitcode(1) 6 | 7 | actor Main 8 | new create(env: Env) => 9 | ClassFinal 10 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-no-trace/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-number-boxed-sent-through-interface/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-number-boxed-sent-through-interface/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:codegen-trace-additional" 2 | use @gc_local[Pointer[None]](target: Main) 3 | use @gc_local_snapshot[Pointer[None]](target: Main) 4 | use @gc_local_snapshot_destroy[None](obj_map: Pointer[None]) 5 | use @objectmap_has_object_rc[Bool](obj_map: Pointer[None], obj: Any tag, rc: USize) 6 | use @pony_exitcode[None](code: I32) 7 | 8 | interface tag I 9 | be trace(x: U32) 10 | 11 | actor Main 12 | var map_before: Pointer[None] = Pointer[None] 13 | 14 | new create(env: Env) => 15 | let i: I = this 16 | i.trace(42) 17 | map_before = @gc_local_snapshot(this) 18 | 19 | be trace(x: Any val) => 20 | let map_after = @gc_local(this) 21 | let ok = @objectmap_has_object_rc(map_before, x, USize(1)) and 22 | @objectmap_has_object_rc(map_after, x, USize(0)) 23 | @gc_local_snapshot_destroy(map_before) 24 | @pony_exitcode(I32(if ok then 1 else 0 end)) 25 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-number-boxed/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-number-boxed/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:codegen-trace-additional" 2 | use @gc_local[Pointer[None]](target: Main) 3 | use @gc_local_snapshot[Pointer[None]](target: Main) 4 | use @gc_local_snapshot_destroy[None](obj_map: Pointer[None]) 5 | use @objectmap_has_object_rc[Bool](obj_map: Pointer[None], obj: Any tag, rc: USize) 6 | use @pony_exitcode[None](code: I32) 7 | 8 | actor Main 9 | var map_before: Pointer[None] = Pointer[None] 10 | 11 | new create(env: Env) => 12 | trace(U32(42)) 13 | map_before = @gc_local_snapshot(this) 14 | 15 | be trace(x: Any val) => 16 | let map_after = @gc_local(this) 17 | let ok = @objectmap_has_object_rc(map_before, x, USize(1)) and 18 | @objectmap_has_object_rc(map_after, x, USize(0)) 19 | @gc_local_snapshot_destroy(map_before) 20 | @pony_exitcode(I32(if ok then 1 else 0 end)) 21 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-object-different-cap/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-object-dynamic/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-object-same-cap/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-object-static/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-struct-field/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-struct-field/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:codegen-trace-additional" 2 | use @gc_local[Pointer[None]](target: Main) 3 | use @objectmap_has_object[Bool](obj_map: Pointer[None], obj: Bar tag) 4 | use @objectmap_has_object_rc[Bool](obj_map: Pointer[None], obj: Any tag, rc: USize) 5 | use @pony_exitcode[None](code: I32) 6 | 7 | class Foo 8 | 9 | struct Bar 10 | let f: Foo = Foo 11 | 12 | class WrapBar 13 | let s: Bar = Bar 14 | 15 | actor Main 16 | new create(env: Env) => 17 | trace(recover WrapBar end) 18 | 19 | be trace(w: WrapBar iso) => 20 | let x = consume ref w 21 | let map = @gc_local(this) 22 | let ok = @objectmap_has_object(map, x.s) and 23 | @objectmap_has_object_rc(map, x.s.f, 0) 24 | @pony_exitcode(I32(if ok then 1 else 0 end)) 25 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-tuple-boxed-sent-through-interface/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-tuple-boxed/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-tuple-dynamic/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-tuple-with-number-boxed-sent-through-interface/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-tuple-with-number-boxed-sent-through-interface/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:codegen-trace-additional" 2 | use @gc_local[Pointer[None]](target: Main) 3 | use @gc_local_snapshot[Pointer[None]](target: Main) 4 | use @gc_local_snapshot_destroy[None](obj_map: Pointer[None]) 5 | use @objectmap_has_object_rc[Bool](obj_map: Pointer[None], obj: Any tag, rc: USize) 6 | use @pony_exitcode[None](code: I32) 7 | 8 | interface tag I 9 | be trace(x: (U32, U32)) 10 | 11 | actor Main 12 | var map_before: Pointer[None] = Pointer[None] 13 | 14 | new create(env: Env) => 15 | let i: I = this 16 | i.trace((42, 42)) 17 | map_before = @gc_local_snapshot(this) 18 | 19 | be trace(x: (Any val, U32)) => 20 | let map_after = @gc_local(this) 21 | let ok = @objectmap_has_object_rc(map_before, x._1, USize(1)) and 22 | @objectmap_has_object_rc(map_after, x._1, USize(0)) 23 | @gc_local_snapshot_destroy(map_before) 24 | @pony_exitcode(I32(if ok then 1 else 0 end)) 25 | -------------------------------------------------------------------------------- /test/full-program-tests/codegen-trace-tuple/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/ctor-autorecover-this/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | A.create().f() 4 | 5 | class A 6 | fun f() => 7 | let a = create() // issue #4259 compiler crash 8 | -------------------------------------------------------------------------------- /test/full-program-tests/custom-serialisation/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/cycle-detector/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/full-program-tests/embed-final/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/embed-final/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class EmbedFinal 4 | fun _final() => 5 | @pony_exitcode(1) 6 | 7 | actor Main 8 | embed c: EmbedFinal = EmbedFinal 9 | 10 | new create(env: Env) => 11 | None 12 | -------------------------------------------------------------------------------- /test/full-program-tests/ffi-call-in-initializer/additional.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | # define EXPORT_SYMBOL __declspec(dllexport) 3 | #else 4 | # define EXPORT_SYMBOL 5 | #endif 6 | 7 | EXPORT_SYMBOL int ffi_function() 8 | { 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /test/full-program-tests/ffi-call-in-initializer/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:ffi-call-in-initializer-additional" 2 | 3 | use @ffi_function[I32]() 4 | 5 | // From issue #4086 6 | actor Main 7 | let _let_field: I32 = @ffi_function() 8 | var _var_field: I32 = @ffi_function() 9 | 10 | new create(env: Env) => 11 | None 12 | -------------------------------------------------------------------------------- /test/full-program-tests/ffi-different-returns/additional.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | # define EXPORT_SYMBOL __declspec(dllexport) 3 | #else 4 | # define EXPORT_SYMBOL 5 | #endif 6 | 7 | EXPORT_SYMBOL int ffi_function() 8 | { 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /test/full-program-tests/ffi-different-returns/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/ffi-different-returns/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:ffi-different-returns-additional" 2 | 3 | use @ffi_function[I32]() 4 | use @pony_exitcode[None](code: I32) 5 | 6 | actor Main 7 | new create(env: Env) => 8 | let res: (I32 | U32) = @ffi_function[U32]() 9 | match res 10 | | let _: U32 => @pony_exitcode(1) 11 | | let _: I32 => @pony_exitcode(2) 12 | end 13 | -------------------------------------------------------------------------------- /test/full-program-tests/ffi-return-arg-reachable/additional.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | # define EXPORT_SYMBOL __declspec(dllexport) 3 | #else 4 | # define EXPORT_SYMBOL 5 | #endif 6 | 7 | int identity(int a) { 8 | return a; 9 | } 10 | 11 | int add(int a, int b) { 12 | return a + b; 13 | } 14 | 15 | EXPORT_SYMBOL void* get_function(int type) 16 | { 17 | if(type == 0) 18 | return identity; 19 | 20 | return add; 21 | } 22 | -------------------------------------------------------------------------------- /test/full-program-tests/ffi-return-arg-reachable/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /test/full-program-tests/ffi-return-arg-reachable/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:ffi-return-arg-reachable-additional" 2 | 3 | use @get_function[@{(U32): U32}](typ: U32) 4 | use @pony_exitcode[None](code: I32) 5 | 6 | actor Main 7 | new create(env: Env) => 8 | let identity = @get_function(0) 9 | let add: @{(U32, U32): U32} = @get_function[@{(U32, U32): U32}](1) 10 | let result = add(identity(1), identity(2)) 11 | @pony_exitcode(result.i32()) 12 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-abstract-type-no-subtyping/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-abstract-type-no-subtyping/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let a: (Env | None) = None 6 | let b: (Main | None) = None 7 | if a is b then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-boxed-numeric-is-boxed-numeric/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-boxed-numeric-is-boxed-numeric/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let u32_0_a: (Any | (U32, U32)) = U32(0) 6 | let u32_0_b: (Any | (U32, U32)) = U32(0) 7 | let u32_1: (Any | (U32, U32)) = U32(1) 8 | let u64_0: (Any | (U32, U32)) = U64(0) 9 | if (u32_0_a is u32_0_a) and (u32_0_a is u32_0_b) and 10 | (u32_0_a isnt u32_1) and (u32_0_a isnt u64_0) 11 | then 12 | @pony_exitcode(1) 13 | end 14 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-boxed-tuple-is-boxed-tuple/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-boxed-tuple-is-boxed-tuple/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let t1_a: (Any | (U32, U32) | (U64, U64)) = (U32(0), U32(0)) 6 | let t1_b: (Any | (U32, U32) | (U64, U64)) = (U32(0), U32(0)) 7 | let t2: (Any | (U32, U32) | (U64, U64)) = (U32(1), U32(0)) 8 | let t3: (Any | (U32, U32) | (U64, U64)) = (U64(0), U64(0)) 9 | if (t1_a is t1_a) and (t1_a is t1_b) and (t1_a isnt t2) and 10 | (t1_a isnt t3) 11 | then 12 | @pony_exitcode(1) 13 | end 14 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-boxed-numeric/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-boxed-numeric/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let boxed: (Any | (U32, U32)) = U32(5) 6 | let dg = digestof boxed 7 | if dg == 5 then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-boxed-tuple/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-boxed-tuple/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let boxed: (Any | (Main, Env)) = (this, env) 6 | let dg = digestof boxed 7 | if dg == ((digestof this) xor (digestof env)) then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-numeric/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-numeric/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let value = U32(5) 6 | let dg = digestof value 7 | if dg == 5 then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-object/additional.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef _MSC_VER 4 | # define EXPORT_SYMBOL __declspec(dllexport) 5 | #else 6 | # define EXPORT_SYMBOL 7 | #endif 8 | 9 | EXPORT_SYMBOL extern uintptr_t ptr_to_int(void* p) 10 | { 11 | return (uintptr_t)p; 12 | } 13 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-object/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-object/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:identity-digestof-object-additional" 2 | 3 | use @ptr_to_int[USize](env: Env) 4 | use @pony_exitcode[None](code: I32) 5 | 6 | actor Main 7 | new create(env: Env) => 8 | let dg = digestof env 9 | if dg == @ptr_to_int(env) then 10 | @pony_exitcode(1) 11 | end 12 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-tuple/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-digestof-tuple/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let value = (this, env) 6 | let dg = digestof value 7 | if dg == ((digestof this) xor (digestof env)) then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-nested-tuple/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-nested-tuple/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let a: (((U8, U16) | None, U8) | None) = None 6 | let b: (((U8, U16) | None, U8) | None) = None 7 | if a is b then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-numeric-is-boxed-numeric/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-numeric-is-boxed-numeric/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let boxed: (Any | (U32, U32)) = U32(0) 6 | if (U32(0) is boxed) and (U32(1) isnt boxed) and 7 | (U64(0) isnt boxed) 8 | then 9 | @pony_exitcode(1) 10 | end 11 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-numeric-is-numeric/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-numeric-is-numeric/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | if (U32(0) is U32(0)) and (U32(0) isnt U32(1)) and 6 | (U32(0) isnt U64(0)) 7 | then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-object-is-object/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-object-is-object/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class C1 4 | class C2 5 | 6 | actor Main 7 | new create(env: Env) => 8 | let c1: Any = C1 9 | let c2: Any = C2 10 | if (c1 is c1) and (c1 isnt c2) then 11 | @pony_exitcode(1) 12 | end 13 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-tuple-cardinality/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-tuple-cardinality/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | if (env, this, this) isnt (env, this) then 6 | @pony_exitcode(1) 7 | end 8 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-tuple-different-types/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-tuple-different-types/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let a: ((Any, U8) | None) = (U8(0), 0) 6 | let b: ((U8, U8) | None) = (0, 0) 7 | if a is b then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-tuple-is-boxed-tuple/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-tuple-is-boxed-tuple/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let boxed: (Any | (U32, U32) | (U64, U64)) = (U32(0), U32(0)) 6 | if ((U32(0), U32(0)) is boxed) and ((U32(1), U32(0)) isnt boxed) and 7 | ((U64(0), U64(0)) isnt boxed) 8 | then 9 | @pony_exitcode(1) 10 | end 11 | -------------------------------------------------------------------------------- /test/full-program-tests/identity-tuple-is-tuple/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/identity-tuple-is-tuple/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let a: (Any, Any) = (U32(0), env) 6 | let b: (Any, Any) = (U32(1), this) 7 | if (a is a) and (a isnt b) then 8 | @pony_exitcode(1) 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/if-block-ending-with-dont-care-assign/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/full-program-tests/if-block-ending-with-dont-care-assign/main.pony: -------------------------------------------------------------------------------- 1 | """ 2 | From Issue #3669 3 | """ 4 | class B 5 | 6 | actor Main 7 | new create(env: Env) => 8 | if true 9 | then _ = B 10 | end 11 | -------------------------------------------------------------------------------- /test/full-program-tests/if-block-ending-with-embed-assign/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/full-program-tests/if-block-ending-with-embed-assign/main.pony: -------------------------------------------------------------------------------- 1 | """ 2 | From Issue #3669 3 | """ 4 | 5 | class B 6 | class A 7 | embed embedded: B 8 | new create() => 9 | if true 10 | then embedded = B 11 | else embedded = B 12 | end 13 | 14 | actor Main 15 | new create(env: Env) => 16 | A 17 | -------------------------------------------------------------------------------- /test/full-program-tests/iftype-else-if-true/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/iftype-else-if-true/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | trait T 4 | class C1 is T 5 | class C2 is T 6 | 7 | actor Main 8 | new create(env: Env) => 9 | foo[C2](C2) 10 | 11 | fun foo[A: T](x: A) => 12 | iftype A <: C1 then 13 | None 14 | elseif A <: C2 then 15 | @pony_exitcode(1) 16 | end 17 | -------------------------------------------------------------------------------- /test/full-program-tests/iftype-false/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/iftype-false/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | trait T 4 | class C is T 5 | 6 | actor Main 7 | new create(env: Env) => 8 | foo[T](C) 9 | 10 | fun foo[A: T](x: A) => 11 | iftype A <: C then 12 | None 13 | else 14 | @pony_exitcode(1) 15 | end 16 | -------------------------------------------------------------------------------- /test/full-program-tests/iftype-true/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/iftype-true/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | trait T 4 | class C is T 5 | 6 | actor Main 7 | new create(env: Env) => 8 | foo[C](C) 9 | 10 | fun foo[A: T](x: A) => 11 | iftype A <: C then 12 | @pony_exitcode(1) 13 | end 14 | -------------------------------------------------------------------------------- /test/full-program-tests/issue-4475-case-2/main.pony: -------------------------------------------------------------------------------- 1 | """ 2 | Unlike case 1 (test/full-program-tests/issue-4475-case-1/main.pony) of the 3 | #4475 issue test, this code managed to compile before the fix because the Pony 4 | statement error was not generated before a termination instruction (e.g. ret). 5 | """ 6 | class Foo 7 | new create(a: U32) ? => 8 | if a > 10 then 9 | error 10 | end 11 | 12 | actor Main 13 | new create(env: Env) => 14 | try 15 | let f = Foo(1)? 16 | end 17 | -------------------------------------------------------------------------------- /test/full-program-tests/lambda-with-return-in-behaviour/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | None 4 | 5 | be foo() => 6 | let f = {() => if true then return None end} 7 | -------------------------------------------------------------------------------- /test/full-program-tests/lambda-with-return-in-constructor/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | let f = {() => if true then return None end} 4 | -------------------------------------------------------------------------------- /test/full-program-tests/large-dependent-finalisers/additional.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifdef _MSC_VER 5 | # define EXPORT_SYMBOL __declspec(dllexport) 6 | #else 7 | # define EXPORT_SYMBOL 8 | #endif 9 | 10 | extern "C" 11 | { 12 | 13 | static uint32_t num_objects = 3; 14 | 15 | EXPORT_SYMBOL extern void codegentest_large_dependent_finalisers_decrement_num_objects() 16 | { 17 | num_objects--; 18 | pony_exitcode((int)num_objects); 19 | } 20 | 21 | #ifndef _MSC_VER 22 | void Main_runtime_override_defaults_oo(void* opt) 23 | { 24 | (void)opt; 25 | return; 26 | } 27 | #endif 28 | 29 | } 30 | -------------------------------------------------------------------------------- /test/full-program-tests/large-dependent-finalisers/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/match-exhaustive-all-cases-including-dont-care-and-tuple/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/full-program-tests/match-exhaustive-all-cases-including-dont-care-and-tuple/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class C1 fun one(): I32 => 1 4 | class C2 fun two(): I32 => 2 5 | class C3 fun three(): I32 => 3 6 | 7 | primitive Foo 8 | fun apply(c': (C1 | C2 | (C3, Bool))): I32 => 9 | match c' 10 | | let c: C1 => c.one() 11 | | let _: C2 => 2 12 | | (let c: C3, let _: Bool) => c.three() 13 | end 14 | 15 | actor Main 16 | new create(env: Env) => 17 | @pony_exitcode(Foo((C3, true))) 18 | -------------------------------------------------------------------------------- /test/full-program-tests/match-exhaustive-all-cases-of-union/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/full-program-tests/match-exhaustive-all-cases-of-union/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class C1 fun one(): I32 => 1 4 | class C2 fun two(): I32 => 2 5 | class C3 fun three(): I32 => 3 6 | 7 | primitive Foo 8 | fun apply(c': (C1 | C2 | C3)): I32 => 9 | match c' 10 | | let c: C1 => c.one() 11 | | let c: C2 => c.two() 12 | | let c: C3 => c.three() 13 | end 14 | 15 | actor Main 16 | new create(env: Env) => 17 | @pony_exitcode(Foo(C3)) 18 | -------------------------------------------------------------------------------- /test/full-program-tests/match-exhaustive-all-cases-primitive-values/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/full-program-tests/match-exhaustive-all-cases-primitive-values/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | primitive P1 fun one(): I32 => 1 4 | primitive P2 fun two(): I32 => 2 5 | primitive P3 fun three(): I32 => 3 6 | 7 | primitive Foo 8 | fun apply(p': (P1 | P2 | P3)): I32 => 9 | match p' 10 | | let p: P1 => p.one() 11 | | let p: P2 => p.two() 12 | | let p: P3 => p.three() 13 | end 14 | 15 | actor Main 16 | new create(env: Env) => 17 | @pony_exitcode(Foo(P3)) 18 | -------------------------------------------------------------------------------- /test/full-program-tests/object-literal-with-return-in-behaviour/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | None 4 | 5 | be foo() => 6 | let f = object ref 7 | fun apply() => 8 | if true then 9 | return None 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /test/full-program-tests/object-literal-with-return-in-constructor/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | let f = object ref 4 | fun apply() => 5 | if true then 6 | return None 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /test/full-program-tests/optimisation-merge-send-message-reordering/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/optimisation-merge-send-message-reordering/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | var state: U8 = 0 5 | 6 | new create(env: Env) => 7 | msg1(env) 8 | msg2(env) 9 | msg3(env) 10 | 11 | be msg1(env: Env) => 12 | if state == 0 then state = 1 end 13 | 14 | be msg2(env: Env) => 15 | if state == 1 then state = 2 end 16 | 17 | be msg3(env: Env) => 18 | if state == 2 then 19 | @pony_exitcode(1) 20 | end 21 | -------------------------------------------------------------------------------- /test/full-program-tests/pinned-actor/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 5 -------------------------------------------------------------------------------- /test/full-program-tests/primitive-final/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/primitive-final/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | primitive PrimitiveFinal 4 | fun _final() => 5 | @pony_exitcode(1) 6 | 7 | actor Main 8 | new create(env: Env) => 9 | None 10 | -------------------------------------------------------------------------------- /test/full-program-tests/primitive-init/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/primitive-init/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | primitive PrimitiveInit 4 | fun _init() => 5 | @pony_exitcode(1) 6 | 7 | actor Main 8 | new create(env: Env) => 9 | None 10 | -------------------------------------------------------------------------------- /test/full-program-tests/private-type-as-default-argument-in-public-function/lib/lib.pony: -------------------------------------------------------------------------------- 1 | primitive _Private 2 | 3 | primitive Public 4 | fun apply[T](v: (T | _Private) = _Private): None => None 5 | -------------------------------------------------------------------------------- /test/full-program-tests/private-type-as-default-argument-in-public-function/main.pony: -------------------------------------------------------------------------------- 1 | use lib = "lib" 2 | 3 | actor Main 4 | new create(env: Env) => 5 | lib.Public.apply[U8]() 6 | -------------------------------------------------------------------------------- /test/full-program-tests/promise-flatten-next-regression-3856/main.pony: -------------------------------------------------------------------------------- 1 | use "promises" 2 | 3 | actor FlattenNextProbe 4 | new create(handler: Handler iso) => 5 | let promise = Promise[String] 6 | // We need a call to next to be present with a call to flatten_next to trigger the issue during reachability analysis 7 | promise.next[Any tag](recover this~behaviour() end) 8 | (consume handler)(recover String end, promise) 9 | 10 | be behaviour(value: String) => 11 | None 12 | 13 | 14 | class Handler 15 | fun ref apply(line: String, prompt: Promise[String]) => 16 | let p = Promise[String] 17 | // BUG: Can't change the flatten_next 18 | p.flatten_next[String]({ (x: String) => Promise[String] }) 19 | 20 | 21 | actor Main 22 | new create(env: Env) => 23 | // BUG: Can't change this 24 | let term = FlattenNextProbe(Handler) -------------------------------------------------------------------------------- /test/full-program-tests/regression-1222/main.pony: -------------------------------------------------------------------------------- 1 | use "collections" 2 | 3 | actor Main 4 | new create(env: Env) => 5 | var list = List[I32] 6 | 7 | while list.size() < 2 do 8 | env.out.print("could be infinite loop if the for loop is optimized out") 9 | 10 | for d in Range[I32](0, 2) do 11 | env.out.print("running for loop...") 12 | list.push(d) 13 | end 14 | end 15 | 16 | env.out.print("finished!") 17 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-2150/bar.pony: -------------------------------------------------------------------------------- 1 | class Bar[T: Stringable #read] is Foo[T] 2 | let _t: T 3 | 4 | new create(t: T) => 5 | _t = t 6 | 7 | fun foo(): this->T => 8 | _t 9 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-2150/foo.pony: -------------------------------------------------------------------------------- 1 | use "debug" 2 | 3 | trait Foo[T: Stringable #read] 4 | fun foo(): this->T 5 | 6 | fun bar() => 7 | Debug.out(foo().string()) 8 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-2150/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | let b = Bar[I32](123) 4 | b.bar() 5 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-2408/main.pony: -------------------------------------------------------------------------------- 1 | interface SafeOps[T] 2 | fun addc(t: T): (T, Bool) 3 | fun subc(t: T): (T, Bool) 4 | 5 | class GenericSum[T: (Int & Integer[T] val & SafeOps[T])] 6 | fun _plus_safe(x: T, y: T): (T, Bool) => 7 | x.addc(y) 8 | 9 | fun sum(x: T, y: T): T ? => 10 | match _plus_safe(x, y) 11 | // In the issue 2408 ponyc < 0.26 was reporting this pattern to never match 12 | | (let res: T, false) => res 13 | | (_, true) => error 14 | else 15 | // this else is only needed because ponyc does not recognize 16 | // the match above as exhaustive 17 | error 18 | end 19 | 20 | actor Main 21 | new create(env: Env) => 22 | try 23 | GenericSum[U8].sum(1, 2)? 24 | end 25 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-2976/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-2976/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | apply(env) 4 | 5 | fun apply(env: Env) => 6 | test[I64](env, (0, true)) 7 | test[U64](env, (0, true)) 8 | 9 | fun test[A: Stringable #read](env: Env, expected: (A, Bool)) => 10 | busywork[A](env, expected._1) 11 | 12 | fun busywork[A: Stringable #read](env: Env, expected: A) => 13 | "." + "." + "." + "." + "." + "." + "." + "." + "." + "." + "." + "." + "." 14 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-3447/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | Dealer.from[U8](0) 4 | 5 | class Dealer 6 | new from[U: (U8 | Dealer val)](u: U val) => 7 | match u 8 | | let u': U8 => None 9 | | let u': Dealer val => None 10 | end 11 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-3615/main.pony: -------------------------------------------------------------------------------- 1 | primitive Foo 2 | fun apply() : (U32 | None) => 1 3 | 4 | type Bar is (U32 | None) 5 | 6 | actor Main 7 | let bar : Bar 8 | 9 | new create(env : Env) => 10 | match Foo() 11 | | let result : U32 => 12 | bar = result 13 | | None => 14 | bar = 0 15 | end 16 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-3658/main.pony: -------------------------------------------------------------------------------- 1 | primitive Foo[T: (Unsigned & UnsignedInteger[T])] 2 | fun boom() => 3 | iftype T <: U8 then 4 | None 5 | end 6 | // more cases 7 | // note that these method bodies are checked at their definition 8 | // site so there's no need to call them 9 | fun baam1[S: (Unsigned & UnsignedInteger[S] & U8)](t: S): U32 => 10 | t.u32() 11 | fun baam2[S: (U8 & Unsigned & UnsignedInteger[S])](t: S): U32 => 12 | t.u32() 13 | 14 | actor Main 15 | new create(env: Env) => 16 | Foo[U8].boom() 17 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-3737/lib/lib.pony: -------------------------------------------------------------------------------- 1 | primitive LibPrimitive 2 | 3 | trait LibTrait 4 | fun foo(): LibPrimitive => LibPrimitive 5 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-3737/main.pony: -------------------------------------------------------------------------------- 1 | use l = "./lib" 2 | 3 | actor Main is l.LibTrait 4 | new create(env: Env) => 5 | None 6 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-3765/main.pony: -------------------------------------------------------------------------------- 1 | use "debug" 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let a: AA = AA 6 | inspecta(consume a) 7 | 8 | be inspecta(a: AA val) => 9 | Debug.out("in inspecta") 10 | 11 | struct iso AA 12 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-3840/main.pony: -------------------------------------------------------------------------------- 1 | struct Foo 2 | 3 | class Bar 4 | let f: Foo = Foo 5 | 6 | actor Main 7 | new create(env: Env) => 8 | inspect(recover Bar end) 9 | 10 | be inspect(wrap: Bar iso) => 11 | None // Do something with wrap.f 12 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4059/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | let p: HtmlNode = P 4 | p.apply() 5 | 6 | class P is HtmlNode 7 | fun apply(): None => 8 | for f in [as HtmlNode:].values() do 9 | None 10 | end 11 | 12 | interface HtmlNode 13 | fun apply(): None 14 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4174/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 11 2 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4174/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(e: Env) => 5 | var src: Array[U8] = [1] 6 | var dest: Array[U8] = [11; 1; 2; 3; 4; 5; 6] 7 | src.copy_to(dest, 11, 0, 10) 8 | try 9 | let v = dest(0)?.i32() 10 | @pony_exitcode(v) 11 | end 12 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4369/main.pony: -------------------------------------------------------------------------------- 1 | use "time" 2 | 3 | class TimerPrint is TimerNotify 4 | var _count: U64 = 0 5 | 6 | new iso create() => 7 | None 8 | 9 | fun ref apply(timer: Timer, count: U64): Bool => 10 | _count = _count + count 11 | _count < 10 12 | 13 | fun ref cancel(timer: Timer) => 14 | None 15 | 16 | actor Main 17 | new create(env: Env) => 18 | let timers = Timers 19 | 20 | let t1 = Timer(TimerPrint, 500000000, 500000000) // 500 ms 21 | let t2 = Timer(TimerPrint, 500000000, 500000000) // 500 ms 22 | 23 | let t1' = t1 24 | timers(consume t1) 25 | timers.cancel(t1') 26 | timers(consume t2) 27 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4412/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4412/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | // As long as #4412 is fixed, this program will compile. 4 | 5 | actor Main 6 | new create(env: Env) => 7 | // A union type with a tuple is required to trigger the crash 8 | let z: (I32 | (I32, I32)) = (123, 42) 9 | 10 | match z 11 | // This is the line that triggered the crash due to the extra parens around 12 | // the let. 13 | | (123, (let x: I32)) => @pony_exitcode(x) 14 | end 15 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4479/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => None 3 | let cb: Callbacks = Callbacks 4 | 5 | class Callbacks 6 | var cbi: @{(): None} 7 | 8 | new create() => 9 | cbi = @{() => None} 10 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4480/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | let a: F64 = 3.14 4 | let b: F64 = a.powi(-2) 5 | env.out.print("B is now " + b.string()) 6 | 7 | let c: F32 = 3.14 8 | let d: F32 = c.powi(-3) 9 | env.out.print("D is now " + d.string()) 10 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4582/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 100 -------------------------------------------------------------------------------- /test/full-program-tests/regression-4612/main.pony: -------------------------------------------------------------------------------- 1 | """ 2 | This won't compile if there is a regression for issue #4612. 3 | """ 4 | 5 | actor Main 6 | new create(env: Env) => 7 | None 8 | 9 | primitive Prim 10 | fun ignore() => None 11 | 12 | trait A 13 | fun union(): (Prim | None) 14 | 15 | fun match_it(): Bool => 16 | match union() 17 | | let p: Prim => 18 | p.ignore() 19 | true 20 | | None => 21 | false 22 | end 23 | 24 | class B is A 25 | fun union(): Prim => 26 | Prim 27 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4613/main.pony: -------------------------------------------------------------------------------- 1 | use "./pkg" 2 | 3 | actor Main 4 | new create(env: Env) => 5 | None 6 | 7 | class C is T 8 | fun _override(): (T | None) => 9 | None 10 | 11 | fun _get_opc(): OPC => 12 | OPC 13 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4613/pkg/trait.pony: -------------------------------------------------------------------------------- 1 | trait T 2 | fun _override(): (T | None) 3 | 4 | fun _with_default() => 5 | """ 6 | Will compile if #4613 remains fixed. Otherwise, this will fail to 7 | compiled IFF a class from outside this package implements this trait 8 | and inherits this default method 9 | """ 10 | match _override() 11 | | let t: T => 12 | t._with_default() 13 | | None => 14 | None 15 | end 16 | 17 | fun _get_opc(): OPC 18 | 19 | fun _calling_method_that_is_private_to_this_package_on_another_type() => 20 | """ 21 | Will compile if #4613 remains fixed. Otherwise, this will fail to 22 | compiled IFF a class from outside this package implements this trait 23 | and inherits this default method 24 | """ 25 | _get_opc()._private() 26 | 27 | class OPC 28 | new create() => 29 | None 30 | 31 | fun _private() => 32 | None 33 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-4613/regression-4613: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ponylang/ponyc/65a06e20509a5db94859742e587520446258283d/test/full-program-tests/regression-4613/regression-4613 -------------------------------------------------------------------------------- /test/full-program-tests/regression-623-case-1/main.pony: -------------------------------------------------------------------------------- 1 | """ 2 | Prior to fix for issue 623, this would result in a segfault 3 | when SpeechOut was gc'd during tracing of SpeechIn 4 | """ 5 | use "debug" 6 | 7 | actor Main 8 | new create(env: Env) => 9 | let talk = SpeechOut 10 | let config = Config.create(talk) 11 | 12 | SpeechIn.create(config) 13 | 14 | actor SpeechOut 15 | new create() => 16 | None 17 | 18 | actor SpeechIn 19 | let _talk: SpeechOut tag 20 | 21 | new create(config: Config) => 22 | _talk = config.talk 23 | _loadRules() 24 | 25 | fun ref _loadRules() => 26 | var i: U8 = 0 27 | 28 | 29 | while i < 240 do 30 | i = i + 1 31 | Debug.out(i.string()) 32 | end 33 | 34 | class val Config 35 | let talk: SpeechOut tag 36 | 37 | new val create(talk': SpeechOut tag) => 38 | talk = talk' 39 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-623-case-2/main.pony: -------------------------------------------------------------------------------- 1 | """ 2 | Prior to the resolution of issue 623, this would cause the gc to crash while 3 | tracing SpeechOut from SpeechIn 4 | """ 5 | actor Main 6 | new create(env: Env) => 7 | let talk = SpeechOut 8 | let config = Config.create(talk) 9 | 10 | SpeechIn.create(talk, config) 11 | 12 | actor SpeechOut 13 | new create() => None 14 | 15 | actor SpeechIn 16 | let talk: SpeechOut tag 17 | 18 | new create(talk': SpeechOut, config: Config) => 19 | talk = config.talk 20 | recover String(16000) end // trigger gc, happens around 14336 21 | 22 | class val Config 23 | let talk: SpeechOut tag 24 | 25 | new val create(talk': SpeechOut tag) => 26 | talk = talk' 27 | -------------------------------------------------------------------------------- /test/full-program-tests/regression-849/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => meaning_of_life() 3 | fun meaning_of_life(): (String, (String|U32)) => 4 | let x = U32(1) 5 | ("hi", "hi") 6 | -------------------------------------------------------------------------------- /test/full-program-tests/small-dependent-finalisers/additional.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifdef _MSC_VER 5 | # define EXPORT_SYMBOL __declspec(dllexport) 6 | #else 7 | # define EXPORT_SYMBOL 8 | #endif 9 | 10 | extern "C" 11 | { 12 | 13 | static uint32_t num_objects = 1025; 14 | 15 | EXPORT_SYMBOL extern void codegentest_small_dependent_finalisers_decrement_num_objects() 16 | { 17 | num_objects--; 18 | pony_exitcode((int)num_objects); 19 | } 20 | 21 | #ifndef _MSC_VER 22 | void Main_runtime_override_defaults_oo(void* opt) 23 | { 24 | (void)opt; 25 | return; 26 | } 27 | #endif 28 | 29 | } 30 | -------------------------------------------------------------------------------- /test/full-program-tests/small-dependent-finalisers/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/full-program-tests/small-dependent-finalisers/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:small-dependent-finalisers-additional" 2 | 3 | use @codegentest_small_dependent_finalisers_decrement_num_objects[None]() 4 | 5 | class _Final 6 | let num: USize 7 | var other: (_Final | None) = None 8 | 9 | new create(n: USize) => 10 | num = n 11 | 12 | fun _final() => 13 | match other 14 | | None => None 15 | | let o: this->_Final => 16 | if 1025 == (num + o.num) then 17 | @codegentest_small_dependent_finalisers_decrement_num_objects() 18 | end 19 | end 20 | 21 | actor Main 22 | new create(env: Env) => 23 | var i: USize = 0 24 | let arr: Array[_Final] = Array[_Final].create(1024) 25 | while i < arr.space() do 26 | i = i + 1 27 | arr.push(_Final(i)) 28 | end 29 | i = 0 30 | while i < arr.space() do 31 | try 32 | arr(i)?.other = arr(arr.space() - (i + 1))? 33 | end 34 | i = i + 1 35 | end 36 | -------------------------------------------------------------------------------- /test/full-program-tests/small-finalisers/additional.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifdef _MSC_VER 5 | # define EXPORT_SYMBOL __declspec(dllexport) 6 | #else 7 | # define EXPORT_SYMBOL 8 | #endif 9 | 10 | extern "C" 11 | { 12 | 13 | static uint32_t num_objects = 0; 14 | 15 | EXPORT_SYMBOL extern void codegentest_small_finalisers_increment_num_objects() 16 | { 17 | num_objects++; 18 | pony_exitcode((int)num_objects); 19 | } 20 | 21 | #ifndef _MSC_VER 22 | void Main_runtime_override_defaults_oo(void* opt) 23 | { 24 | (void)opt; 25 | return; 26 | } 27 | #endif 28 | 29 | } 30 | -------------------------------------------------------------------------------- /test/full-program-tests/small-finalisers/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/full-program-tests/small-finalisers/main.pony: -------------------------------------------------------------------------------- 1 | use "lib:small-finalisers-additional" 2 | 3 | use @codegentest_small_finalisers_increment_num_objects[None]() 4 | 5 | class _Final 6 | fun _final() => 7 | @codegentest_small_finalisers_increment_num_objects() 8 | 9 | actor Main 10 | new create(env: Env) => 11 | var i: U64 = 0 12 | while i < 42 do 13 | _Final 14 | i = i + 1 15 | end 16 | -------------------------------------------------------------------------------- /test/full-program-tests/string-serialisation/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/string-serialisation/main.pony: -------------------------------------------------------------------------------- 1 | """ 2 | From #2245 3 | """ 4 | 5 | use "serialise" 6 | use @pony_exitcode[None](code: I32) 7 | 8 | class V 9 | let _v: String = "" 10 | 11 | actor Main 12 | new create(env: Env) => 13 | try 14 | let v: V = V 15 | Serialised(SerialiseAuth(env.root), v)? 16 | @pony_exitcode(1) 17 | end 18 | -------------------------------------------------------------------------------- /test/full-program-tests/try-block-cant-catch-cpp-exception/additional.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef _MSC_VER 4 | # define EXPORT_SYMBOL __declspec(dllexport) 5 | #else 6 | # define EXPORT_SYMBOL 7 | #endif 8 | 9 | extern "C" 10 | { 11 | 12 | EXPORT_SYMBOL int codegen_test_tryblock_catch(void (*callback)()) 13 | { 14 | try 15 | { 16 | callback(); 17 | return 0; 18 | } catch(std::exception const&) { 19 | return 1; 20 | } 21 | } 22 | 23 | EXPORT_SYMBOL void codegen_test_tryblock_throw() 24 | { 25 | throw std::exception(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /test/full-program-tests/try-block-cant-catch-cpp-exception/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/full-program-tests/try-block-cant-catch-cpp-exception/main.pony: -------------------------------------------------------------------------------- 1 | """ 2 | This test doesn't work on Windows. The C++ code doesn't catch C++ exceptions 3 | if they've traversed a Pony frame. This is suspected to be related to how 4 | SEH and LLVM exception code generation interact. 5 | 6 | See https://github.com/ponylang/ponyc/issues/2455 for more details. 7 | """ 8 | use "lib:try-block-cant-catch-cpp-exception-additional" 9 | 10 | use @codegen_test_tryblock_catch[I32](callback: Pointer[None]) 11 | use @codegen_test_tryblock_throw[None]()? 12 | use @pony_exitcode[None](code: I32) 13 | 14 | actor Main 15 | new create(env: Env) => 16 | let r = @codegen_test_tryblock_catch(this~tryblock()) 17 | @pony_exitcode(r) 18 | 19 | fun @tryblock() => 20 | try 21 | @codegen_test_tryblock_throw()? 22 | else 23 | None 24 | end 25 | -------------------------------------------------------------------------------- /test/full-program-tests/try-else-can-initialize-fields/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | var _s: (String | None) 3 | 4 | new create(env: Env) => 5 | try 6 | _s = "".usize()?.string() 7 | else 8 | _s = None 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-can-initialize-fields/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | var _s: (String | None) 3 | 4 | new create(env: Env) => 5 | try 6 | "".usize()?.string() 7 | then 8 | _s = "initialized" 9 | end 10 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-break-nested/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-break-nested/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | var r: I32 = 0 6 | while true do 7 | try 8 | try 9 | if Bool(false) then error end 10 | break 11 | end 12 | then 13 | r = 42 14 | end 15 | end 16 | @pony_exitcode(r) 17 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-break/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-break/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | var r: I32 = 0 6 | while true do 7 | try 8 | if Bool(false) then error end 9 | break 10 | then 11 | r = 42 12 | end 13 | end 14 | @pony_exitcode(r) 15 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-continue-nested/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-continue-nested/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | var r: I32 = 0 6 | while r == 0 do 7 | try 8 | if Bool(true) then 9 | try 10 | if Bool(false) then error else r = 1 end 11 | continue 12 | end 13 | end 14 | then 15 | r = 42 16 | end 17 | end 18 | @pony_exitcode(r) 19 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-continue/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-continue/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | var r: I32 = 0 6 | while r == 0 do 7 | try 8 | if Bool(false) then error else r = 1 end 9 | continue 10 | then 11 | r = 42 12 | end 13 | end 14 | @pony_exitcode(r) 15 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-return-nested/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-return-nested/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | try 6 | try 7 | if false then error end 8 | return 9 | end 10 | then 11 | @pony_exitcode(42) 12 | end 13 | @pony_exitcode(0) 14 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-return/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/full-program-tests/try-then-clause-return/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | try 6 | if false then error end 7 | return 8 | then 9 | @pony_exitcode(42) 10 | end 11 | @pony_exitcode(0) 12 | -------------------------------------------------------------------------------- /test/full-program-tests/union-value-for-tuple-return-type/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/full-program-tests/union-value-for-tuple-return-type/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | new create(env: Env) => 3 | try _create_tuple()._2 as Bool end 4 | 5 | fun _create_tuple(): (U32, (Bool | None)) => 6 | let x: ((U32, Bool) | (U32, None)) = (1, true) 7 | x 8 | -------------------------------------------------------------------------------- /test/full-program-tests/while-else-can-initialize-fields/main.pony: -------------------------------------------------------------------------------- 1 | actor Main 2 | var _s: (String | None) 3 | 4 | new create(env: Env) => 5 | var i: USize = 0 6 | while i < 5 do 7 | _s = i.string() 8 | i = i + 1 9 | else 10 | _s = "" 11 | end 12 | -------------------------------------------------------------------------------- /test/full-program-tests/while-else-trigger-else-clause/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /test/full-program-tests/while-else-trigger-else-clause/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | let counter: USize = 0 6 | while counter > 0 do 7 | @pony_exitcode(10) 8 | else 9 | @pony_exitcode(20) 10 | end 11 | -------------------------------------------------------------------------------- /test/full-program-tests/while-else-trigger-while-body/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/full-program-tests/while-else-trigger-while-body/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | actor Main 4 | new create(env: Env) => 5 | var counter: USize = 5 6 | while counter > 0 do 7 | @pony_exitcode(10) 8 | counter = counter - 1 9 | else 10 | @pony_exitcode(20) 11 | end 12 | -------------------------------------------------------------------------------- /test/full-program-tests/with-as-expression/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/full-program-tests/with-as-expression/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class Disposble 4 | new create() => 5 | None 6 | 7 | fun foo() => 8 | None 9 | 10 | fun dispose() => 11 | None 12 | 13 | actor Main 14 | new create(env: Env) => 15 | let exit = with d = Disposble do 16 | d.foo() 17 | I32(10) 18 | end 19 | @pony_exitcode(exit) 20 | 21 | -------------------------------------------------------------------------------- /test/full-program-tests/with-error-from-function/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/full-program-tests/with-error-from-function/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class Disposable 4 | var _exit_code: I32 5 | 6 | new create() => 7 | _exit_code = 0 8 | 9 | fun ref set_exit(code: I32) => 10 | _exit_code = code 11 | 12 | fun dispose() => 13 | @pony_exitcode(_exit_code) 14 | 15 | actor Main 16 | new create(env: Env) => 17 | try 18 | with d = Disposable do 19 | d.set_exit(10) 20 | errors()? 21 | end 22 | end 23 | 24 | fun errors() ? => 25 | error 26 | -------------------------------------------------------------------------------- /test/full-program-tests/with-error-in-block/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/full-program-tests/with-error-in-block/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class Disposble 4 | var _exit_code: I32 5 | 6 | new create() => 7 | _exit_code = 0 8 | 9 | fun ref set_exit(code: I32) => 10 | _exit_code = code 11 | 12 | fun dispose() => 13 | @pony_exitcode(_exit_code) 14 | 15 | actor Main 16 | new create(env: Env) => 17 | try 18 | with d = Disposble do 19 | d.set_exit(10) 20 | error 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /test/full-program-tests/with-in-loop-with-break/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/full-program-tests/with-in-loop-with-break/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class Disposble 4 | var _exit_code: I32 5 | 6 | new create() => 7 | _exit_code = 0 8 | 9 | fun ref set_exit(code: I32) => 10 | _exit_code = code 11 | 12 | fun dispose() => 13 | @pony_exitcode(_exit_code) 14 | 15 | actor Main 16 | new create(env: Env) => 17 | var counter: I32 = 0 18 | while true do 19 | counter = counter + 1 20 | with d = Disposble do 21 | d.set_exit(counter) 22 | if counter == 10 then 23 | break 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /test/full-program-tests/with-in-loop-with-continue/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/full-program-tests/with-in-loop-with-continue/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class Disposble 4 | var _exit_code: I32 5 | 6 | new create() => 7 | _exit_code = 0 8 | 9 | fun ref set_exit(code: I32) => 10 | _exit_code = code 11 | 12 | fun dispose() => 13 | @pony_exitcode(_exit_code) 14 | 15 | actor Main 16 | new create(env: Env) => 17 | var counter: I32 = 0 18 | while counter < 10 do 19 | counter = counter + 1 20 | with d = Disposble do 21 | d.set_exit(counter) 22 | continue 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /test/full-program-tests/with-standard/expected-exit-code.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/full-program-tests/with-standard/main.pony: -------------------------------------------------------------------------------- 1 | use @pony_exitcode[None](code: I32) 2 | 3 | class Disposble 4 | var _exit_code: I32 5 | 6 | new create() => 7 | _exit_code = 0 8 | 9 | fun ref set_exit(code: I32) => 10 | _exit_code = code 11 | 12 | fun dispose() => 13 | @pony_exitcode(_exit_code) 14 | 15 | actor Main 16 | new create(env: Env) => 17 | with d = Disposble do 18 | d.set_exit(10) 19 | end 20 | 21 | -------------------------------------------------------------------------------- /test/libponyc/codegen_optimisation.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "util.h" 5 | 6 | #define TEST_COMPILE(src) DO(test_compile(src, "ir")) 7 | 8 | 9 | class CodegenOptimisationTest : public PassTest 10 | {}; 11 | 12 | TEST_F(CodegenOptimisationTest, MergeSendCrossMessaging) 13 | { 14 | // Test that we don't produce invalid LLVM IR that would cause a crash. 15 | const char* src = 16 | "actor A\n" 17 | " be m(a: A) => None\n" 18 | 19 | "actor Main\n" 20 | " new create(env: Env) =>\n" 21 | " test(A, A)\n" 22 | 23 | " be test(a1: A, a2: A) =>\n" 24 | " a1.m(a2)\n" 25 | " a2.m(a1)"; 26 | 27 | opt.release = true; 28 | 29 | TEST_COMPILE(src); 30 | } 31 | -------------------------------------------------------------------------------- /test/libponyc/option_parser.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../../src/libponyrt/options/options.h" 5 | 6 | class OptionParserTest : public testing::Test 7 | {}; 8 | -------------------------------------------------------------------------------- /test/libponyc/type_check_bind.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "util.h" 6 | 7 | #define TEST_COMPILE(src) DO(test_compile(src, "expr")) 8 | 9 | class BindTest: public PassTest 10 | {}; 11 | 12 | 13 | TEST_F(BindTest, RecursiveConstraintIsUnbound) 14 | { 15 | const char* src = 16 | "class C1[A, B: A]\n" 17 | " var x: B\n" 18 | " new create(x': B) => x = consume x'\n"; 19 | 20 | TEST_COMPILE(src); 21 | ast_t* x = lookup_member("C1", "x"); 22 | ASSERT_EQ(NULL, typeparam_constraint(ast_type(x))); 23 | } 24 | -------------------------------------------------------------------------------- /test/libponyc/with.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "util.h" 5 | 6 | 7 | #define TEST_COMPILE(src) DO(test_compile(src, "expr")) 8 | 9 | #define TEST_ERRORS_1(src, err1) \ 10 | { const char* errs[] = {err1, NULL}; \ 11 | DO(test_expected_errors(src, "expr", errs)); } 12 | 13 | class WithTest : public PassTest 14 | {}; 15 | 16 | TEST_F(WithTest, NoEarlyReturnFromWith) 17 | { 18 | // From issue #4464 19 | const char* src = 20 | "class Disposable\n" 21 | " new create() => None\n" 22 | " fun ref set_exit(x: U32) => None\n" 23 | " fun dispose() => None\n" 24 | "actor Main\n" 25 | " new create(env: Env) =>\n" 26 | " with d = Disposable do\n" 27 | " d.set_exit(10)\n" 28 | " return\n" 29 | " end"; 30 | 31 | TEST_ERRORS_1(src, 32 | "use return only to exit early from a with block, not at the end"); 33 | } 34 | -------------------------------------------------------------------------------- /test/libponyrt/lang/error.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | TEST(ErrorTest, PonyTry) 9 | { 10 | auto cb_success = [](void*){}; 11 | auto cb_error = [](void*){ pony_error(); }; 12 | 13 | ASSERT_TRUE(pony_try(cb_success, nullptr)); 14 | ASSERT_FALSE(pony_try(cb_error, nullptr)); 15 | } 16 | 17 | // Doesn't work on windows. The C++ code doesn't catch C++ exceptions if they've 18 | // traversed a pony_try() call. This is suspected to be related to how SEH and 19 | // LLVM exception code generation interact. 20 | // See https://github.com/ponylang/ponyc/issues/2455 for more details. 21 | #ifndef PLATFORM_IS_WINDOWS 22 | TEST(ErrorTest, PonyTryCantCatchCppExcept) 23 | { 24 | auto cb_cppthrow = [](void*){ throw std::exception{}; }; 25 | 26 | ASSERT_THROW((pony_try(cb_cppthrow, nullptr)), std::exception); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /test/libponyrt/util.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "util.h" 3 | 4 | void Main_runtime_override_defaults_oo(void* opt) 5 | { 6 | (void)opt; 7 | return; 8 | } 9 | 10 | int main(int argc, char** argv) 11 | { 12 | testing::InitGoogleTest(&argc, argv); 13 | return RUN_ALL_TESTS(); 14 | } 15 | -------------------------------------------------------------------------------- /test/libponyrt/util.h: -------------------------------------------------------------------------------- 1 | #ifndef UNIT_UTIL_H 2 | #define UNIT_UTIL_H 3 | 4 | extern "C" { 5 | void Main_runtime_override_defaults_oo(void* opt); 6 | } 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/rt-stress/tcp-open-close/README.md: -------------------------------------------------------------------------------- 1 | # TCP Open/Close Stress Test 2 | 3 | Stress test that opens and closes a large number of TCP connections sending a small amount of data between them. 4 | 5 | ## How it stresses the runtime 6 | 7 | - Heavy ASIO activity 8 | - Lots of actor creation and destruction 9 | --------------------------------------------------------------------------------