Merge remote-tracking branch 'remote/main' into upgrade-llvm-zig

This commit is contained in:
Luke Boswell 2024-08-15 07:11:29 +10:00
commit 57b277da5c
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
212 changed files with 9379 additions and 7534 deletions

View file

@ -30,7 +30,7 @@ rustflags = ["-Clink-args=/FORCE:UNRESOLVED"]
# https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993 # https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993
ROC_WORKSPACE_DIR = { value = "", relative = true } ROC_WORKSPACE_DIR = { value = "", relative = true }
# Debug flags. Keep this up-to-date with compiler/debug_flags/src/lib.rs. # Debug flags. Explanations for these are in compiler/debug_flags/src/lib.rs.
# Set = "1" to turn a debug flag on. # Set = "1" to turn a debug flag on.
ROC_PRETTY_PRINT_ALIAS_CONTENTS = "0" ROC_PRETTY_PRINT_ALIAS_CONTENTS = "0"
ROC_PRINT_UNIFICATIONS = "0" ROC_PRINT_UNIFICATIONS = "0"
@ -49,6 +49,7 @@ ROC_PRINT_IR_AFTER_TRMC = "0"
ROC_PRINT_IR_AFTER_DROP_SPECIALIZATION = "0" ROC_PRINT_IR_AFTER_DROP_SPECIALIZATION = "0"
ROC_DEBUG_ALIAS_ANALYSIS = "0" ROC_DEBUG_ALIAS_ANALYSIS = "0"
ROC_PRINT_RUNTIME_ERROR_GEN = "0" ROC_PRINT_RUNTIME_ERROR_GEN = "0"
ROC_NO_UNBOUND_LAYOUT = "0"
ROC_PRINT_LLVM_FN_VERIFICATION = "0" ROC_PRINT_LLVM_FN_VERIFICATION = "0"
ROC_WRITE_FINAL_WASM = "0" ROC_WRITE_FINAL_WASM = "0"
ROC_LOG_WASM_INTERP = "0" ROC_LOG_WASM_INTERP = "0"

View file

@ -104,10 +104,10 @@ jobs:
if: needs.check-changes.outputs.run_tests == 'full' if: needs.check-changes.outputs.run_tests == 'full'
uses: ./.github/workflows/ubuntu_x86_64.yml uses: ./.github/workflows/ubuntu_x86_64.yml
start-ubuntu-x86-64-tests-debug: start-ubuntu-x86-64-nix-tests-debug:
needs: check-changes needs: check-changes
if: needs.check-changes.outputs.run_tests == 'full' if: needs.check-changes.outputs.run_tests == 'full'
uses: ./.github/workflows/ubuntu_x86_64_debug.yml uses: ./.github/workflows/ubuntu_x86_64_nix_debug.yml
start-windows-release-build-test: start-windows-release-build-test:
needs: check-changes needs: check-changes
@ -133,7 +133,7 @@ jobs:
start-nix-macos-apple-silicon-tests, start-nix-macos-apple-silicon-tests,
start-macos-x86-64-tests, start-macos-x86-64-tests,
start-ubuntu-x86-64-tests, start-ubuntu-x86-64-tests,
start-ubuntu-x86-64-tests-debug, start-ubuntu-x86-64-nix-tests-debug,
start-windows-release-build-test, start-windows-release-build-test,
start-windows-tests, start-windows-tests,
start-roc-benchmarks start-roc-benchmarks

View file

@ -1,38 +0,0 @@
on:
workflow_call:
name: cargo test debug
env:
RUST_BACKTRACE: 1
jobs:
cargo-test-debug:
name: cargo test debug
runs-on: [ubuntu-22.04]
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- run: zig version
- name: Install dependencies
run: |
sudo apt -y install build-essential libunwind-dev pkg-config zlib1g-dev valgrind
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16
sudo rm /usr/bin/clang
sudo ln -s /usr/bin/clang-16 /usr/bin/clang
sudo ln -s /usr/bin/lld-16 /usr/bin/ld.lld
sudo apt -y install libpolly-16-dev
# for skipped tests; see #6946, #6947
- name: cargo test without --release
env:
RUSTFLAGS: -C link-arg=-fuse-ld=lld
run: cargo test -- --skip tests/exhaustive/match_on_result_with_uninhabited_error_destructuring_in_lambda_syntax.txt --skip tests::identity_lambda --skip tests::issue_2300 --skip tests::issue_2582_specialize_result_value --skip tests::sum_lambda

View file

@ -0,0 +1,27 @@
on:
workflow_call:
name: cargo test debug nix
env:
RUST_BACKTRACE: 1
jobs:
cargo-test-debug-nix:
name: cargo test debug nix
runs-on: [ubuntu-22.04]
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
# install nix
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Check if debug flag files are in sync
run: ./ci/check_debug_vars.sh
# for skipped tests; see #6946, #6947
- name: cargo test without --release
run: nix develop -c sh -c 'export ROC_CHECK_MONO_IR=1 && cargo test -- --skip tests/exhaustive/match_on_result_with_uninhabited_error_destructuring_in_lambda_syntax.txt --skip tests::identity_lambda --skip tests::issue_2300 --skip tests::issue_2582_specialize_result_value --skip tests::sum_lambda'

View file

@ -43,20 +43,9 @@ Execute `cargo fmt --all` to fix the formatting.
- The [compiler's README](https://github.com/roc-lang/roc/tree/main/crates/compiler) contains important info. - The [compiler's README](https://github.com/roc-lang/roc/tree/main/crates/compiler) contains important info.
- The AI chat in the [cursor editor](https://www.cursor.com/) can also help you find your way in the codebase. - The AI chat in the [cursor editor](https://www.cursor.com/) can also help you find your way in the codebase.
<details> ### Debugging tips
<summary>:beetle: Debugging Tips</summary>
- Use a debug build of the compiler. We have many asserts enabled in the debug compiler that can alert you to something going wrong. When building from source, build the debug compiler with `cargo build --bin roc`, the binary is at roc/target/debug/roc. When using roc through a nix flake like in [basic-cli](https://github.com/roc-lang/basic-cli), use `rocPkgs.cli-debug` instead of `rocPkgs.cli`.
- At the bottom of [.cargo/config.toml](https://github.com/roc-lang/roc/blob/main/.cargo/config.toml) we have useful debug flags that activate certain debug prints.
- For Roc code; minimize the code that produces the issue.
- If you plan to look at the data used and produced inside the compiler, try to reproduce your issue with a very simple platform like our [minimal Rust platform](https://github.com/roc-lang/roc/tree/main/examples/platform-switching/rust-platform) instead of for example basic-cli.
- For segmentation faults:
+ In general we recommend using linux to investigate, it has better tools for this.
+ Use `roc build myApp.roc --linker=legacy` followed by `valgrind ./myApp`.
+ Use gdb to step through the code, [this gdb script](https://roc.zulipchat.com/#narrow/stream/395097-compiler-development/topic/gdb.20script/near/424422545) can be helpful.
+ Inspect the generated LLVM IR (`roc build myApp.roc --emit-llvm-ir`) between Roc code that encounters the segfault and code that doesn't.
If you need to do some debugging, check out [our tips](devtools/debug_tips.md).
</details>
### Commit signing ### Commit signing

22
ci/check_debug_vars.sh Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euo pipefail
# Extract vars from .cargo/config.toml
config_vars=$(grep -E "^ROC_.*= \"[01]\"" .cargo/config.toml | cut -d'=' -f1 | tr -d ' ')
# Extract vars from crates/compiler/debug_flags/src/lib.rs
lib_vars=$(grep -E "^ ROC_.*" crates/compiler/debug_flags/src/lib.rs | tr -d ' ')
# Sort both lists
sorted_config_vars=$(echo "$config_vars" | sort)
sorted_lib_vars=$(echo "$lib_vars" | sort)
# Compare the sorted lists
if diff <(echo "$sorted_config_vars") <(echo "$sorted_lib_vars") > /dev/null; then
echo "The flags in both files are identical."
else
echo "Looks like some flags are out of sync between .cargo/config.toml and crates/compiler/debug_flags/src/lib.rs:"
diff <(echo "$sorted_config_vars") <(echo "$sorted_lib_vars")
fi

View file

@ -5,11 +5,12 @@ use std::path::{Path, PathBuf};
use bumpalo::Bump; use bumpalo::Bump;
use roc_error_macros::{internal_error, user_error}; use roc_error_macros::{internal_error, user_error};
use roc_fmt::def::fmt_defs; use roc_fmt::def::fmt_defs;
use roc_fmt::module::fmt_module; use roc_fmt::header::fmt_header;
use roc_fmt::{Ast, Buf}; use roc_fmt::Buf;
use roc_parse::module::parse_module_defs; use roc_parse::ast::{FullAst, SpacesBefore};
use roc_parse::remove_spaces::RemoveSpaces; use roc_parse::header::parse_module_defs;
use roc_parse::{module, parser::SyntaxError, state::State}; use roc_parse::normalize::Normalize;
use roc_parse::{header, parser::SyntaxError, state::State};
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum FormatMode { pub enum FormatMode {
@ -199,8 +200,8 @@ pub fn format_src(arena: &Bump, src: &str) -> Result<String, FormatProblem> {
} }
}; };
let ast_normalized = ast.remove_spaces(arena); let ast_normalized = ast.normalize(arena);
let reparsed_ast_normalized = reparsed_ast.remove_spaces(arena); let reparsed_ast_normalized = reparsed_ast.normalize(arena);
// HACK! // HACK!
// We compare the debug format strings of the ASTs, because I'm finding in practice that _somewhere_ deep inside the ast, // We compare the debug format strings of the ASTs, because I'm finding in practice that _somewhere_ deep inside the ast,
@ -230,19 +231,25 @@ pub fn format_src(arena: &Bump, src: &str) -> Result<String, FormatProblem> {
Ok(buf.as_str().to_string()) Ok(buf.as_str().to_string())
} }
fn parse_all<'a>(arena: &'a Bump, src: &'a str) -> Result<Ast<'a>, SyntaxError<'a>> { fn parse_all<'a>(arena: &'a Bump, src: &'a str) -> Result<FullAst<'a>, SyntaxError<'a>> {
let (module, state) = module::parse_header(arena, State::new(src.as_bytes())) let (header, state) = header::parse_header(arena, State::new(src.as_bytes()))
.map_err(|e| SyntaxError::Header(e.problem))?; .map_err(|e| SyntaxError::Header(e.problem))?;
let (module, defs) = module.upgrade_header_imports(arena); let (h, defs) = header.item.upgrade_header_imports(arena);
let defs = parse_module_defs(arena, state, defs)?; let defs = parse_module_defs(arena, state, defs)?;
Ok(Ast { module, defs }) Ok(FullAst {
header: SpacesBefore {
before: header.before,
item: h,
},
defs,
})
} }
fn fmt_all<'a>(buf: &mut Buf<'a>, ast: &'a Ast) { fn fmt_all<'a>(buf: &mut Buf<'a>, ast: &'a FullAst) {
fmt_module(buf, &ast.module); fmt_header(buf, &ast.header);
fmt_defs(buf, &ast.defs, 0); fmt_defs(buf, &ast.defs, 0);

View file

@ -432,6 +432,14 @@ pub fn build_app() -> Command {
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.required(false) .required(false)
) )
.arg(
Arg::new(FLAG_TARGET)
.long(FLAG_TARGET)
.help("Choose a different target")
.default_value(Into::<&'static str>::into(Target::default()))
.value_parser(build_target_values_parser.clone())
.required(false),
)
) )
.arg(flag_optimize) .arg(flag_optimize)
.arg(flag_max_threads) .arg(flag_max_threads)

View file

@ -9,8 +9,8 @@ main =
a: Task.ok 123, a: Task.ok 123,
b: Task.ok "abc", b: Task.ok "abc",
c: Task.ok [123], c: Task.ok [123],
d: Task.ok ["abc"], _d: Task.ok ["abc"],
e: Task.ok (Dict.single "a" "b"), _: Task.ok (Dict.single "a" "b"),
}! }!
Stdout.line! "For multiple tasks: $(Inspect.toStr multipleIn)" Stdout.line! "For multiple tasks: $(Inspect.toStr multipleIn)"

View file

@ -711,6 +711,17 @@ mod cli_run {
) )
} }
#[test]
#[cfg_attr(windows, ignore)]
fn platform_requires_pkg() {
test_roc_app_slim(
"crates/cli/tests/platform_requires_pkg",
"app.roc",
"from app from package",
UseValgrind::No,
)
}
#[test] #[test]
#[cfg_attr(windows, ignore)] #[cfg_attr(windows, ignore)]
fn transitive_expects() { fn transitive_expects() {
@ -947,7 +958,7 @@ mod cli_run {
&[], &[],
&[], &[],
&[], &[],
"For multiple tasks: {a: 123, b: \"abc\", c: [123], d: [\"abc\"], e: {\"a\": \"b\"}}\n", "For multiple tasks: {a: 123, b: \"abc\", c: [123]}\n",
UseValgrind::No, UseValgrind::No,
TestCliCommands::Run, TestCliCommands::Run,
) )

View file

@ -0,0 +1,6 @@
app [main] {
pf: platform "./platform/main.roc"
}
main =
"from app"

View file

@ -0,0 +1,3 @@
module [foo]
foo = "from package"

View file

@ -0,0 +1 @@
package [Foo] {}

View file

@ -0,0 +1,129 @@
const std = @import("std");
const builtin = @import("builtin");
const str = @import("glue").str;
const RocStr = str.RocStr;
const testing = std.testing;
const expectEqual = testing.expectEqual;
const expect = testing.expect;
const Align = 2 * @alignOf(usize);
extern fn malloc(size: usize) callconv(.C) ?*align(Align) anyopaque;
extern fn realloc(c_ptr: [*]align(Align) u8, size: usize) callconv(.C) ?*anyopaque;
extern fn free(c_ptr: [*]align(Align) u8) callconv(.C) void;
extern fn memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void;
extern fn memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void;
const DEBUG: bool = false;
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
if (DEBUG) {
var ptr = malloc(size);
const stdout = std.io.getStdOut().writer();
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
return ptr;
} else {
return malloc(size);
}
}
export fn roc_realloc(c_ptr: *anyopaque, new_size: usize, old_size: usize, alignment: u32) callconv(.C) ?*anyopaque {
if (DEBUG) {
const stdout = std.io.getStdOut().writer();
stdout.print("realloc: {d} (alignment {d}, old_size {d})\n", .{ c_ptr, alignment, old_size }) catch unreachable;
}
return realloc(@as([*]align(Align) u8, @alignCast(@ptrCast(c_ptr))), new_size);
}
export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void {
if (DEBUG) {
const stdout = std.io.getStdOut().writer();
stdout.print("dealloc: {d} (alignment {d})\n", .{ c_ptr, alignment }) catch unreachable;
}
free(@as([*]align(Align) u8, @alignCast(@ptrCast(c_ptr))));
}
export fn roc_panic(msg: *RocStr, tag_id: u32) callconv(.C) void {
_ = tag_id;
const stderr = std.io.getStdErr().writer();
stderr.print("Application crashed with message\n\n {s}\n\nShutting down\n", .{msg.asSlice()}) catch unreachable;
std.process.exit(1);
}
export fn roc_dbg(loc: *RocStr, msg: *RocStr, src: *RocStr) callconv(.C) void {
// This platform uses stdout for testing purposes instead of the normal stderr.
const stdout = std.io.getStdOut().writer();
stdout.print("[{s}] {s} = {s}\n", .{ loc.asSlice(), src.asSlice(), msg.asSlice() }) catch unreachable;
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size);
}
extern fn kill(pid: c_int, sig: c_int) c_int;
extern fn shm_open(name: *const i8, oflag: c_int, mode: c_uint) c_int;
extern fn mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_int, offset: c_uint) *anyopaque;
extern fn getppid() c_int;
fn roc_getppid() callconv(.C) c_int {
return getppid();
}
fn roc_getppid_windows_stub() callconv(.C) c_int {
return 0;
}
fn roc_send_signal(pid: c_int, sig: c_int) callconv(.C) c_int {
return kill(pid, sig);
}
fn roc_shm_open(name: *const i8, oflag: c_int, mode: c_uint) callconv(.C) c_int {
return shm_open(name, oflag, mode);
}
fn roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_int, offset: c_uint) callconv(.C) *anyopaque {
return mmap(addr, length, prot, flags, fd, offset);
}
comptime {
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .Strong });
@export(roc_send_signal, .{ .name = "roc_send_signal", .linkage = .Strong });
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .Strong });
}
if (builtin.os.tag == .windows) {
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .Strong });
}
}
const mem = std.mem;
const Allocator = mem.Allocator;
extern fn roc__mainForHost_1_exposed_generic(*RocStr) void;
const Unit = extern struct {};
pub fn main() u8 {
const stdout = std.io.getStdOut().writer();
const stderr = std.io.getStdErr().writer();
var timer = std.time.Timer.start() catch unreachable;
// actually call roc to populate the callresult
var callresult = RocStr.empty();
roc__mainForHost_1_exposed_generic(&callresult);
const nanos = timer.read();
const seconds = (@as(f64, @floatFromInt(nanos)) / 1_000_000_000.0);
// stdout the result
stdout.print("{s}", .{callresult.asSlice()}) catch unreachable;
callresult.decref();
stderr.print("runtime: {d:.3}ms\n", .{seconds * 1000}) catch unreachable;
return 0;
}

View file

@ -0,0 +1,14 @@
platform "test"
requires {} { main : _ }
exposes []
packages {
foo: "../foo/main.roc",
}
imports []
provides [mainForHost]
import foo.Foo
mainForHost : Str
mainForHost =
"$(main) $(Foo.foo)"

View file

@ -1,4 +1,15 @@
module [Result, isOk, isErr, map, mapErr, try, onErr, withDefault] module [
Result,
isOk,
isErr,
map,
mapErr,
mapBoth,
map2,
try,
onErr,
withDefault,
]
import Bool exposing [Bool] import Bool exposing [Bool]
@ -67,6 +78,22 @@ mapErr = \result, transform ->
Ok v -> Ok v Ok v -> Ok v
Err e -> Err (transform e) Err e -> Err (transform e)
## Maps both the `Ok` and `Err` values of a `Result` to new values.
mapBoth : Result ok1 err1, (ok1 -> ok2), (err1 -> err2) -> Result ok2 err2
mapBoth = \result, okTransform, errTransform ->
when result is
Ok val -> Ok (okTransform val)
Err err -> Err (errTransform err)
## Maps the `Ok` values of two `Result`s to a new value using a given transformation,
## or returns the first `Err` value encountered.
map2 : Result a err, Result b err, (a, b -> c) -> Result c err
map2 = \firstResult, secondResult, transform ->
when (firstResult, secondResult) is
(Ok first, Ok second) -> Ok (transform first second)
(Err err, _) -> Err err
(_, Err err) -> Err err
## If the result is `Ok`, transforms the entire result by running a conversion ## If the result is `Ok`, transforms the entire result by running a conversion
## function on the value the `Ok` holds. Then returns that new result. If the ## function on the value the `Ok` holds. Then returns that new result. If the
## result is `Err`, this has no effect. Use `onErr` to transform an `Err`. ## result is `Err`, this has no effect. Use `onErr` to transform an `Err`.

View file

@ -1,6 +1,6 @@
use crate::env::Env; use crate::env::Env;
use crate::procedure::{QualifiedReference, References}; use crate::procedure::{QualifiedReference, References};
use crate::scope::{PendingAbilitiesInScope, Scope}; use crate::scope::{PendingAbilitiesInScope, Scope, SymbolLookup};
use roc_collections::{ImMap, MutSet, SendMap, VecMap, VecSet}; use roc_collections::{ImMap, MutSet, SendMap, VecMap, VecSet};
use roc_module::ident::{Ident, Lowercase, TagName}; use roc_module::ident::{Ident, Lowercase, TagName};
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
@ -386,7 +386,10 @@ pub(crate) fn make_apply_symbol(
// Look it up in scope! // Look it up in scope!
match scope.lookup_str(ident, region) { match scope.lookup_str(ident, region) {
Ok(symbol) => { Ok(SymbolLookup {
symbol,
module_params: _,
}) => {
references.insert_type_lookup(symbol, QualifiedReference::Unqualified); references.insert_type_lookup(symbol, QualifiedReference::Unqualified);
Ok(symbol) Ok(symbol)
} }
@ -398,7 +401,10 @@ pub(crate) fn make_apply_symbol(
} }
} else { } else {
match env.qualified_lookup(scope, module_name, ident, region) { match env.qualified_lookup(scope, module_name, ident, region) {
Ok(symbol) => { Ok(SymbolLookup {
symbol,
module_params: _,
}) => {
references.insert_type_lookup(symbol, QualifiedReference::Qualified); references.insert_type_lookup(symbol, QualifiedReference::Qualified);
Ok(symbol) Ok(symbol)
} }
@ -467,7 +473,8 @@ pub fn find_type_def_symbols(
while let Some(assigned_field) = inner_stack.pop() { while let Some(assigned_field) = inner_stack.pop() {
match assigned_field { match assigned_field {
AssignedField::RequiredValue(_, _, t) AssignedField::RequiredValue(_, _, t)
| AssignedField::OptionalValue(_, _, t) => { | AssignedField::OptionalValue(_, _, t)
| AssignedField::IgnoredValue(_, _, t) => {
stack.push(&t.value); stack.push(&t.value);
} }
AssignedField::LabelOnly(_) => {} AssignedField::LabelOnly(_) => {}
@ -1386,6 +1393,7 @@ fn can_assigned_fields<'a>(
break 'inner label; break 'inner label;
} }
IgnoredValue(_, _, _) => unreachable!(),
LabelOnly(loc_field_name) => { LabelOnly(loc_field_name) => {
// Interpret { a, b } as { a : a, b : b } // Interpret { a, b } as { a : a, b : b }
let field_name = Lowercase::from(loc_field_name.value); let field_name = Lowercase::from(loc_field_name.value);

View file

@ -602,7 +602,8 @@ impl Constraints {
| Constraint::Exhaustive { .. } | Constraint::Exhaustive { .. }
| Constraint::Resolve(..) | Constraint::Resolve(..)
| Constraint::IngestedFile(..) | Constraint::IngestedFile(..)
| Constraint::CheckCycle(..) => false, | Constraint::CheckCycle(..)
| Constraint::ImportParams(..) => false,
} }
} }
@ -685,6 +686,15 @@ impl Constraints {
) -> Constraint { ) -> Constraint {
Constraint::IngestedFile(type_index, file_path, bytes) Constraint::IngestedFile(type_index, file_path, bytes)
} }
pub fn import_params(
&mut self,
opt_type_index: Option<TypeOrVar>,
module_id: ModuleId,
region: Region,
) -> Constraint {
Constraint::ImportParams(opt_type_index, module_id, region)
}
} }
roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8); roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8);
@ -787,6 +797,7 @@ pub enum Constraint {
CheckCycle(Index<Cycle>, IllegalCycleMark), CheckCycle(Index<Cycle>, IllegalCycleMark),
IngestedFile(TypeOrVar, Box<PathBuf>, Arc<Vec<u8>>), IngestedFile(TypeOrVar, Box<PathBuf>, Arc<Vec<u8>>),
ImportParams(Option<TypeOrVar>, ModuleId, Region),
} }
#[derive(Debug, Clone, Copy, Default)] #[derive(Debug, Clone, Copy, Default)]
@ -865,6 +876,9 @@ impl std::fmt::Debug for Constraint {
Self::IngestedFile(arg0, arg1, arg2) => { Self::IngestedFile(arg0, arg1, arg2) => {
write!(f, "IngestedFile({arg0:?}, {arg1:?}, {arg2:?})") write!(f, "IngestedFile({arg0:?}, {arg1:?}, {arg2:?})")
} }
Self::ImportParams(arg0, arg1, arg2) => {
write!(f, "ImportParams({arg0:?}, {arg1:?}, {arg2:?})")
}
} }
} }
} }

View file

@ -288,6 +288,22 @@ fn deep_copy_expr_help<C: CopyEnv>(env: &mut C, copied: &mut Vec<Variable>, expr
loc_elems: loc_elems.iter().map(|le| le.map(|e| go_help!(e))).collect(), loc_elems: loc_elems.iter().map(|le| le.map(|e| go_help!(e))).collect(),
}, },
Var(sym, var) => Var(*sym, sub!(*var)), Var(sym, var) => Var(*sym, sub!(*var)),
ParamsVar {
symbol,
params,
var,
} => ParamsVar {
symbol: *symbol,
params: *params,
var: sub!(*var),
},
ImportParams(module_id, region, opt_provided) => ImportParams(
*module_id,
*region,
opt_provided
.as_ref()
.map(|(var, expr)| (sub!(*var), Box::new(go_help!(&expr)))),
),
&AbilityMember(sym, specialization, specialization_var) => { &AbilityMember(sym, specialization, specialization_var) => {
AbilityMember(sym, specialization, sub!(specialization_var)) AbilityMember(sym, specialization, sub!(specialization_var))
} }

View file

@ -206,7 +206,13 @@ fn expr<'a>(c: &Ctx, p: EPrec, f: &'a Arena<'a>, e: &'a Expr) -> DocBuilder<'a,
.append("]") .append("]")
.group(), .group(),
), ),
Var(sym, _) | AbilityMember(sym, _, _) => pp_sym(c, f, *sym), Var(sym, _) | ParamsVar { symbol: sym, .. } | AbilityMember(sym, _, _) => {
pp_sym(c, f, *sym)
}
ImportParams(_, _, Some((_, params_expr))) => expr(c, p, f, params_expr),
ImportParams(module_id, _, None) => {
text!(f, "<no params for {:?}>", module_id)
}
When { When {
loc_cond, branches, .. loc_cond, branches, ..
} => maybe_paren!( } => maybe_paren!(

View file

@ -10,6 +10,7 @@ use crate::annotation::IntroducedVariables;
use crate::annotation::OwnedNamedOrAble; use crate::annotation::OwnedNamedOrAble;
use crate::derive; use crate::derive;
use crate::env::Env; use crate::env::Env;
use crate::expr::canonicalize_record;
use crate::expr::get_lookup_symbols; use crate::expr::get_lookup_symbols;
use crate::expr::AnnotatedMark; use crate::expr::AnnotatedMark;
use crate::expr::ClosureData; use crate::expr::ClosureData;
@ -18,6 +19,7 @@ use crate::expr::Expr::{self, *};
use crate::expr::StructAccessorData; use crate::expr::StructAccessorData;
use crate::expr::{canonicalize_expr, Output, Recursive}; use crate::expr::{canonicalize_expr, Output, Recursive};
use crate::pattern::{canonicalize_def_header_pattern, BindingsFromPattern, Pattern}; use crate::pattern::{canonicalize_def_header_pattern, BindingsFromPattern, Pattern};
use crate::procedure::QualifiedReference;
use crate::procedure::References; use crate::procedure::References;
use crate::scope::create_alias; use crate::scope::create_alias;
use crate::scope::{PendingAbilitiesInScope, Scope}; use crate::scope::{PendingAbilitiesInScope, Scope};
@ -160,6 +162,13 @@ enum PendingValueDef<'a> {
&'a Loc<ast::TypeAnnotation<'a>>, &'a Loc<ast::TypeAnnotation<'a>>,
&'a Loc<ast::Expr<'a>>, &'a Loc<ast::Expr<'a>>,
), ),
/// Module params from an import
ImportParams {
symbol: Symbol,
loc_pattern: Loc<Pattern>,
module_id: ModuleId,
opt_provided: Option<ast::Collection<'a, Loc<AssignedField<'a, ast::Expr<'a>>>>>,
},
/// Ingested file /// Ingested file
IngestedFile( IngestedFile(
Loc<Pattern>, Loc<Pattern>,
@ -174,6 +183,12 @@ impl PendingValueDef<'_> {
PendingValueDef::AnnotationOnly(loc_pattern, _) => loc_pattern, PendingValueDef::AnnotationOnly(loc_pattern, _) => loc_pattern,
PendingValueDef::Body(loc_pattern, _) => loc_pattern, PendingValueDef::Body(loc_pattern, _) => loc_pattern,
PendingValueDef::TypedBody(_, loc_pattern, _, _) => loc_pattern, PendingValueDef::TypedBody(_, loc_pattern, _, _) => loc_pattern,
PendingValueDef::ImportParams {
loc_pattern,
symbol: _,
module_id: _,
opt_provided: _,
} => loc_pattern,
PendingValueDef::IngestedFile(loc_pattern, _, _) => loc_pattern, PendingValueDef::IngestedFile(loc_pattern, _, _) => loc_pattern,
} }
} }
@ -485,6 +500,16 @@ fn canonicalize_alias<'a>(
} }
} }
#[macro_export]
macro_rules! params_in_abilities_unimplemented {
($lookup:expr) => {
match $lookup.module_params {
None => $lookup.symbol,
Some(_) => unimplemented!("params in abilities"),
}
};
}
/// Canonicalizes a claimed ability implementation like `{ eq }` or `{ eq: myEq }`. /// Canonicalizes a claimed ability implementation like `{ eq }` or `{ eq: myEq }`.
/// Returns a mapping of the ability member to the implementation symbol. /// Returns a mapping of the ability member to the implementation symbol.
/// If there was an error, a problem will be recorded and nothing is returned. /// If there was an error, a problem will be recorded and nothing is returned.
@ -503,7 +528,7 @@ fn canonicalize_claimed_ability_impl<'a>(
let member_symbol = let member_symbol =
match env.qualified_lookup_with_module_id(scope, ability_home, label_str, region) { match env.qualified_lookup_with_module_id(scope, ability_home, label_str, region) {
Ok(symbol) => symbol, Ok(lookup) => params_in_abilities_unimplemented!(lookup),
Err(_) => { Err(_) => {
env.problem(Problem::NotAnAbilityMember { env.problem(Problem::NotAnAbilityMember {
ability, ability,
@ -546,8 +571,13 @@ fn canonicalize_claimed_ability_impl<'a>(
// To handle both cases, try checking for a shadow first, then check for a direct // To handle both cases, try checking for a shadow first, then check for a direct
// reference. We want to check for a direct reference second so that if there is a // reference. We want to check for a direct reference second so that if there is a
// shadow, we won't accidentally grab the imported symbol. // shadow, we won't accidentally grab the imported symbol.
let opt_impl_symbol = (scope.lookup_ability_member_shadow(member_symbol)) let opt_impl_symbol =
.or_else(|| scope.lookup_str(label_str, region).ok()); (scope.lookup_ability_member_shadow(member_symbol)).or_else(|| {
scope
.lookup_str(label_str, region)
.map(|s| params_in_abilities_unimplemented!(s))
.ok()
});
match opt_impl_symbol { match opt_impl_symbol {
// It's possible that even if we find a symbol it is still only the member // It's possible that even if we find a symbol it is still only the member
@ -599,7 +629,7 @@ fn canonicalize_claimed_ability_impl<'a>(
label.value, label.value,
label.region, label.region,
) { ) {
Ok(symbol) => symbol, Ok(lookup) => params_in_abilities_unimplemented!(lookup),
Err(_) => { Err(_) => {
env.problem(Problem::NotAnAbilityMember { env.problem(Problem::NotAnAbilityMember {
ability, ability,
@ -611,7 +641,7 @@ fn canonicalize_claimed_ability_impl<'a>(
}; };
let impl_symbol = match scope.lookup(&impl_ident.into(), impl_region) { let impl_symbol = match scope.lookup(&impl_ident.into(), impl_region) {
Ok(symbol) => symbol, Ok(symbol) => params_in_abilities_unimplemented!(symbol),
Err(err) => { Err(err) => {
env.problem(Problem::RuntimeError(err)); env.problem(Problem::RuntimeError(err));
return Err(()); return Err(());
@ -631,7 +661,9 @@ fn canonicalize_claimed_ability_impl<'a>(
// An error will already have been reported // An error will already have been reported
Err(()) Err(())
} }
AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => { AssignedField::SpaceBefore(_, _)
| AssignedField::SpaceAfter(_, _)
| AssignedField::IgnoredValue(_, _, _) => {
internal_error!("unreachable") internal_error!("unreachable")
} }
} }
@ -1107,8 +1139,24 @@ fn canonicalize_value_defs<'a>(
PendingValue::ExpectFx(pending_expect) => { PendingValue::ExpectFx(pending_expect) => {
pending_expect_fx.push(pending_expect); pending_expect_fx.push(pending_expect);
} }
PendingValue::ModuleImport(introduced_import) => { PendingValue::ModuleImport(PendingModuleImport {
imports_introduced.push(introduced_import); module_id,
region,
exposed_symbols,
params,
}) => {
imports_introduced.push(IntroducedImport {
module_id,
region,
exposed_symbols,
});
pending_value_defs.push(PendingValueDef::ImportParams {
symbol: params.symbol,
loc_pattern: params.loc_pattern,
opt_provided: params.opt_provided,
module_id,
});
} }
PendingValue::InvalidIngestedFile => { /* skip */ } PendingValue::InvalidIngestedFile => { /* skip */ }
PendingValue::ImportNameConflict => { /* skip */ } PendingValue::ImportNameConflict => { /* skip */ }
@ -1556,7 +1604,7 @@ impl DefOrdering {
fn insert_symbol_references(&mut self, def_id: u32, def_references: &DefReferences) { fn insert_symbol_references(&mut self, def_id: u32, def_references: &DefReferences) {
match def_references { match def_references {
DefReferences::Value(references) => { DefReferences::Value(references) => {
let it = references.value_lookups().chain(references.calls()); let it = references.value_lookups();
for referenced in it { for referenced in it {
if let Some(ref_id) = self.get_id(*referenced) { if let Some(ref_id) = self.get_id(*referenced) {
@ -2350,6 +2398,50 @@ fn canonicalize_pending_value_def<'a>(
None, None,
) )
} }
ImportParams {
symbol,
loc_pattern,
module_id,
opt_provided,
} => {
// Insert a reference to the record so that we don't report it as unused
// If the whole module is unused, we'll report that separately
output
.references
.insert_value_lookup(symbol, QualifiedReference::Unqualified);
let (opt_var_record, references) = match opt_provided {
Some(params) => {
let (record, can_output) =
canonicalize_record(env, var_store, scope, loc_pattern.region, params);
let references = can_output.references.clone();
output.union(can_output);
(Some((var_store.fresh(), Box::new(record))), references)
}
None => (None, References::new()),
};
let loc_expr = Loc::at(
loc_pattern.region,
Expr::ImportParams(module_id, loc_pattern.region, opt_var_record),
);
let def = single_can_def(
loc_pattern,
loc_expr,
var_store.fresh(),
None,
SendMap::default(),
);
DefOutput {
output,
references: DefReferences::Value(references),
def,
}
}
IngestedFile(loc_pattern, opt_loc_ann, path_literal) => { IngestedFile(loc_pattern, opt_loc_ann, path_literal) => {
let relative_path = let relative_path =
if let ast::StrLiteral::PlainLine(ingested_path) = path_literal.value { if let ast::StrLiteral::PlainLine(ingested_path) = path_literal.value {
@ -2891,7 +2983,7 @@ enum PendingValue<'a> {
Dbg(PendingExpectOrDbg<'a>), Dbg(PendingExpectOrDbg<'a>),
Expect(PendingExpectOrDbg<'a>), Expect(PendingExpectOrDbg<'a>),
ExpectFx(PendingExpectOrDbg<'a>), ExpectFx(PendingExpectOrDbg<'a>),
ModuleImport(IntroducedImport), ModuleImport(PendingModuleImport<'a>),
SignatureDefMismatch, SignatureDefMismatch,
InvalidIngestedFile, InvalidIngestedFile,
ImportNameConflict, ImportNameConflict,
@ -2902,6 +2994,19 @@ struct PendingExpectOrDbg<'a> {
preceding_comment: Region, preceding_comment: Region,
} }
struct PendingModuleImport<'a> {
module_id: ModuleId,
region: Region,
exposed_symbols: Vec<(Symbol, Region)>,
params: PendingModuleImportParams<'a>,
}
struct PendingModuleImportParams<'a> {
symbol: Symbol,
loc_pattern: Loc<Pattern>,
opt_provided: Option<ast::Collection<'a, Loc<AssignedField<'a, ast::Expr<'a>>>>>,
}
pub struct IntroducedImport { pub struct IntroducedImport {
module_id: ModuleId, module_id: ModuleId,
region: Region, region: Region,
@ -3051,10 +3156,27 @@ fn to_pending_value_def<'a>(
None => module_name.clone(), None => module_name.clone(),
}; };
// Generate a symbol for the module params def
// We do this even if params weren't provided so that solve can report if they are missing
let params_sym = scope.gen_unique_symbol();
let params_region = module_import.params.map(|p| p.params.region).unwrap_or(region);
let params =
PendingModuleImportParams {
symbol: params_sym,
loc_pattern: Loc::at(params_region, Pattern::Identifier(params_sym)),
opt_provided: module_import.params.map(|p| p.params.value),
};
let provided_params_sym = if module_import.params.is_some() {
// Only add params to scope if they are provided
Some(params_sym)
} else {
None
};
if let Err(existing_import) = if let Err(existing_import) =
scope scope
.modules .modules
.insert(name_with_alias.clone(), module_id, region) .insert(name_with_alias.clone(), module_id, provided_params_sym, region)
{ {
env.problems.push(Problem::ImportNameConflict { env.problems.push(Problem::ImportNameConflict {
name: name_with_alias, name: name_with_alias,
@ -3065,7 +3187,7 @@ fn to_pending_value_def<'a>(
}); });
return PendingValue::ImportNameConflict; return PendingValue::ImportNameConflict;
} };
let exposed_names = module_import let exposed_names = module_import
.exposed .exposed
@ -3117,13 +3239,13 @@ fn to_pending_value_def<'a>(
})) }))
} }
} }
} }
PendingValue::ModuleImport(IntroducedImport { PendingValue::ModuleImport(PendingModuleImport {
module_id, module_id,
region, region,
exposed_symbols, exposed_symbols,
params,
}) })
} }
IngestedFileImport(ingested_file) => { IngestedFileImport(ingested_file) => {

View file

@ -140,7 +140,9 @@ fn desugar_value_def<'a>(
let desugared_params = let desugared_params =
params.map(|ModuleImportParams { before, params }| ModuleImportParams { params.map(|ModuleImportParams { before, params }| ModuleImportParams {
before, before,
params: desugar_field_collection(arena, params, src, line_info, module_path), params: params.map(|params| {
desugar_field_collection(arena, *params, src, line_info, module_path)
}),
}); });
ModuleImport(roc_parse::ast::ModuleImport { ModuleImport(roc_parse::ast::ModuleImport {
@ -521,25 +523,34 @@ pub fn desugar_expr<'a>(
}); });
} }
let mut field_names = Vec::with_capacity_in(fields.len(), arena); struct FieldData<'d> {
let mut field_vals = Vec::with_capacity_in(fields.len(), arena); name: Loc<&'d str>,
value: &'d Loc<Expr<'d>>,
ignored: bool,
}
let mut field_data = Vec::with_capacity_in(fields.len(), arena);
for field in fields.items { for field in fields.items {
let (name, value, ignored) =
match desugar_field(arena, &field.value, src, line_info, module_path) { match desugar_field(arena, &field.value, src, line_info, module_path) {
AssignedField::RequiredValue(loc_name, _, loc_val) => { AssignedField::RequiredValue(loc_name, _, loc_val) => {
field_names.push(loc_name); (loc_name, loc_val, false)
field_vals.push(loc_val);
} }
AssignedField::LabelOnly(loc_name) => { AssignedField::IgnoredValue(loc_name, _, loc_val) => {
field_names.push(loc_name); (loc_name, loc_val, true)
field_vals.push(arena.alloc(Loc { }
AssignedField::LabelOnly(loc_name) => (
loc_name,
&*arena.alloc(Loc {
region: loc_name.region, region: loc_name.region,
value: Expr::Var { value: Expr::Var {
module_name: "", module_name: "",
ident: loc_name.value, ident: loc_name.value,
}, },
})); }),
} false,
),
AssignedField::OptionalValue(loc_name, _, loc_val) => { AssignedField::OptionalValue(loc_name, _, loc_val) => {
return arena.alloc(Loc { return arena.alloc(Loc {
region: loc_expr.region, region: loc_expr.region,
@ -549,14 +560,29 @@ pub fn desugar_expr<'a>(
AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => { AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => {
unreachable!("Should have been desugared in `desugar_field`") unreachable!("Should have been desugared in `desugar_field`")
} }
AssignedField::Malformed(_name) => {} AssignedField::Malformed(_name) => continue,
} };
field_data.push(FieldData {
name,
value,
ignored,
});
} }
let closure_arg_from_field = |field: Loc<&'a str>| Loc { let closure_arg_from_field =
region: field.region, |FieldData {
value: Pattern::Identifier { name,
ident: arena.alloc_str(&format!("#{}", field.value)), value: _,
ignored,
}: &FieldData<'a>| Loc {
region: name.region,
value: if *ignored {
Pattern::Underscore(name.value)
} else {
Pattern::Identifier {
ident: arena.alloc_str(&format!("#{}", name.value)),
}
}, },
}; };
@ -607,15 +633,15 @@ pub fn desugar_expr<'a>(
}; };
let closure_args = { let closure_args = {
if field_names.len() == 2 { if field_data.len() == 2 {
arena.alloc_slice_copy(&[ arena.alloc_slice_copy(&[
closure_arg_from_field(field_names[0]), closure_arg_from_field(&field_data[0]),
closure_arg_from_field(field_names[1]), closure_arg_from_field(&field_data[1]),
]) ])
} else { } else {
let second_to_last_arg = let second_to_last_arg =
closure_arg_from_field(field_names[field_names.len() - 2]); closure_arg_from_field(&field_data[field_data.len() - 2]);
let last_arg = closure_arg_from_field(field_names[field_names.len() - 1]); let last_arg = closure_arg_from_field(&field_data[field_data.len() - 1]);
let mut second_arg = Pattern::Tuple(Collection::with_items( let mut second_arg = Pattern::Tuple(Collection::with_items(
arena.alloc_slice_copy(&[second_to_last_arg, last_arg]), arena.alloc_slice_copy(&[second_to_last_arg, last_arg]),
@ -623,18 +649,18 @@ pub fn desugar_expr<'a>(
let mut second_arg_region = let mut second_arg_region =
Region::span_across(&second_to_last_arg.region, &last_arg.region); Region::span_across(&second_to_last_arg.region, &last_arg.region);
for index in (1..(field_names.len() - 2)).rev() { for index in (1..(field_data.len() - 2)).rev() {
second_arg = second_arg =
Pattern::Tuple(Collection::with_items(arena.alloc_slice_copy(&[ Pattern::Tuple(Collection::with_items(arena.alloc_slice_copy(&[
closure_arg_from_field(field_names[index]), closure_arg_from_field(&field_data[index]),
Loc::at(second_arg_region, second_arg), Loc::at(second_arg_region, second_arg),
]))); ])));
second_arg_region = second_arg_region =
Region::span_across(&field_names[index].region, &second_arg_region); Region::span_across(&field_data[index].name.region, &second_arg_region);
} }
arena.alloc_slice_copy(&[ arena.alloc_slice_copy(&[
closure_arg_from_field(field_names[0]), closure_arg_from_field(&field_data[0]),
Loc::at(second_arg_region, second_arg), Loc::at(second_arg_region, second_arg),
]) ])
} }
@ -642,17 +668,21 @@ pub fn desugar_expr<'a>(
let record_val = Record(Collection::with_items( let record_val = Record(Collection::with_items(
Vec::from_iter_in( Vec::from_iter_in(
field_names.iter().map(|field_name| { field_data
.iter()
.filter(|field| !field.ignored)
.map(|field| {
Loc::at( Loc::at(
field_name.region, field.name.region,
AssignedField::RequiredValue( AssignedField::RequiredValue(
Loc::at(field_name.region, field_name.value), field.name,
&[], &[],
arena.alloc(Loc::at( arena.alloc(Loc::at(
field_name.region, field.name.region,
Expr::Var { Expr::Var {
module_name: "", module_name: "",
ident: arena.alloc_str(&format!("#{}", field_name.value)), ident: arena
.alloc_str(&format!("#{}", field.name.value)),
}, },
)), )),
), ),
@ -671,14 +701,14 @@ pub fn desugar_expr<'a>(
), ),
}); });
if field_names.len() == 2 { if field_data.len() == 2 {
return arena.alloc(Loc { return arena.alloc(Loc {
region: loc_expr.region, region: loc_expr.region,
value: Apply( value: Apply(
new_mapper, new_mapper,
arena.alloc_slice_copy(&[ arena.alloc_slice_copy(&[
field_vals[0], field_data[0].value,
field_vals[1], field_data[1].value,
record_combiner_closure, record_combiner_closure,
]), ]),
CalledVia::RecordBuilder, CalledVia::RecordBuilder,
@ -688,27 +718,30 @@ pub fn desugar_expr<'a>(
let mut inner_combined = arena.alloc(Loc { let mut inner_combined = arena.alloc(Loc {
region: Region::span_across( region: Region::span_across(
&field_vals[field_names.len() - 2].region, &field_data[field_data.len() - 2].value.region,
&field_vals[field_names.len() - 1].region, &field_data[field_data.len() - 1].value.region,
), ),
value: Apply( value: Apply(
new_mapper, new_mapper,
arena.alloc_slice_copy(&[ arena.alloc_slice_copy(&[
field_vals[field_names.len() - 2], field_data[field_data.len() - 2].value,
field_vals[field_names.len() - 1], field_data[field_data.len() - 1].value,
combiner_closure_in_region(loc_expr.region), combiner_closure_in_region(loc_expr.region),
]), ]),
CalledVia::RecordBuilder, CalledVia::RecordBuilder,
), ),
}); });
for index in (1..(field_names.len() - 2)).rev() { for index in (1..(field_data.len() - 2)).rev() {
inner_combined = arena.alloc(Loc { inner_combined = arena.alloc(Loc {
region: Region::span_across(&field_vals[index].region, &inner_combined.region), region: Region::span_across(
&field_data[index].value.region,
&inner_combined.region,
),
value: Apply( value: Apply(
new_mapper, new_mapper,
arena.alloc_slice_copy(&[ arena.alloc_slice_copy(&[
field_vals[index], field_data[index].value,
inner_combined, inner_combined,
combiner_closure_in_region(loc_expr.region), combiner_closure_in_region(loc_expr.region),
]), ]),
@ -722,7 +755,7 @@ pub fn desugar_expr<'a>(
value: Apply( value: Apply(
new_mapper, new_mapper,
arena.alloc_slice_copy(&[ arena.alloc_slice_copy(&[
field_vals[0], field_data[0].value,
inner_combined, inner_combined,
record_combiner_closure, record_combiner_closure,
]), ]),
@ -1095,6 +1128,14 @@ fn desugar_field<'a>(
spaces, spaces,
desugar_expr(arena, loc_expr, src, line_info, module_path), desugar_expr(arena, loc_expr, src, line_info, module_path),
), ),
IgnoredValue(loc_str, spaces, loc_expr) => IgnoredValue(
Loc {
value: loc_str.value,
region: loc_str.region,
},
spaces,
desugar_expr(arena, loc_expr, src, line_info, module_path),
),
LabelOnly(loc_str) => { LabelOnly(loc_str) => {
// Desugar { x } into { x: x } // Desugar { x } into { x: x }
let loc_expr = Loc { let loc_expr = Loc {

View file

@ -1,7 +1,7 @@
use std::path::Path; use std::path::Path;
use crate::procedure::References; use crate::procedure::References;
use crate::scope::Scope; use crate::scope::{ModuleLookup, Scope, SymbolLookup};
use bumpalo::Bump; use bumpalo::Bump;
use roc_collections::{MutMap, VecSet}; use roc_collections::{MutMap, VecSet};
use roc_module::ident::{Ident, ModuleName}; use roc_module::ident::{Ident, ModuleName};
@ -74,7 +74,7 @@ impl<'a> Env<'a> {
module_name_str: &str, module_name_str: &str,
ident: &str, ident: &str,
region: Region, region: Region,
) -> Result<Symbol, RuntimeError> { ) -> Result<SymbolLookup, RuntimeError> {
debug_assert!( debug_assert!(
!module_name_str.is_empty(), !module_name_str.is_empty(),
"Called env.qualified_lookup with an unqualified ident: {ident:?}" "Called env.qualified_lookup with an unqualified ident: {ident:?}"
@ -82,8 +82,10 @@ impl<'a> Env<'a> {
let module_name = ModuleName::from(module_name_str); let module_name = ModuleName::from(module_name_str);
match scope.modules.get_id(&module_name) { match scope.modules.lookup(&module_name) {
Some(module_id) => self.qualified_lookup_help(scope, module_id, ident, region), Some(lookedup_module) => {
self.qualified_lookup_help(scope, lookedup_module, ident, region)
}
None => Err(RuntimeError::ModuleNotImported { None => Err(RuntimeError::ModuleNotImported {
module_name: module_name.clone(), module_name: module_name.clone(),
imported_modules: scope imported_modules: scope
@ -106,11 +108,11 @@ impl<'a> Env<'a> {
module_id: ModuleId, module_id: ModuleId,
ident: &str, ident: &str,
region: Region, region: Region,
) -> Result<Symbol, RuntimeError> { ) -> Result<SymbolLookup, RuntimeError> {
if !scope.modules.has_id(module_id) { if let Some(module) = scope.modules.lookup_by_id(&module_id) {
Err(self.module_exists_but_not_imported(scope, module_id, region)) self.qualified_lookup_help(scope, module, ident, region)
} else { } else {
self.qualified_lookup_help(scope, module_id, ident, region) Err(self.module_exists_but_not_imported(scope, module_id, region))
} }
} }
@ -118,18 +120,18 @@ impl<'a> Env<'a> {
fn qualified_lookup_help( fn qualified_lookup_help(
&mut self, &mut self,
scope: &Scope, scope: &Scope,
module_id: ModuleId, module: ModuleLookup,
ident: &str, ident: &str,
region: Region, region: Region,
) -> Result<Symbol, RuntimeError> { ) -> Result<SymbolLookup, RuntimeError> {
let is_type_name = ident.starts_with(|c: char| c.is_uppercase()); let is_type_name = ident.starts_with(|c: char| c.is_uppercase());
// You can do qualified lookups on your own module, e.g. // You can do qualified lookups on your own module, e.g.
// if I'm in the Foo module, I can do a `Foo.bar` lookup. // if I'm in the Foo module, I can do a `Foo.bar` lookup.
if module_id == self.home { if module.id == self.home {
match scope.locals.ident_ids.get_id(ident) { match scope.locals.ident_ids.get_id(ident) {
Some(ident_id) => { Some(ident_id) => {
let symbol = Symbol::new(module_id, ident_id); let symbol = Symbol::new(module.id, ident_id);
if is_type_name { if is_type_name {
self.qualified_type_lookups.insert(symbol); self.qualified_type_lookups.insert(symbol);
@ -137,7 +139,7 @@ impl<'a> Env<'a> {
self.qualified_value_lookups.insert(symbol); self.qualified_value_lookups.insert(symbol);
} }
Ok(symbol) Ok(SymbolLookup::no_params(symbol))
} }
None => { None => {
let error = RuntimeError::LookupNotInScope { let error = RuntimeError::LookupNotInScope {
@ -157,10 +159,10 @@ impl<'a> Env<'a> {
} }
} }
} else { } else {
match self.dep_idents.get(&module_id) { match self.dep_idents.get(&module.id) {
Some(exposed_ids) => match exposed_ids.get_id(ident) { Some(exposed_ids) => match exposed_ids.get_id(ident) {
Some(ident_id) => { Some(ident_id) => {
let symbol = Symbol::new(module_id, ident_id); let symbol = Symbol::new(module.id, ident_id);
if is_type_name { if is_type_name {
self.qualified_type_lookups.insert(symbol); self.qualified_type_lookups.insert(symbol);
@ -168,12 +170,12 @@ impl<'a> Env<'a> {
self.qualified_value_lookups.insert(symbol); self.qualified_value_lookups.insert(symbol);
} }
Ok(symbol) Ok(module.into_symbol(symbol))
} }
None => Err(RuntimeError::ValueNotExposed { None => Err(RuntimeError::ValueNotExposed {
module_name: self module_name: self
.qualified_module_ids .qualified_module_ids
.get_name(module_id) .get_name(module.id)
.expect("Module ID known, but not in the module IDs somehow") .expect("Module ID known, but not in the module IDs somehow")
.as_inner() .as_inner()
.clone(), .clone(),
@ -182,7 +184,7 @@ impl<'a> Env<'a> {
exposed_values: exposed_ids.exposed_values(), exposed_values: exposed_ids.exposed_values(),
}), }),
}, },
_ => Err(self.module_exists_but_not_imported(scope, module_id, region)), _ => Err(self.module_exists_but_not_imported(scope, module.id, region)),
} }
} }
} }

View file

@ -7,9 +7,10 @@ use crate::num::{
finish_parsing_base, finish_parsing_float, finish_parsing_num, float_expr_from_result, finish_parsing_base, finish_parsing_float, finish_parsing_num, float_expr_from_result,
int_expr_from_result, num_expr_from_result, FloatBound, IntBound, NumBound, int_expr_from_result, num_expr_from_result, FloatBound, IntBound, NumBound,
}; };
use crate::params_in_abilities_unimplemented;
use crate::pattern::{canonicalize_pattern, BindingsFromPattern, Pattern, PermitShadows}; use crate::pattern::{canonicalize_pattern, BindingsFromPattern, Pattern, PermitShadows};
use crate::procedure::{QualifiedReference, References}; use crate::procedure::{QualifiedReference, References};
use crate::scope::Scope; use crate::scope::{Scope, SymbolLookup};
use crate::traverse::{walk_expr, Visitor}; use crate::traverse::{walk_expr, Visitor};
use roc_collections::soa::Index; use roc_collections::soa::Index;
use roc_collections::{SendMap, VecMap, VecSet}; use roc_collections::{SendMap, VecMap, VecSet};
@ -17,7 +18,7 @@ use roc_error_macros::internal_error;
use roc_module::called_via::CalledVia; use roc_module::called_via::CalledVia;
use roc_module::ident::{ForeignSymbol, Lowercase, TagName}; use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
use roc_module::low_level::LowLevel; use roc_module::low_level::LowLevel;
use roc_module::symbol::Symbol; use roc_module::symbol::{ModuleId, Symbol};
use roc_parse::ast::{self, Defs, PrecedenceConflict, StrLiteral}; use roc_parse::ast::{self, Defs, PrecedenceConflict, StrLiteral};
use roc_parse::ident::Accessor; use roc_parse::ident::Accessor;
use roc_parse::pattern::PatternType::*; use roc_parse::pattern::PatternType::*;
@ -107,6 +108,12 @@ pub enum Expr {
// Lookups // Lookups
Var(Symbol, Variable), Var(Symbol, Variable),
/// Like Var, but from a module with params
ParamsVar {
symbol: Symbol,
params: Symbol,
var: Variable,
},
AbilityMember( AbilityMember(
/// Actual member name /// Actual member name
Symbol, Symbol,
@ -177,6 +184,9 @@ pub enum Expr {
elems: Vec<(Variable, Box<Loc<Expr>>)>, elems: Vec<(Variable, Box<Loc<Expr>>)>,
}, },
/// Module params expression in import
ImportParams(ModuleId, Region, Option<(Variable, Box<Expr>)>),
/// The "crash" keyword /// The "crash" keyword
Crash { Crash {
msg: Box<Loc<Expr>>, msg: Box<Loc<Expr>>,
@ -308,6 +318,11 @@ impl Expr {
Self::SingleQuote(..) => Category::Character, Self::SingleQuote(..) => Category::Character,
Self::List { .. } => Category::List, Self::List { .. } => Category::List,
&Self::Var(sym, _) => Category::Lookup(sym), &Self::Var(sym, _) => Category::Lookup(sym),
&Self::ParamsVar {
symbol,
params: _,
var: _,
} => Category::Lookup(symbol),
&Self::AbilityMember(sym, _, _) => Category::Lookup(sym), &Self::AbilityMember(sym, _, _) => Category::Lookup(sym),
Self::When { .. } => Category::When, Self::When { .. } => Category::When,
Self::If { .. } => Category::If, Self::If { .. } => Category::If,
@ -324,6 +339,8 @@ impl Expr {
Self::RecordAccessor(data) => Category::Accessor(data.field.clone()), Self::RecordAccessor(data) => Category::Accessor(data.field.clone()),
Self::TupleAccess { index, .. } => Category::TupleAccess(*index), Self::TupleAccess { index, .. } => Category::TupleAccess(*index),
Self::RecordUpdate { .. } => Category::Record, Self::RecordUpdate { .. } => Category::Record,
Self::ImportParams(_, _, Some((_, expr))) => expr.category(),
Self::ImportParams(_, _, None) => Category::Unknown,
Self::Tag { Self::Tag {
name, arguments, .. name, arguments, ..
} => Category::TagApply { } => Category::TagApply {
@ -632,33 +649,8 @@ pub fn canonicalize_expr<'a>(
(answer, Output::default()) (answer, Output::default())
} }
ast::Expr::Record(fields) => { ast::Expr::Record(fields) => {
if fields.is_empty() { canonicalize_record(env, var_store, scope, region, *fields)
(EmptyRecord, Output::default())
} else {
match canonicalize_fields(env, var_store, scope, region, fields.items) {
Ok((can_fields, output)) => (
Record {
record_var: var_store.fresh(),
fields: can_fields,
},
output,
),
Err(CanonicalizeRecordProblem::InvalidOptionalValue {
field_name,
field_region,
record_region,
}) => (
Expr::RuntimeError(roc_problem::can::RuntimeError::InvalidOptionalValue {
field_name,
field_region,
record_region,
}),
Output::default(),
),
} }
}
}
ast::Expr::RecordUpdate { ast::Expr::RecordUpdate {
fields, fields,
update: loc_update, update: loc_update,
@ -1452,6 +1444,42 @@ pub fn canonicalize_expr<'a>(
) )
} }
pub fn canonicalize_record<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
scope: &mut Scope,
region: Region,
fields: ast::Collection<'a, Loc<ast::AssignedField<'a, ast::Expr<'a>>>>,
) -> (Expr, Output) {
use Expr::*;
if fields.is_empty() {
(EmptyRecord, Output::default())
} else {
match canonicalize_fields(env, var_store, scope, region, fields.items) {
Ok((can_fields, output)) => (
Record {
record_var: var_store.fresh(),
fields: can_fields,
},
output,
),
Err(CanonicalizeRecordProblem::InvalidOptionalValue {
field_name,
field_region,
record_region,
}) => (
Expr::RuntimeError(roc_problem::can::RuntimeError::InvalidOptionalValue {
field_name,
field_region,
record_region,
}),
Output::default(),
),
}
}
}
pub fn canonicalize_closure<'a>( pub fn canonicalize_closure<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
var_store: &mut VarStore, var_store: &mut VarStore,
@ -1846,6 +1874,11 @@ fn canonicalize_field<'a>(
field_region: Region::span_across(&label.region, &loc_expr.region), field_region: Region::span_across(&label.region, &loc_expr.region),
}), }),
// An ignored value, e.g. `{ _name: 123 }`
IgnoredValue(_, _, _) => {
internal_error!("Somehow an IgnoredValue record field was not desugared!");
}
// A label with no value, e.g. `{ name }` (this is sugar for { name: name }) // A label with no value, e.g. `{ name }` (this is sugar for { name: name })
LabelOnly(_) => { LabelOnly(_) => {
internal_error!("Somehow a LabelOnly record field was not desugared!"); internal_error!("Somehow a LabelOnly record field was not desugared!");
@ -1876,19 +1909,19 @@ fn canonicalize_var_lookup(
// Since module_name was empty, this is an unqualified var. // Since module_name was empty, this is an unqualified var.
// Look it up in scope! // Look it up in scope!
match scope.lookup_str(ident, region) { match scope.lookup_str(ident, region) {
Ok(symbol) => { Ok(lookup) => {
output output
.references .references
.insert_value_lookup(symbol, QualifiedReference::Unqualified); .insert_value_lookup(lookup.symbol, QualifiedReference::Unqualified);
if scope.abilities_store.is_ability_member_name(symbol) { if scope.abilities_store.is_ability_member_name(lookup.symbol) {
AbilityMember( AbilityMember(
symbol, params_in_abilities_unimplemented!(lookup),
Some(scope.abilities_store.fresh_specialization_id()), Some(scope.abilities_store.fresh_specialization_id()),
var_store.fresh(), var_store.fresh(),
) )
} else { } else {
Var(symbol, var_store.fresh()) lookup_to_expr(lookup, var_store.fresh())
} }
} }
Err(problem) => { Err(problem) => {
@ -1901,19 +1934,19 @@ fn canonicalize_var_lookup(
// Since module_name was nonempty, this is a qualified var. // Since module_name was nonempty, this is a qualified var.
// Look it up in the env! // Look it up in the env!
match env.qualified_lookup(scope, module_name, ident, region) { match env.qualified_lookup(scope, module_name, ident, region) {
Ok(symbol) => { Ok(lookup) => {
output output
.references .references
.insert_value_lookup(symbol, QualifiedReference::Qualified); .insert_value_lookup(lookup.symbol, QualifiedReference::Qualified);
if scope.abilities_store.is_ability_member_name(symbol) { if scope.abilities_store.is_ability_member_name(lookup.symbol) {
AbilityMember( AbilityMember(
symbol, params_in_abilities_unimplemented!(lookup),
Some(scope.abilities_store.fresh_specialization_id()), Some(scope.abilities_store.fresh_specialization_id()),
var_store.fresh(), var_store.fresh(),
) )
} else { } else {
Var(symbol, var_store.fresh()) lookup_to_expr(lookup, var_store.fresh())
} }
} }
Err(problem) => { Err(problem) => {
@ -1931,6 +1964,24 @@ fn canonicalize_var_lookup(
(can_expr, output) (can_expr, output)
} }
fn lookup_to_expr(
SymbolLookup {
symbol,
module_params: params,
}: SymbolLookup,
var: Variable,
) -> Expr {
if let Some(params) = params {
Expr::ParamsVar {
symbol,
params,
var,
}
} else {
Expr::Var(symbol, var)
}
}
/// Currently uses the heuristic of "only inline if it's a builtin" /// Currently uses the heuristic of "only inline if it's a builtin"
pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr { pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
use Expr::*; use Expr::*;
@ -1949,6 +2000,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
| other @ RecordAccessor { .. } | other @ RecordAccessor { .. }
| other @ RecordUpdate { .. } | other @ RecordUpdate { .. }
| other @ Var(..) | other @ Var(..)
| other @ ParamsVar { .. }
| other @ AbilityMember(..) | other @ AbilityMember(..)
| other @ RunLowLevel { .. } | other @ RunLowLevel { .. }
| other @ TypedHole { .. } | other @ TypedHole { .. }
@ -2212,6 +2264,14 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
); );
} }
ImportParams(module_id, region, Some((var, expr))) => ImportParams(
module_id,
region,
Some((var, Box::new(inline_calls(var_store, *expr)))),
),
ImportParams(module_id, region, None) => ImportParams(module_id, region, None),
RecordAccess { RecordAccess {
record_var, record_var,
ext_var, ext_var,
@ -2433,7 +2493,8 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
} }
ast::Expr::Record(fields) => fields.iter().all(|loc_field| match loc_field.value { ast::Expr::Record(fields) => fields.iter().all(|loc_field| match loc_field.value {
ast::AssignedField::RequiredValue(_label, loc_comments, loc_val) ast::AssignedField::RequiredValue(_label, loc_comments, loc_val)
| ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) => { | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val)
| ast::AssignedField::IgnoredValue(_label, loc_comments, loc_val) => {
loc_comments.is_empty() && is_valid_interpolation(&loc_val.value) loc_comments.is_empty() && is_valid_interpolation(&loc_val.value)
} }
ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true, ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true,
@ -2481,7 +2542,8 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
is_valid_interpolation(&update.value) is_valid_interpolation(&update.value)
&& fields.iter().all(|loc_field| match loc_field.value { && fields.iter().all(|loc_field| match loc_field.value {
ast::AssignedField::RequiredValue(_label, loc_comments, loc_val) ast::AssignedField::RequiredValue(_label, loc_comments, loc_val)
| ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) => { | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val)
| ast::AssignedField::IgnoredValue(_label, loc_comments, loc_val) => {
loc_comments.is_empty() && is_valid_interpolation(&loc_val.value) loc_comments.is_empty() && is_valid_interpolation(&loc_val.value)
} }
ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true, ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true,
@ -2514,7 +2576,8 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
is_valid_interpolation(&mapper.value) is_valid_interpolation(&mapper.value)
&& fields.iter().all(|loc_field| match loc_field.value { && fields.iter().all(|loc_field| match loc_field.value {
ast::AssignedField::RequiredValue(_label, loc_comments, loc_val) ast::AssignedField::RequiredValue(_label, loc_comments, loc_val)
| ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) => { | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val)
| ast::AssignedField::IgnoredValue(_label, loc_comments, loc_val) => {
loc_comments.is_empty() && is_valid_interpolation(&loc_val.value) loc_comments.is_empty() && is_valid_interpolation(&loc_val.value)
} }
ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true, ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true,
@ -3133,6 +3196,11 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
while let Some(expr) = stack.pop() { while let Some(expr) = stack.pop() {
match expr { match expr {
Expr::Var(symbol, var) Expr::Var(symbol, var)
| Expr::ParamsVar {
symbol,
params: _,
var,
}
| Expr::RecordUpdate { | Expr::RecordUpdate {
symbol, symbol,
record_var: var, record_var: var,
@ -3237,6 +3305,9 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
Expr::Tuple { elems, .. } => { Expr::Tuple { elems, .. } => {
stack.extend(elems.iter().map(|(_, elem)| &elem.value)); stack.extend(elems.iter().map(|(_, elem)| &elem.value));
} }
Expr::ImportParams(_, _, Some((_, expr))) => {
stack.push(expr);
}
Expr::Expect { Expr::Expect {
loc_continuation, .. loc_continuation, ..
} }
@ -3263,6 +3334,7 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
| Expr::EmptyRecord | Expr::EmptyRecord
| Expr::TypedHole(_) | Expr::TypedHole(_)
| Expr::RuntimeError(_) | Expr::RuntimeError(_)
| Expr::ImportParams(_, _, None)
| Expr::OpaqueWrapFunction(_) => {} | Expr::OpaqueWrapFunction(_) => {}
} }
} }

View file

@ -6,9 +6,11 @@ use crate::def::{canonicalize_defs, report_unused_imports, Def};
use crate::effect_module::HostedGeneratedFunctions; use crate::effect_module::HostedGeneratedFunctions;
use crate::env::Env; use crate::env::Env;
use crate::expr::{ use crate::expr::{
ClosureData, DbgLookup, Declarations, ExpectLookup, Expr, Output, PendingDerives, AnnotatedMark, ClosureData, DbgLookup, Declarations, ExpectLookup, Expr, Output, PendingDerives,
};
use crate::pattern::{
canonicalize_record_destructure, BindingsFromPattern, Pattern, PermitShadows,
}; };
use crate::pattern::{BindingsFromPattern, Pattern};
use crate::procedure::References; use crate::procedure::References;
use crate::scope::Scope; use crate::scope::Scope;
use bumpalo::Bump; use bumpalo::Bump;
@ -18,7 +20,7 @@ use roc_module::ident::Ident;
use roc_module::ident::Lowercase; use roc_module::ident::Lowercase;
use roc_module::symbol::{IdentIds, IdentIdsByModule, ModuleId, PackageModuleIds, Symbol}; use roc_module::symbol::{IdentIds, IdentIdsByModule, ModuleId, PackageModuleIds, Symbol};
use roc_parse::ast::{Defs, TypeAnnotation}; use roc_parse::ast::{Defs, TypeAnnotation};
use roc_parse::header::HeaderType; use roc_parse::header::{HeaderType, ModuleParams};
use roc_parse::pattern::PatternType; use roc_parse::pattern::PatternType;
use roc_problem::can::{Problem, RuntimeError}; use roc_problem::can::{Problem, RuntimeError};
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
@ -136,6 +138,7 @@ pub struct Module {
pub abilities_store: PendingAbilitiesStore, pub abilities_store: PendingAbilitiesStore,
pub loc_expects: VecMap<Region, Vec<ExpectLookup>>, pub loc_expects: VecMap<Region, Vec<ExpectLookup>>,
pub loc_dbgs: VecMap<Symbol, DbgLookup>, pub loc_dbgs: VecMap<Symbol, DbgLookup>,
pub params_pattern: Option<(Variable, AnnotatedMark, Loc<Pattern>)>,
} }
#[derive(Debug, Default)] #[derive(Debug, Default)]
@ -149,6 +152,7 @@ pub struct RigidVariables {
pub struct ModuleOutput { pub struct ModuleOutput {
pub aliases: MutMap<Symbol, Alias>, pub aliases: MutMap<Symbol, Alias>,
pub rigid_variables: RigidVariables, pub rigid_variables: RigidVariables,
pub params_pattern: Option<(Variable, AnnotatedMark, Loc<Pattern>)>,
pub declarations: Declarations, pub declarations: Declarations,
pub exposed_imports: MutMap<Symbol, Region>, pub exposed_imports: MutMap<Symbol, Region>,
pub exposed_symbols: VecSet<Symbol>, pub exposed_symbols: VecSet<Symbol>,
@ -244,6 +248,7 @@ impl GeneratedInfo {
generates_with, generates_with,
name: _, name: _,
exposes: _, exposes: _,
opt_params: _,
} => { } => {
debug_assert!(generates_with.is_empty()); debug_assert!(generates_with.is_empty());
GeneratedInfo::Builtin GeneratedInfo::Builtin
@ -274,7 +279,7 @@ fn has_no_implementation(expr: &Expr) -> bool {
pub fn canonicalize_module_defs<'a>( pub fn canonicalize_module_defs<'a>(
arena: &'a Bump, arena: &'a Bump,
loc_defs: &'a mut Defs<'a>, loc_defs: &'a mut Defs<'a>,
header_type: &roc_parse::header::HeaderType, header_type: &'a roc_parse::header::HeaderType,
home: ModuleId, home: ModuleId,
module_path: &'a str, module_path: &'a str,
src: &'a str, src: &'a str,
@ -290,6 +295,7 @@ pub fn canonicalize_module_defs<'a>(
opt_shorthand: Option<&'a str>, opt_shorthand: Option<&'a str>,
) -> ModuleOutput { ) -> ModuleOutput {
let mut can_exposed_imports = MutMap::default(); let mut can_exposed_imports = MutMap::default();
let mut scope = Scope::new( let mut scope = Scope::new(
home, home,
qualified_module_ids qualified_module_ids
@ -382,9 +388,42 @@ pub fn canonicalize_module_defs<'a>(
} }
} }
let mut output = Output::default();
let params_pattern = header_type.get_params().as_ref().map(
|ModuleParams {
pattern,
before_arrow: _,
after_arrow: _,
}| {
let can_pattern = canonicalize_record_destructure(
&mut env,
var_store,
&mut scope,
&mut output,
PatternType::ModuleParams,
&pattern.value,
pattern.region,
PermitShadows(false),
);
let loc_pattern = Loc::at(pattern.region, can_pattern);
for (symbol, _) in BindingsFromPattern::new(&loc_pattern) {
env.top_level_symbols.insert(symbol);
}
(
var_store.fresh(),
AnnotatedMark::new(var_store),
loc_pattern,
)
},
);
let (defs, output, symbols_introduced, imports_introduced) = canonicalize_defs( let (defs, output, symbols_introduced, imports_introduced) = canonicalize_defs(
&mut env, &mut env,
Output::default(), output,
var_store, var_store,
&mut scope, &mut scope,
loc_defs, loc_defs,
@ -812,6 +851,7 @@ pub fn canonicalize_module_defs<'a>(
scope, scope,
aliases, aliases,
rigid_variables, rigid_variables,
params_pattern,
declarations, declarations,
referenced_values, referenced_values,
exposed_imports: can_exposed_imports, exposed_imports: can_exposed_imports,
@ -1105,6 +1145,7 @@ fn fix_values_captured_in_closure_expr(
| SingleQuote(..) | SingleQuote(..)
| IngestedFile(..) | IngestedFile(..)
| Var(..) | Var(..)
| ParamsVar { .. }
| AbilityMember(..) | AbilityMember(..)
| EmptyRecord | EmptyRecord
| TypedHole { .. } | TypedHole { .. }
@ -1216,6 +1257,12 @@ fn fix_values_captured_in_closure_expr(
} }
} }
ImportParams(_, _, Some((_, expr))) => {
fix_values_captured_in_closure_expr(expr, no_capture_symbols, closure_captures);
}
ImportParams(_, _, None) => {}
Tuple { elems, .. } => { Tuple { elems, .. } => {
for (_var, expr) in elems.iter_mut() { for (_var, expr) in elems.iter_mut() {
fix_values_captured_in_closure_expr( fix_values_captured_in_closure_expr(

View file

@ -623,132 +623,16 @@ pub fn canonicalize_pattern<'a>(
} }
} }
RecordDestructure(patterns) => { RecordDestructure(patterns) => canonicalize_record_destructure(
let ext_var = var_store.fresh();
let whole_var = var_store.fresh();
let mut destructs = Vec::with_capacity(patterns.len());
let mut opt_erroneous = None;
for loc_pattern in patterns.iter() {
match loc_pattern.value {
Identifier { ident: label } => {
match scope.introduce(label.into(), region) {
Ok(symbol) => {
output.references.insert_bound(symbol);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Required,
},
});
}
Err((shadowed_symbol, shadow, new_symbol)) => {
env.problem(Problem::RuntimeError(RuntimeError::Shadowing {
original_region: shadowed_symbol.region,
shadow: shadow.clone(),
kind: ShadowKind::Variable,
}));
// No matter what the other patterns
// are, we're definitely shadowed and will
// get a runtime exception as soon as we
// encounter the first bad pattern.
opt_erroneous = Some(Pattern::Shadowed(
shadowed_symbol.region,
shadow,
new_symbol,
));
}
};
}
RequiredField(label, loc_guard) => {
// a guard does not introduce the label into scope!
let symbol =
scope.scopeless_symbol(&Ident::from(label), loc_pattern.region);
let can_guard = canonicalize_pattern(
env, env,
var_store, var_store,
scope, scope,
output, output,
pattern_type, pattern_type,
&loc_guard.value, patterns,
loc_guard.region, region,
permit_shadows, permit_shadows,
); ),
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Guard(var_store.fresh(), can_guard),
},
});
}
OptionalField(label, loc_default) => {
// an optional DOES introduce the label into scope!
match scope.introduce(label.into(), region) {
Ok(symbol) => {
let (can_default, expr_output) = canonicalize_expr(
env,
var_store,
scope,
loc_default.region,
&loc_default.value,
);
// an optional field binds the symbol!
output.references.insert_bound(symbol);
output.union(expr_output);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Optional(var_store.fresh(), can_default),
},
});
}
Err((shadowed_symbol, shadow, new_symbol)) => {
env.problem(Problem::RuntimeError(RuntimeError::Shadowing {
original_region: shadowed_symbol.region,
shadow: shadow.clone(),
kind: ShadowKind::Variable,
}));
// No matter what the other patterns
// are, we're definitely shadowed and will
// get a runtime exception as soon as we
// encounter the first bad pattern.
opt_erroneous = Some(Pattern::Shadowed(
shadowed_symbol.region,
shadow,
new_symbol,
));
}
};
}
_ => unreachable!("Any other pattern should have given a parse error"),
}
}
// If we encountered an erroneous pattern (e.g. one with shadowing),
// use the resulting RuntimeError. Otherwise, return a successful record destructure.
opt_erroneous.unwrap_or(Pattern::RecordDestructure {
whole_var,
ext_var,
destructs,
})
}
RequiredField(_name, _loc_pattern) => { RequiredField(_name, _loc_pattern) => {
unreachable!("should have been handled in RecordDestructure"); unreachable!("should have been handled in RecordDestructure");
@ -894,6 +778,144 @@ pub fn canonicalize_pattern<'a>(
} }
} }
#[allow(clippy::too_many_arguments)]
pub fn canonicalize_record_destructure<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
scope: &mut Scope,
output: &mut Output,
pattern_type: PatternType,
patterns: &ast::Collection<Loc<ast::Pattern<'a>>>,
region: Region,
permit_shadows: PermitShadows,
) -> Pattern {
use ast::Pattern::*;
let ext_var = var_store.fresh();
let whole_var = var_store.fresh();
let mut destructs = Vec::with_capacity(patterns.len());
let mut opt_erroneous = None;
for loc_pattern in patterns.iter() {
match loc_pattern.value {
Identifier { ident: label } => {
match scope.introduce(label.into(), region) {
Ok(symbol) => {
output.references.insert_bound(symbol);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Required,
},
});
}
Err((shadowed_symbol, shadow, new_symbol)) => {
env.problem(Problem::RuntimeError(RuntimeError::Shadowing {
original_region: shadowed_symbol.region,
shadow: shadow.clone(),
kind: ShadowKind::Variable,
}));
// No matter what the other patterns
// are, we're definitely shadowed and will
// get a runtime exception as soon as we
// encounter the first bad pattern.
opt_erroneous = Some(Pattern::Shadowed(
shadowed_symbol.region,
shadow,
new_symbol,
));
}
};
}
RequiredField(label, loc_guard) => {
// a guard does not introduce the label into scope!
let symbol = scope.scopeless_symbol(&Ident::from(label), loc_pattern.region);
let can_guard = canonicalize_pattern(
env,
var_store,
scope,
output,
pattern_type,
&loc_guard.value,
loc_guard.region,
permit_shadows,
);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Guard(var_store.fresh(), can_guard),
},
});
}
OptionalField(label, loc_default) => {
// an optional DOES introduce the label into scope!
match scope.introduce(label.into(), region) {
Ok(symbol) => {
let (can_default, expr_output) = canonicalize_expr(
env,
var_store,
scope,
loc_default.region,
&loc_default.value,
);
// an optional field binds the symbol!
output.references.insert_bound(symbol);
output.union(expr_output);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Optional(var_store.fresh(), can_default),
},
});
}
Err((shadowed_symbol, shadow, new_symbol)) => {
env.problem(Problem::RuntimeError(RuntimeError::Shadowing {
original_region: shadowed_symbol.region,
shadow: shadow.clone(),
kind: ShadowKind::Variable,
}));
// No matter what the other patterns
// are, we're definitely shadowed and will
// get a runtime exception as soon as we
// encounter the first bad pattern.
opt_erroneous = Some(Pattern::Shadowed(
shadowed_symbol.region,
shadow,
new_symbol,
));
}
};
}
_ => unreachable!("Any other pattern should have given a parse error"),
}
}
// If we encountered an erroneous pattern (e.g. one with shadowing),
// use the resulting RuntimeError. Otherwise, return a successful record destructure.
opt_erroneous.unwrap_or(Pattern::RecordDestructure {
whole_var,
ext_var,
destructs,
})
}
/// When we detect an unsupported pattern type (e.g. 5 = 1 + 2 is unsupported because you can't /// When we detect an unsupported pattern type (e.g. 5 = 1 + 2 is unsupported because you can't
/// assign to Int patterns), report it to Env and return an UnsupportedPattern runtime error pattern. /// assign to Int patterns), report it to Env and return an UnsupportedPattern runtime error pattern.
fn unsupported_pattern(env: &mut Env, pattern_type: PatternType, region: Region) -> Pattern { fn unsupported_pattern(env: &mut Env, pattern_type: PatternType, region: Region) -> Pattern {

View file

@ -1,8 +1,8 @@
use roc_collections::{VecMap, VecSet}; use roc_collections::{VecMap, VecSet};
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::ident::{Ident, ModuleName}; use roc_module::ident::{Ident, ModuleName};
use roc_module::symbol::{IdentId, IdentIds, ModuleId, ScopeModules, Symbol}; use roc_module::symbol::{IdentId, IdentIds, ModuleId, ModuleIds, Symbol};
use roc_problem::can::RuntimeError; use roc_problem::can::{RuntimeError, ScopeModuleSource};
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
use roc_types::subs::Variable; use roc_types::subs::Variable;
use roc_types::types::{Alias, AliasKind, AliasVar, Type}; use roc_types::types::{Alias, AliasKind, AliasVar, Type};
@ -76,7 +76,7 @@ impl Scope {
} }
} }
pub fn lookup(&self, ident: &Ident, region: Region) -> Result<Symbol, RuntimeError> { pub fn lookup(&self, ident: &Ident, region: Region) -> Result<SymbolLookup, RuntimeError> {
self.lookup_str(ident.as_str(), region) self.lookup_str(ident.as_str(), region)
} }
@ -91,7 +91,7 @@ impl Scope {
.push(("Set".into(), Symbol::SET_SET, Region::zero())); .push(("Set".into(), Symbol::SET_SET, Region::zero()));
} }
pub fn lookup_str(&self, ident: &str, region: Region) -> Result<Symbol, RuntimeError> { pub fn lookup_str(&self, ident: &str, region: Region) -> Result<SymbolLookup, RuntimeError> {
use ContainsIdent::*; use ContainsIdent::*;
match self.scope_contains_ident(ident) { match self.scope_contains_ident(ident) {
@ -205,15 +205,20 @@ impl Scope {
} }
} }
fn has_imported_symbol(&self, ident: &str) -> Option<(Symbol, Region)> { fn has_imported_symbol(&self, ident: &str) -> Option<(SymbolLookup, Region)> {
for (import, shadow, original_region) in self.imported_symbols.iter() { self.imported_symbols
.iter()
.find_map(|(import, symbol, original_region)| {
if ident == import.as_str() { if ident == import.as_str() {
return Some((*shadow, *original_region)); match self.modules.lookup_by_id(&symbol.module_id()) {
Some(module) => Some((module.into_symbol(*symbol), *original_region)),
None => Some((SymbolLookup::no_params(*symbol), *original_region)),
} }
} } else {
None None
} }
})
}
/// Is an identifier in scope, either in the locals or imports /// Is an identifier in scope, either in the locals or imports
fn scope_contains_ident(&self, ident: &str) -> ContainsIdent { fn scope_contains_ident(&self, ident: &str) -> ContainsIdent {
@ -229,7 +234,7 @@ impl Scope {
ContainsIdent::InScope(original_symbol, original_region) => { ContainsIdent::InScope(original_symbol, original_region) => {
// the ident is already in scope; up to the caller how to handle that // the ident is already in scope; up to the caller how to handle that
// (usually it's shadowing, but it is valid to shadow ability members) // (usually it's shadowing, but it is valid to shadow ability members)
Err((original_symbol, original_region)) Err((original_symbol.symbol, original_region))
} }
ContainsIdent::NotPresent => { ContainsIdent::NotPresent => {
// We know nothing about this ident yet; introduce it to the scope // We know nothing about this ident yet; introduce it to the scope
@ -389,7 +394,13 @@ impl Scope {
region: Region, region: Region,
) -> Result<(), (Symbol, Region)> { ) -> Result<(), (Symbol, Region)> {
match self.scope_contains_ident(ident.as_str()) { match self.scope_contains_ident(ident.as_str()) {
ContainsIdent::InScope(symbol, region) => Err((symbol, region)), ContainsIdent::InScope(
SymbolLookup {
symbol,
module_params: _,
},
region,
) => Err((symbol, region)),
ContainsIdent::NotPresent | ContainsIdent::NotInScope(_) => { ContainsIdent::NotPresent | ContainsIdent::NotInScope(_) => {
self.imported_symbols.push((ident, symbol, region)); self.imported_symbols.push((ident, symbol, region));
Ok(()) Ok(())
@ -534,7 +545,7 @@ pub fn create_alias(
#[derive(Debug)] #[derive(Debug)]
enum ContainsIdent { enum ContainsIdent {
InScope(Symbol, Region), InScope(SymbolLookup, Region),
NotInScope(IdentId), NotInScope(IdentId),
NotPresent, NotPresent,
} }
@ -561,7 +572,7 @@ impl ScopedIdentIds {
fn has_in_scope(&self, ident: &Ident) -> Option<(Symbol, Region)> { fn has_in_scope(&self, ident: &Ident) -> Option<(Symbol, Region)> {
match self.contains_ident(ident.as_str()) { match self.contains_ident(ident.as_str()) {
ContainsIdent::InScope(symbol, region) => Some((symbol, region)), ContainsIdent::InScope(symbol, region) => Some((symbol.symbol, region)),
ContainsIdent::NotInScope(_) | ContainsIdent::NotPresent => None, ContainsIdent::NotInScope(_) | ContainsIdent::NotPresent => None,
} }
} }
@ -574,7 +585,10 @@ impl ScopedIdentIds {
for ident_id in self.ident_ids.get_id_many(ident) { for ident_id in self.ident_ids.get_id_many(ident) {
let index = ident_id.index(); let index = ident_id.index();
if self.in_scope[index] { if self.in_scope[index] {
return InScope(Symbol::new(self.home, ident_id), self.regions[index]); return InScope(
SymbolLookup::no_params(Symbol::new(self.home, ident_id)),
self.regions[index],
);
} else { } else {
result = NotInScope(ident_id) result = NotInScope(ident_id)
} }
@ -646,6 +660,149 @@ impl ScopedIdentIds {
} }
} }
#[derive(Debug, Clone)]
pub struct ScopeModules {
/// The ids of all modules in scope
ids: Vec<ModuleId>,
/// The alias or original name of each module in scope
names: Vec<ModuleName>,
/// Why is this module in scope?
sources: Vec<ScopeModuleSource>,
/// The params of a module if any
params: Vec<Option<Symbol>>,
}
impl ScopeModules {
pub fn new(home_id: ModuleId, home_name: ModuleName) -> Self {
let builtins = ModuleIds::default();
let builtins_iter = builtins.iter();
let count = builtins_iter.len();
let mut ids = Vec::with_capacity(count + 1);
let mut names = Vec::with_capacity(count + 1);
let mut sources = vec![ScopeModuleSource::Builtin; count];
let mut params = vec![None; count];
for (module_id, module_name) in builtins_iter {
ids.push(module_id);
names.push(module_name.clone());
}
if !home_id.is_builtin() {
ids.push(home_id);
names.push(home_name);
sources.push(ScopeModuleSource::Current);
params.push(None);
}
Self {
ids,
names,
sources,
params,
}
}
pub fn lookup(&self, module_name: &ModuleName) -> Option<ModuleLookup> {
self.names
.iter()
.position(|name| name == module_name)
.map(|index| ModuleLookup {
id: self.ids[index],
params: self.params[index],
})
}
pub fn lookup_by_id(&self, module_id: &ModuleId) -> Option<ModuleLookup> {
self.ids
.iter()
.position(|id| id == module_id)
.map(|index| ModuleLookup {
id: self.ids[index],
params: self.params[index],
})
}
pub fn available_names(&self) -> impl Iterator<Item = &ModuleName> {
self.names.iter()
}
pub fn insert(
&mut self,
module_name: ModuleName,
module_id: ModuleId,
params_symbol: Option<Symbol>,
region: Region,
) -> Result<(), ScopeModuleSource> {
if let Some(index) = self.names.iter().position(|name| name == &module_name) {
if self.ids[index] == module_id {
return Ok(());
}
return Err(self.sources[index]);
}
self.ids.push(module_id);
self.names.push(module_name);
self.sources.push(ScopeModuleSource::Import(region));
self.params.push(params_symbol);
Ok(())
}
pub fn len(&self) -> usize {
debug_assert_eq!(self.ids.len(), self.names.len());
debug_assert_eq!(self.ids.len(), self.sources.len());
debug_assert_eq!(self.ids.len(), self.params.len());
self.ids.len()
}
pub fn is_empty(&self) -> bool {
self.ids.is_empty()
}
pub fn truncate(&mut self, len: usize) {
self.ids.truncate(len);
self.names.truncate(len);
self.sources.truncate(len);
self.params.truncate(len);
}
}
#[derive(Debug, Clone)]
pub struct SymbolLookup {
pub symbol: Symbol,
pub module_params: Option<Symbol>,
}
impl SymbolLookup {
pub fn new(symbol: Symbol, params: Option<Symbol>) -> Self {
Self {
symbol,
module_params: params,
}
}
pub fn no_params(symbol: Symbol) -> Self {
Self::new(symbol, None)
}
}
pub struct ModuleLookup {
pub id: ModuleId,
pub params: Option<Symbol>,
}
impl ModuleLookup {
pub fn into_symbol(&self, symbol: Symbol) -> SymbolLookup {
debug_assert_eq!(symbol.module_id(), self.id);
SymbolLookup {
symbol,
module_params: self.params,
}
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
@ -701,7 +858,7 @@ mod test {
let lookup = scope.lookup(&ident, Region::zero()).unwrap(); let lookup = scope.lookup(&ident, Region::zero()).unwrap();
assert_eq!(first, lookup); assert_eq!(first, lookup.symbol);
} }
#[test] #[test]
@ -857,6 +1014,6 @@ mod test {
let lookup = scope.lookup(&ident, Region::zero()).unwrap(); let lookup = scope.lookup(&ident, Region::zero()).unwrap();
assert_eq!(symbol, lookup); assert_eq!(symbol, lookup.symbol);
} }
} }

View file

@ -266,6 +266,7 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
walk_list(visitor, *elem_var, loc_elems); walk_list(visitor, *elem_var, loc_elems);
} }
Expr::Var(..) => { /* terminal */ } Expr::Var(..) => { /* terminal */ }
Expr::ParamsVar { .. } => { /* terminal */ }
Expr::AbilityMember(..) => { /* terminal */ } Expr::AbilityMember(..) => { /* terminal */ }
Expr::If { Expr::If {
cond_var, cond_var,
@ -317,6 +318,8 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
.iter() .iter()
.for_each(|(var, elem)| visitor.visit_expr(&elem.value, elem.region, *var)), .for_each(|(var, elem)| visitor.visit_expr(&elem.value, elem.region, *var)),
Expr::EmptyRecord => { /* terminal */ } Expr::EmptyRecord => { /* terminal */ }
Expr::ImportParams(_, region, Some((_, expr))) => visitor.visit_expr(expr, *region, var),
Expr::ImportParams(_, _, None) => { /* terminal */ }
Expr::RecordAccess { Expr::RecordAccess {
field_var, field_var,
loc_expr, loc_expr,

View file

@ -566,7 +566,12 @@ pub fn constrain_expr(
constraints.exists([*ret_var], and) constraints.exists([*ret_var], and)
} }
Var(symbol, variable) => { Var(symbol, variable)
| ParamsVar {
symbol,
params: _,
var: variable,
} => {
// Save the expectation in the variable, then lookup the symbol's type in the environment // Save the expectation in the variable, then lookup the symbol's type in the environment
let expected_type = *constraints[expected].get_type_ref(); let expected_type = *constraints[expected].get_type_ref();
let store_expected = constraints.store(expected_type, *variable, file!(), line!()); let store_expected = constraints.store(expected_type, *variable, file!(), line!());
@ -575,6 +580,22 @@ pub fn constrain_expr(
constraints.and_constraint([store_expected, lookup_constr]) constraints.and_constraint([store_expected, lookup_constr])
} }
ImportParams(module_id, region, Some((var, params))) => {
let index = constraints.push_variable(*var);
let expected_params = constraints.push_expected_type(Expected::ForReason(
Reason::ImportParams(*module_id),
index,
*region,
));
let expr_con =
constrain_expr(types, constraints, env, *region, params, expected_params);
let params_con = constraints.import_params(Some(index), *module_id, *region);
let expr_and_params = constraints.and_constraint([expr_con, params_con]);
constraints.exists([*var], expr_and_params)
}
ImportParams(module_id, region, None) => {
constraints.import_params(None, *module_id, *region)
}
&AbilityMember(symbol, specialization_id, specialization_var) => { &AbilityMember(symbol, specialization_id, specialization_var) => {
// Save the expectation in the `specialization_var` so we know what to specialize, then // Save the expectation in the `specialization_var` so we know what to specialize, then
// lookup the member in the environment. // lookup the member in the environment.
@ -4089,6 +4110,8 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool {
return true; return true;
} }
OpaqueRef { argument, .. } => expr = &argument.1.value, OpaqueRef { argument, .. } => expr = &argument.1.value,
ImportParams(_, _, Some((_, params))) => expr = params,
ImportParams(_, _, None) => return false,
Str(_) Str(_)
| IngestedFile(..) | IngestedFile(..)
| List { .. } | List { .. }
@ -4115,7 +4138,8 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool {
| ZeroArgumentTag { .. } | ZeroArgumentTag { .. }
| Tag { .. } | Tag { .. }
| AbilityMember(..) | AbilityMember(..)
| Var(..) => return false, | Var(..)
| ParamsVar { .. } => return false,
} }
} }
} }

View file

@ -1,11 +1,15 @@
use crate::expr::{constrain_def_make_constraint, constrain_def_pattern, Env}; use crate::expr::{constrain_def_make_constraint, constrain_def_pattern, Env};
use crate::pattern::{constrain_pattern, PatternState};
use roc_can::abilities::{PendingAbilitiesStore, PendingMemberType}; use roc_can::abilities::{PendingAbilitiesStore, PendingMemberType};
use roc_can::constraint::{Constraint, Constraints, Generalizable}; use roc_can::constraint::{Constraint, Constraints, Generalizable};
use roc_can::expected::Expected; use roc_can::expected::{Expected, PExpected};
use roc_can::expr::Declarations; use roc_can::expr::{AnnotatedMark, Declarations};
use roc_can::pattern::Pattern; use roc_can::pattern::Pattern;
use roc_collections::MutMap;
use roc_error_macros::internal_error;
use roc_module::symbol::{ModuleId, Symbol}; use roc_module::symbol::{ModuleId, Symbol};
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
use roc_types::subs::Variable;
use roc_types::types::{AnnotationSource, Category, Type, Types}; use roc_types::types::{AnnotationSource, Category, Type, Types};
pub fn constrain_module( pub fn constrain_module(
@ -14,9 +18,18 @@ pub fn constrain_module(
symbols_from_requires: Vec<(Loc<Symbol>, Loc<Type>)>, symbols_from_requires: Vec<(Loc<Symbol>, Loc<Type>)>,
abilities_store: &PendingAbilitiesStore, abilities_store: &PendingAbilitiesStore,
declarations: &Declarations, declarations: &Declarations,
params_pattern: &Option<(Variable, AnnotatedMark, Loc<Pattern>)>,
home: ModuleId, home: ModuleId,
) -> Constraint { ) -> Constraint {
let constraint = crate::expr::constrain_decls(types, constraints, home, declarations); let constraint = crate::expr::constrain_decls(types, constraints, home, declarations);
let constraint = match params_pattern {
Some(params_pattern) => {
constrain_params(types, constraints, home, constraint, params_pattern)
}
None => constraint,
};
let constraint = constrain_symbols_from_requires( let constraint = constrain_symbols_from_requires(
types, types,
constraints, constraints,
@ -33,6 +46,63 @@ pub fn constrain_module(
constraint constraint
} }
fn constrain_params(
types: &mut Types,
constraints: &mut Constraints,
home: ModuleId,
constraint: Constraint,
(pattern_var, _, loc_pattern): &(Variable, AnnotatedMark, Loc<Pattern>),
) -> Constraint {
let mut env = Env {
home,
rigids: MutMap::default(),
resolutions_to_make: vec![],
};
let index = constraints.push_variable(*pattern_var);
let expected_params = constraints.push_pat_expected_type(PExpected::NoExpectation(index));
let mut state = PatternState::default();
let closed_con = match loc_pattern.value {
Pattern::RecordDestructure {
whole_var: _,
ext_var,
destructs: _,
} => {
// Disallow record extension for module params
let empty_rec = constraints.push_type(types, Types::EMPTY_RECORD);
constraints.store(empty_rec, ext_var, file!(), line!())
}
_ => internal_error!("Only record destructures are allowed in module params. This should've been caught earlier."),
};
state.constraints.push(closed_con);
constrain_pattern(
types,
constraints,
&mut env,
&loc_pattern.value,
loc_pattern.region,
expected_params,
&mut state,
);
let pattern_constraints = constraints.and_constraint(state.constraints);
let cons = constraints.let_constraint(
[],
state.vars,
state.headers,
pattern_constraints,
constraint,
Generalizable(true),
);
constraints.exists([*pattern_var], cons)
}
fn constrain_symbols_from_requires( fn constrain_symbols_from_requires(
types: &mut Types, types: &mut Types,
constraints: &mut Constraints, constraints: &mut Constraints,

View file

@ -428,9 +428,9 @@ fn is_multiline_assigned_field_help<T: Formattable>(afield: &AssignedField<'_, T
use self::AssignedField::*; use self::AssignedField::*;
match afield { match afield {
RequiredValue(_, spaces, ann) | OptionalValue(_, spaces, ann) => { RequiredValue(_, spaces, ann)
!spaces.is_empty() || ann.value.is_multiline() | OptionalValue(_, spaces, ann)
} | IgnoredValue(_, spaces, ann) => !spaces.is_empty() || ann.value.is_multiline(),
LabelOnly(_) => false, LabelOnly(_) => false,
AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => true, AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => true,
Malformed(text) => text.chars().any(|c| c == '\n'), Malformed(text) => text.chars().any(|c| c == '\n'),
@ -483,6 +483,24 @@ fn format_assigned_field_help<T>(
buf.spaces(1); buf.spaces(1);
ann.value.format(buf, indent); ann.value.format(buf, indent);
} }
IgnoredValue(name, spaces, ann) => {
if is_multiline {
buf.newline();
}
buf.indent(indent);
buf.push('_');
buf.push_str(name.value);
if !spaces.is_empty() {
fmt_spaces(buf, spaces.iter(), indent);
}
buf.spaces(separator_spaces);
buf.push(':');
buf.spaces(1);
ann.value.format(buf, indent);
}
LabelOnly(name) => { LabelOnly(name) => {
if is_multiline { if is_multiline {
buf.newline(); buf.newline();

View file

@ -252,14 +252,14 @@ impl<'a> Formattable for ModuleImportParams<'a> {
fn is_multiline(&self) -> bool { fn is_multiline(&self) -> bool {
let ModuleImportParams { before, params } = self; let ModuleImportParams { before, params } = self;
!before.is_empty() || is_collection_multiline(params) !before.is_empty() || is_collection_multiline(&params.value)
} }
fn format_with_options(&self, buf: &mut Buf, _parens: Parens, newlines: Newlines, indent: u16) { fn format_with_options(&self, buf: &mut Buf, _parens: Parens, newlines: Newlines, indent: u16) {
let ModuleImportParams { before, params } = self; let ModuleImportParams { before, params } = self;
fmt_default_spaces(buf, before, indent); fmt_default_spaces(buf, before, indent);
fmt_collection(buf, indent, Braces::Curly, *params, newlines); fmt_collection(buf, indent, Braces::Curly, params.value, newlines);
} }
} }

View file

@ -1529,6 +1529,23 @@ fn format_assigned_field_multiline<T>(
ann.value.format(buf, indent); ann.value.format(buf, indent);
buf.push(','); buf.push(',');
} }
IgnoredValue(name, spaces, ann) => {
buf.newline();
buf.indent(indent);
buf.push('_');
buf.push_str(name.value);
if !spaces.is_empty() {
fmt_spaces(buf, spaces.iter(), indent);
buf.indent(indent);
}
buf.push_str(separator_prefix);
buf.push_str(":");
buf.spaces(1);
ann.value.format(buf, indent);
buf.push(',');
}
LabelOnly(name) => { LabelOnly(name) => {
buf.newline(); buf.newline();
buf.indent(indent); buf.indent(indent);

View file

@ -5,7 +5,7 @@ use crate::collection::{fmt_collection, Braces};
use crate::expr::fmt_str_literal; use crate::expr::fmt_str_literal;
use crate::spaces::{fmt_comments_only, fmt_default_spaces, fmt_spaces, NewlineAt, INDENT}; use crate::spaces::{fmt_comments_only, fmt_default_spaces, fmt_spaces, NewlineAt, INDENT};
use crate::Buf; use crate::Buf;
use roc_parse::ast::{Collection, CommentOrNewline, Header, Module, Spaced, Spaces}; use roc_parse::ast::{Collection, CommentOrNewline, Header, Spaced, Spaces, SpacesBefore};
use roc_parse::header::{ use roc_parse::header::{
AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword, HostedHeader, ImportsEntry, AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword, HostedHeader, ImportsEntry,
ImportsKeyword, Keyword, KeywordItem, ModuleHeader, ModuleName, PackageEntry, PackageHeader, ImportsKeyword, Keyword, KeywordItem, ModuleHeader, ModuleName, PackageEntry, PackageHeader,
@ -16,9 +16,9 @@ use roc_parse::header::{
use roc_parse::ident::UppercaseIdent; use roc_parse::ident::UppercaseIdent;
use roc_region::all::Loc; use roc_region::all::Loc;
pub fn fmt_module<'a>(buf: &mut Buf<'_>, module: &'a Module<'a>) { pub fn fmt_header<'a>(buf: &mut Buf<'_>, header: &'a SpacesBefore<'a, Header<'a>>) {
fmt_comments_only(buf, module.comments.iter(), NewlineAt::Bottom, 0); fmt_comments_only(buf, header.before.iter(), NewlineAt::Bottom, 0);
match &module.header { match &header.item {
Header::Module(header) => { Header::Module(header) => {
fmt_module_header(buf, header); fmt_module_header(buf, header);
} }
@ -174,11 +174,17 @@ pub fn fmt_module_header<'a>(buf: &mut Buf, header: &'a ModuleHeader<'a>) {
let mut indent = fmt_spaces_with_outdent(buf, header.after_keyword, 0); let mut indent = fmt_spaces_with_outdent(buf, header.after_keyword, 0);
if let Some(params) = &header.params { if let Some(params) = &header.params {
if is_collection_multiline(&params.params) { if is_collection_multiline(&params.pattern.value) {
indent = INDENT; indent = INDENT;
} }
fmt_collection(buf, indent, Braces::Curly, params.params, Newlines::Yes); fmt_collection(
buf,
indent,
Braces::Curly,
params.pattern.value,
Newlines::Yes,
);
indent = fmt_spaces_with_outdent(buf, params.before_arrow, indent); indent = fmt_spaces_with_outdent(buf, params.before_arrow, indent);
buf.push_str("->"); buf.push_str("->");

View file

@ -6,18 +6,11 @@ pub mod annotation;
pub mod collection; pub mod collection;
pub mod def; pub mod def;
pub mod expr; pub mod expr;
pub mod module; pub mod header;
pub mod pattern; pub mod pattern;
pub mod spaces; pub mod spaces;
use bumpalo::{collections::String, Bump}; use bumpalo::{collections::String, Bump};
use roc_parse::ast::Module;
#[derive(Debug)]
pub struct Ast<'a> {
pub module: Module<'a>,
pub defs: roc_parse::ast::Defs<'a>,
}
#[derive(Debug)] #[derive(Debug)]
pub struct Buf<'a> { pub struct Buf<'a> {

View file

@ -1,7 +1,6 @@
use bumpalo::Bump; use roc_parse::ast::CommentOrNewline;
use roc_parse::{ast::CommentOrNewline, remove_spaces::RemoveSpaces};
use crate::{Ast, Buf}; use crate::Buf;
/// The number of spaces to indent. /// The number of spaces to indent.
pub const INDENT: u16 = 4; pub const INDENT: u16 = 4;
@ -192,12 +191,3 @@ fn fmt_docs(buf: &mut Buf, docs: &str) {
} }
buf.push_str(docs.trim_end()); buf.push_str(docs.trim_end());
} }
impl<'a> RemoveSpaces<'a> for Ast<'a> {
fn remove_spaces(&self, arena: &'a Bump) -> Self {
Ast {
module: self.module.remove_spaces(arena),
defs: self.defs.remove_spaces(arena),
}
}
}

View file

@ -51,6 +51,8 @@ pub fn infer_expr(
exposed_by_module: &Default::default(), exposed_by_module: &Default::default(),
derived_module, derived_module,
function_kind: FunctionKind::LambdaSet, function_kind: FunctionKind::LambdaSet,
params_pattern: None,
module_params_vars: Default::default(),
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
checkmate: None, checkmate: None,
}; };

View file

@ -16,7 +16,7 @@ mod test_reporting {
use roc_load::{self, ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading}; use roc_load::{self, ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
use roc_module::symbol::{Interns, ModuleId}; use roc_module::symbol::{Interns, ModuleId};
use roc_packaging::cache::RocCacheDir; use roc_packaging::cache::RocCacheDir;
use roc_parse::module::parse_header; use roc_parse::header::parse_header;
use roc_parse::state::State; use roc_parse::state::State;
use roc_parse::test_helpers::parse_expr_with; use roc_parse::test_helpers::parse_expr_with;
use roc_problem::Severity; use roc_problem::Severity;
@ -359,7 +359,7 @@ mod test_reporting {
let src_lines: Vec<&str> = src.split('\n').collect(); let src_lines: Vec<&str> = src.split('\n').collect();
let lines = LineInfo::new(src); let lines = LineInfo::new(src);
match roc_parse::module::parse_header(arena, state) { match roc_parse::header::parse_header(arena, state) {
Err(fail) => { Err(fail) => {
let interns = Interns::default(); let interns = Interns::default();
let home = crate::helpers::test_home(); let home = crate::helpers::test_home();

View file

@ -465,7 +465,8 @@ fn contains_unexposed_type(
while let Some(field) = fields_to_process.pop() { while let Some(field) = fields_to_process.pop() {
match field { match field {
AssignedField::RequiredValue(_field, _spaces, loc_val) AssignedField::RequiredValue(_field, _spaces, loc_val)
| AssignedField::OptionalValue(_field, _spaces, loc_val) => { | AssignedField::OptionalValue(_field, _spaces, loc_val)
| AssignedField::IgnoredValue(_field, _spaces, loc_val) => {
if contains_unexposed_type(&loc_val.value, exposed_module_ids, module_ids) { if contains_unexposed_type(&loc_val.value, exposed_module_ids, module_ids) {
return true; return true;
} }
@ -721,7 +722,7 @@ fn record_field_to_doc(
AssignedField::LabelOnly(label) => Some(RecordField::LabelOnly { AssignedField::LabelOnly(label) => Some(RecordField::LabelOnly {
name: label.value.to_string(), name: label.value.to_string(),
}), }),
AssignedField::Malformed(_) => None, AssignedField::Malformed(_) | AssignedField::IgnoredValue(_, _, _) => None,
} }
} }

View file

@ -48,11 +48,11 @@ use roc_mono::reset_reuse;
use roc_mono::{drop_specialization, inc_dec}; use roc_mono::{drop_specialization, inc_dec};
use roc_packaging::cache::RocCacheDir; use roc_packaging::cache::RocCacheDir;
use roc_parse::ast::{self, CommentOrNewline, ExtractSpaces, Spaced, ValueDef}; use roc_parse::ast::{self, CommentOrNewline, ExtractSpaces, Spaced, ValueDef};
use roc_parse::header::parse_module_defs;
use roc_parse::header::{ use roc_parse::header::{
self, AppHeader, ExposedName, HeaderType, ImportsKeywordItem, PackageEntry, PackageHeader, self, AppHeader, ExposedName, HeaderType, ImportsKeywordItem, PackageEntry, PackageHeader,
PlatformHeader, To, TypedIdent, PlatformHeader, To, TypedIdent,
}; };
use roc_parse::module::parse_module_defs;
use roc_parse::parser::{FileError, SourceError, SyntaxError}; use roc_parse::parser::{FileError, SourceError, SyntaxError};
use roc_problem::Severity; use roc_problem::Severity;
use roc_region::all::{LineInfo, Loc, Region}; use roc_region::all::{LineInfo, Loc, Region};
@ -1327,8 +1327,8 @@ fn load_packages_from_main<'a>(
let parse_state = roc_parse::state::State::new(arena.alloc(src_bytes)); let parse_state = roc_parse::state::State::new(arena.alloc(src_bytes));
let (parsed_module, _) = let (parsed_header, _) =
roc_parse::module::parse_header(arena, parse_state.clone()).map_err(|fail| { roc_parse::header::parse_header(arena, parse_state.clone()).map_err(|fail| {
LoadingProblem::ParsingFailed( LoadingProblem::ParsingFailed(
fail.map_problem(SyntaxError::Header) fail.map_problem(SyntaxError::Header)
.into_file_error(filename.clone()), .into_file_error(filename.clone()),
@ -1337,7 +1337,7 @@ fn load_packages_from_main<'a>(
use ast::Header::*; use ast::Header::*;
let packages = match parsed_module.header { let packages = match parsed_header.item {
App(AppHeader { packages, .. }) | Package(PackageHeader { packages, .. }) => { App(AppHeader { packages, .. }) | Package(PackageHeader { packages, .. }) => {
unspace(arena, packages.value.items) unspace(arena, packages.value.items)
} }
@ -2395,6 +2395,13 @@ fn update<'a>(
.pending_abilities .pending_abilities
.insert(module_id, constrained_module.module.abilities_store.clone()); .insert(module_id, constrained_module.module.abilities_store.clone());
if let Some(params_pattern) = constrained_module.module.params_pattern.clone() {
state
.module_cache
.param_patterns
.insert(module_id, params_pattern);
}
state state
.module_cache .module_cache
.constrained .constrained
@ -3349,7 +3356,7 @@ fn load_package_from_disk<'a>(
let parse_start = Instant::now(); let parse_start = Instant::now();
let bytes = arena.alloc(bytes_vec); let bytes = arena.alloc(bytes_vec);
let parse_state = roc_parse::state::State::new(bytes); let parse_state = roc_parse::state::State::new(bytes);
let parsed = roc_parse::module::parse_header(arena, parse_state.clone()); let parsed = roc_parse::header::parse_header(arena, parse_state.clone());
let parse_header_duration = parse_start.elapsed(); let parse_header_duration = parse_start.elapsed();
// Insert the first entries for this module's timings // Insert the first entries for this module's timings
@ -3360,8 +3367,8 @@ fn load_package_from_disk<'a>(
match parsed { match parsed {
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Module(header), item: ast::Header::Module(header),
.. ..
}, },
_parse_state, _parse_state,
@ -3369,8 +3376,8 @@ fn load_package_from_disk<'a>(
"expected platform/package module, got Module with header\n{header:?}" "expected platform/package module, got Module with header\n{header:?}"
))), ))),
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Hosted(header), item: ast::Header::Hosted(header),
.. ..
}, },
_parse_state, _parse_state,
@ -3378,8 +3385,8 @@ fn load_package_from_disk<'a>(
"expected platform/package module, got Hosted module with header\n{header:?}" "expected platform/package module, got Hosted module with header\n{header:?}"
))), ))),
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::App(header), item: ast::Header::App(header),
.. ..
}, },
_parse_state, _parse_state,
@ -3387,9 +3394,9 @@ fn load_package_from_disk<'a>(
"expected platform/package module, got App with header\n{header:?}" "expected platform/package module, got App with header\n{header:?}"
))), ))),
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Package(header), item: ast::Header::Package(header),
comments, before: comments,
}, },
parser_state, parser_state,
)) => { )) => {
@ -3430,9 +3437,9 @@ fn load_package_from_disk<'a>(
Ok(Msg::Many(messages)) Ok(Msg::Many(messages))
} }
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Platform(header), item: ast::Header::Platform(header),
comments, before: comments,
}, },
parser_state, parser_state,
)) => { )) => {
@ -3530,13 +3537,13 @@ fn load_builtin_module_help<'a>(
let opt_shorthand = None; let opt_shorthand = None;
let filename = PathBuf::from(filename); let filename = PathBuf::from(filename);
let parse_state = roc_parse::state::State::new(src_bytes.as_bytes()); let parse_state = roc_parse::state::State::new(src_bytes.as_bytes());
let parsed = roc_parse::module::parse_header(arena, parse_state.clone()); let parsed = roc_parse::header::parse_header(arena, parse_state.clone());
match parsed { match parsed {
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Module(header), item: ast::Header::Module(header),
comments, before: comments,
}, },
parse_state, parse_state,
)) => { )) => {
@ -3551,6 +3558,7 @@ fn load_builtin_module_help<'a>(
name: header::ModuleName::new(name_stem), name: header::ModuleName::new(name_stem),
exposes: unspace(arena, header.exposes.items), exposes: unspace(arena, header.exposes.items),
generates_with: &[], generates_with: &[],
opt_params: header.params,
}, },
module_comments: comments, module_comments: comments,
header_imports: header.interface_imports, header_imports: header.interface_imports,
@ -3786,7 +3794,7 @@ fn parse_header<'a>(
) -> Result<HeaderOutput<'a>, LoadingProblem<'a>> { ) -> Result<HeaderOutput<'a>, LoadingProblem<'a>> {
let parse_start = Instant::now(); let parse_start = Instant::now();
let parse_state = roc_parse::state::State::new(src_bytes); let parse_state = roc_parse::state::State::new(src_bytes);
let parsed = roc_parse::module::parse_header(arena, parse_state.clone()); let parsed = roc_parse::header::parse_header(arena, parse_state.clone());
let parse_header_duration = parse_start.elapsed(); let parse_header_duration = parse_start.elapsed();
if let Err(problem) = ensure_roc_file(&filename, src_bytes) { if let Err(problem) = ensure_roc_file(&filename, src_bytes) {
@ -3815,9 +3823,9 @@ fn parse_header<'a>(
match parsed { match parsed {
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Module(header), item: ast::Header::Module(header),
comments, before: comments,
}, },
parse_state, parse_state,
)) => { )) => {
@ -3837,6 +3845,7 @@ fn parse_header<'a>(
header_type: HeaderType::Module { header_type: HeaderType::Module {
name: roc_parse::header::ModuleName::new(module_name), name: roc_parse::header::ModuleName::new(module_name),
exposes: unspace(arena, header.exposes.items), exposes: unspace(arena, header.exposes.items),
opt_params: header.params,
}, },
module_comments: comments, module_comments: comments,
header_imports: header.interface_imports, header_imports: header.interface_imports,
@ -3852,9 +3861,9 @@ fn parse_header<'a>(
}) })
} }
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Hosted(header), item: ast::Header::Hosted(header),
comments, before: comments,
}, },
parse_state, parse_state,
)) => { )) => {
@ -3883,9 +3892,9 @@ fn parse_header<'a>(
}) })
} }
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::App(header), item: ast::Header::App(header),
comments, before: comments,
}, },
parse_state, parse_state,
)) => { )) => {
@ -3988,9 +3997,9 @@ fn parse_header<'a>(
}) })
} }
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Package(header), item: ast::Header::Package(header),
comments, before: comments,
}, },
parse_state, parse_state,
)) => { )) => {
@ -4015,9 +4024,9 @@ fn parse_header<'a>(
} }
Ok(( Ok((
ast::Module { ast::SpacesBefore {
header: ast::Header::Platform(header), item: ast::Header::Platform(header),
comments, before: comments,
}, },
parse_state, parse_state,
)) => { )) => {
@ -4380,7 +4389,7 @@ pub fn add_imports(
def_types: &mut Vec<(Symbol, Loc<TypeOrVar>)>, def_types: &mut Vec<(Symbol, Loc<TypeOrVar>)>,
imported_rigid_vars: &mut Vec<Variable>, imported_rigid_vars: &mut Vec<Variable>,
imported_flex_vars: &mut Vec<Variable>, imported_flex_vars: &mut Vec<Variable>,
) -> (Vec<Variable>, AbilitiesStore) { ) -> (Vec<Variable>, VecMap<ModuleId, Variable>, AbilitiesStore) {
let mut import_variables = Vec::new(); let mut import_variables = Vec::new();
let mut cached_symbol_vars = VecMap::default(); let mut cached_symbol_vars = VecMap::default();
@ -4487,7 +4496,31 @@ pub fn add_imports(
}, },
); );
(import_variables, abilities_store) let mut imported_param_vars = VecMap::default();
for (module_id, _) in exposed_for_module.exposed_by_module.iter_all() {
let ExposedModuleTypes {
exposed_types_storage_subs: exposed_types,
..
} = exposed_for_module.exposed_by_module.get(module_id).unwrap();
if let Some(stored_aprams_var) = exposed_types.stored_params_var {
let copied_import = exposed_types
.storage_subs
.export_variable_to(subs, stored_aprams_var);
let copied_import_var = extend_imports_data_with_copied_import(
copied_import,
&mut import_variables,
imported_rigid_vars,
imported_flex_vars,
);
imported_param_vars.insert(*module_id, copied_import_var);
}
}
(import_variables, imported_param_vars, abilities_store)
} }
enum OnSymbolNotFound { enum OnSymbolNotFound {
@ -4609,6 +4642,7 @@ fn run_solve_solve(
aliases, aliases,
rigid_variables, rigid_variables,
abilities_store: pending_abilities, abilities_store: pending_abilities,
params_pattern,
.. ..
} = module; } = module;
@ -4618,7 +4652,7 @@ fn run_solve_solve(
let mut subs = Subs::new_from_varstore(var_store); let mut subs = Subs::new_from_varstore(var_store);
let (import_variables, abilities_store) = add_imports( let (import_variables, imported_param_vars, abilities_store) = add_imports(
module.module_id, module.module_id,
&mut constraints, &mut constraints,
&mut subs, &mut subs,
@ -4656,6 +4690,8 @@ fn run_solve_solve(
derived_module, derived_module,
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
checkmate, checkmate,
params_pattern: params_pattern.map(|(_, _, pattern)| pattern.value),
module_params_vars: imported_param_vars,
}; };
let solve_output = roc_solve::module::run_solve( let solve_output = roc_solve::module::run_solve(
@ -4740,6 +4776,11 @@ fn run_solve<'a>(
// TODO remove when we write builtins in roc // TODO remove when we write builtins in roc
let aliases = module.aliases.clone(); let aliases = module.aliases.clone();
let opt_params_var = module
.params_pattern
.as_ref()
.map(|(params_var, _, _)| *params_var);
let mut module = module; let mut module = module;
let loc_expects = std::mem::take(&mut module.loc_expects); let loc_expects = std::mem::take(&mut module.loc_expects);
let loc_dbgs = std::mem::take(&mut module.loc_dbgs); let loc_dbgs = std::mem::take(&mut module.loc_dbgs);
@ -4811,6 +4852,7 @@ fn run_solve<'a>(
module_id, module_id,
&mut solved_subs, &mut solved_subs,
&exposed_vars_by_symbol, &exposed_vars_by_symbol,
opt_params_var,
&solved_implementations, &solved_implementations,
&abilities_store, &abilities_store,
); );
@ -4922,6 +4964,7 @@ fn build_platform_header<'a>(
.zip(requires.iter().copied()), .zip(requires.iter().copied()),
arena, arena,
); );
let packages = unspace(arena, header.packages.item.items);
let exposes = bumpalo::collections::Vec::from_iter_in( let exposes = bumpalo::collections::Vec::from_iter_in(
unspace(arena, header.exposes.item.items).iter().copied(), unspace(arena, header.exposes.item.items).iter().copied(),
arena, arena,
@ -4943,7 +4986,7 @@ fn build_platform_header<'a>(
filename, filename,
is_root_module, is_root_module,
opt_shorthand, opt_shorthand,
packages: &[], packages,
header_type, header_type,
module_comments: comments, module_comments: comments,
header_imports: Some(header.imports), header_imports: Some(header.imports),
@ -5059,6 +5102,7 @@ fn canonicalize_and_constrain<'a>(
module_output.symbols_from_requires, module_output.symbols_from_requires,
&module_output.scope.abilities_store, &module_output.scope.abilities_store,
&module_output.declarations, &module_output.declarations,
&module_output.params_pattern,
module_id, module_id,
) )
}; };
@ -5115,6 +5159,7 @@ fn canonicalize_and_constrain<'a>(
abilities_store: module_output.scope.abilities_store, abilities_store: module_output.scope.abilities_store,
loc_expects: module_output.loc_expects, loc_expects: module_output.loc_expects,
loc_dbgs: module_output.loc_dbgs, loc_dbgs: module_output.loc_dbgs,
params_pattern: module_output.params_pattern,
}; };
let constrained_module = ConstrainedModule { let constrained_module = ConstrainedModule {
@ -5152,7 +5197,7 @@ fn parse<'a>(
let parse_state = header.parse_state; let parse_state = header.parse_state;
let header_import_defs = let header_import_defs =
roc_parse::ast::Module::header_imports_to_defs(arena, header.header_imports); roc_parse::ast::Header::header_imports_to_defs(arena, header.header_imports);
let parsed_defs = match parse_module_defs(arena, parse_state.clone(), header_import_defs) { let parsed_defs = match parse_module_defs(arena, parse_state.clone(), header_import_defs) {
Ok(success) => success, Ok(success) => success,
@ -5458,6 +5503,7 @@ fn make_specializations<'a>(
) -> Msg<'a> { ) -> Msg<'a> {
let make_specializations_start = Instant::now(); let make_specializations_start = Instant::now();
let mut update_mode_ids = UpdateModeIds::new(); let mut update_mode_ids = UpdateModeIds::new();
// do the thing // do the thing
let mut mono_env = roc_mono::ir::Env { let mut mono_env = roc_mono::ir::Env {
arena, arena,

View file

@ -4,12 +4,13 @@ use crate::module::{
ModuleHeader, ParsedModule, TypeCheckedModule, ModuleHeader, ParsedModule, TypeCheckedModule,
}; };
use roc_can::abilities::PendingAbilitiesStore; use roc_can::abilities::PendingAbilitiesStore;
use roc_can::expr::AnnotatedMark;
use roc_collections::{MutMap, MutSet, VecMap}; use roc_collections::{MutMap, MutSet, VecMap};
use roc_module::ident::ModuleName; use roc_module::ident::ModuleName;
use roc_module::symbol::{ModuleId, PQModuleName, Symbol}; use roc_module::symbol::{ModuleId, PQModuleName, Symbol};
use roc_mono::ir::ExternalSpecializations; use roc_mono::ir::ExternalSpecializations;
use roc_problem::Severity; use roc_problem::Severity;
use roc_region::all::Region; use roc_region::all::{Loc, Region};
use roc_solve_problem::TypeError; use roc_solve_problem::TypeError;
use roc_types::subs::Variable; use roc_types::subs::Variable;
use roc_types::types::Alias; use roc_types::types::Alias;
@ -26,6 +27,8 @@ pub(crate) struct ModuleCache<'a> {
pub(crate) aliases: MutMap<ModuleId, MutMap<Symbol, (bool, Alias)>>, pub(crate) aliases: MutMap<ModuleId, MutMap<Symbol, (bool, Alias)>>,
pub(crate) pending_abilities: MutMap<ModuleId, PendingAbilitiesStore>, pub(crate) pending_abilities: MutMap<ModuleId, PendingAbilitiesStore>,
pub(crate) constrained: MutMap<ModuleId, ConstrainedModule>, pub(crate) constrained: MutMap<ModuleId, ConstrainedModule>,
pub(crate) param_patterns:
MutMap<ModuleId, (Variable, AnnotatedMark, Loc<roc_can::pattern::Pattern>)>,
pub(crate) typechecked: MutMap<ModuleId, TypeCheckedModule<'a>>, pub(crate) typechecked: MutMap<ModuleId, TypeCheckedModule<'a>>,
pub(crate) checked: MutMap<ModuleId, CheckedModule>, pub(crate) checked: MutMap<ModuleId, CheckedModule>,
pub(crate) found_specializations: MutMap<ModuleId, FoundSpecializationsModule<'a>>, pub(crate) found_specializations: MutMap<ModuleId, FoundSpecializationsModule<'a>>,
@ -100,6 +103,7 @@ impl Default for ModuleCache<'_> {
aliases: Default::default(), aliases: Default::default(),
pending_abilities: Default::default(), pending_abilities: Default::default(),
constrained: Default::default(), constrained: Default::default(),
param_patterns: Default::default(),
typechecked: Default::default(), typechecked: Default::default(),
checked: Default::default(), checked: Default::default(),
found_specializations: Default::default(), found_specializations: Default::default(),

View file

@ -27,10 +27,11 @@ use roc_module::symbol::{Interns, ModuleId};
use roc_packaging::cache::RocCacheDir; use roc_packaging::cache::RocCacheDir;
use roc_problem::can::Problem; use roc_problem::can::Problem;
use roc_region::all::LineInfo; use roc_region::all::LineInfo;
use roc_reporting::report::RocDocAllocator;
use roc_reporting::report::{can_problem, DEFAULT_PALETTE}; use roc_reporting::report::{can_problem, DEFAULT_PALETTE};
use roc_reporting::report::{strip_colors, RenderTarget}; use roc_reporting::report::{strip_colors, RenderTarget};
use roc_reporting::report::{type_problem, RocDocAllocator};
use roc_solve::FunctionKind; use roc_solve::FunctionKind;
use roc_solve_problem::TypeError;
use roc_target::Target; use roc_target::Target;
use roc_test_utils_dir::TmpDir; use roc_test_utils_dir::TmpDir;
use roc_types::pretty_print::name_and_print_var; use roc_types::pretty_print::name_and_print_var;
@ -107,6 +108,33 @@ fn format_can_problems(
buf buf
} }
fn format_type_problems(
problems: Vec<TypeError>,
home: ModuleId,
interns: &Interns,
filename: PathBuf,
src: &str,
) -> String {
use ven_pretty::DocAllocator;
let src_lines: Vec<&str> = src.split('\n').collect();
let lines = LineInfo::new(src);
let alloc = RocDocAllocator::new(&src_lines, home, interns);
let reports = problems
.into_iter()
.flat_map(|problem| type_problem(&alloc, &lines, filename.clone(), problem))
.map(|report| report.pretty(&alloc));
let mut buf = String::new();
alloc
.stack(reports)
.append(alloc.line())
.1
.render_raw(70, &mut roc_reporting::report::CiWrite::new(&mut buf))
.unwrap();
buf
}
fn multiple_modules(subdir: &str, files: Vec<(&str, &str)>) -> Result<LoadedModule, String> { fn multiple_modules(subdir: &str, files: Vec<(&str, &str)>) -> Result<LoadedModule, String> {
let arena = Bump::new(); let arena = Bump::new();
let arena = &arena; let arena = &arena;
@ -130,11 +158,19 @@ fn multiple_modules(subdir: &str, files: Vec<(&str, &str)>) -> Result<LoadedModu
)); ));
} }
assert!(loaded_module let type_problems = loaded_module
.type_problems .type_problems
.remove(&home) .remove(&home)
.unwrap_or_default() .unwrap_or_default();
.is_empty(),); if !type_problems.is_empty() {
return Err(format_type_problems(
type_problems,
home,
&loaded_module.interns,
filepath.clone(),
src,
));
}
Ok(loaded_module) Ok(loaded_module)
} }
@ -279,6 +315,13 @@ fn expect_types(mut loaded_module: LoadedModule, mut expected_types: HashMap<&st
match declarations.declarations[index] { match declarations.declarations[index] {
Value | Function(_) | Recursive(_) | TailRecursive(_) => { Value | Function(_) | Recursive(_) | TailRecursive(_) => {
let body = declarations.expressions[index].clone();
if let roc_can::expr::Expr::ImportParams(_, _, None) = body.value {
// Skip import defs without params
continue;
}
let symbol = declarations.symbols[index].value; let symbol = declarations.symbols[index].value;
let expr_var = declarations.variables[index]; let expr_var = declarations.variables[index];
@ -407,8 +450,14 @@ fn module_with_deps() {
match declarations.declarations[index] { match declarations.declarations[index] {
Value | Function(_) | Recursive(_) | TailRecursive(_) => { Value | Function(_) | Recursive(_) | TailRecursive(_) => {
let body = declarations.expressions[index].clone();
if let roc_can::expr::Expr::ImportParams(_, _, None) = body.value {
// Skip import defs without params
} else {
def_count += 1; def_count += 1;
} }
}
Destructure(_) => { Destructure(_) => {
def_count += 1; def_count += 1;
} }
@ -1563,6 +1612,325 @@ fn cannot_use_original_name_if_imported_with_alias() {
multiple_modules("cannot_use_original_name_if_imported_with_alias", modules).unwrap_err(); multiple_modules("cannot_use_original_name_if_imported_with_alias", modules).unwrap_err();
} }
#[test]
fn module_params_checks() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key } -> [url]
url = "example.com/$(key)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: "abcdef" }
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_checks", modules);
assert!(result.is_ok());
}
#[test]
fn module_params_optional() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key, exp ? "default" } -> [url]
url = "example.com/$(key)?exp=$(exp)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: "abcdef" }
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_optional", modules);
assert!(result.is_ok())
}
#[test]
fn module_params_typecheck_fail() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key } -> [url]
url = "example.com/$(key)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: 123 }
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_typecheck_fail", modules).unwrap_err();
assert_eq!(
result,
indoc!(
r#"
MODULE PARAMS MISMATCH in tmp/module_params_typecheck_fail/Main.roc
Something is off with the params provided by this import:
3 import Api { key: 123 }
^^^^^^^^^^^^
This is the type I inferred:
{ key : Num * }
However, Api expects:
{ key : Str }
"#
)
);
}
#[test]
fn module_params_missing_fields() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key } -> [url]
url = "example.com/$(key)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api {}
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_missing_fields", modules).unwrap_err();
assert_eq!(
result,
indoc!(
r#"
MODULE PARAMS MISMATCH in tmp/module_params_missing_fields/Main.roc
Something is off with the params provided by this import:
3 import Api {}
^^
This is the type I inferred:
{}
However, Api expects:
{ key : Str }
Tip: Looks like the key field is missing.
"#
)
);
}
#[test]
fn module_params_extra_fields() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key } -> [url]
url = "example.com/$(key)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: "123", doesNotExist: Bool.true }
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_extra_fields", modules).unwrap_err();
assert_eq!(
result,
indoc!(
r#"
MODULE PARAMS MISMATCH in tmp/module_params_extra_fields/Main.roc
Something is off with the params provided by this import:
3 import Api { key: "123", doesNotExist: Bool.true }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the type I inferred:
{ doesNotExist : Bool, }
However, Api expects:
{ }
"#
)
);
}
#[test]
fn module_params_unexpected() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module [url]
url = "example.com"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: 123 }
example = Api.url
"#
),
),
];
let err = multiple_modules("module_params_unexpected", modules).unwrap_err();
assert_eq!(
err,
indoc!(
r#"
UNEXPECTED MODULE PARAMS in tmp/module_params_unexpected/Main.roc
This import specifies module params:
3 import Api { key: 123 }
^^^^^^^^^^^^
However, Api does not expect any. Did you intend to import a different
module?
"#
)
)
}
#[test]
fn module_params_missing() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key, exp } -> [url]
url = "example.com/$(key)?exp=$(Num.toStr exp)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api
example = Api.url
"#
),
),
];
let err = multiple_modules("module_params_missing", modules).unwrap_err();
assert_eq!(
err,
indoc!(
r#"
MISSING MODULE PARAMS in tmp/module_params_missing/Main.roc
This import specifies no module params:
3 import Api
^^^^^^^^^^
However, Api expects the following to be provided:
{
exp : Num *,
key : Str,
}
You can provide params after the module name, like:
import Menu { echo, read }
"#
)
)
}
#[test] #[test]
fn issue_2863_module_type_does_not_exist() { fn issue_2863_module_type_does_not_exist() {
let modules = vec![ let modules = vec![

View file

@ -627,67 +627,12 @@ impl ModuleIds {
pub fn available_modules(&self) -> impl Iterator<Item = &ModuleName> { pub fn available_modules(&self) -> impl Iterator<Item = &ModuleName> {
self.by_id.iter() self.by_id.iter()
} }
}
#[derive(Debug, Clone)] pub fn iter(&self) -> impl ExactSizeIterator<Item = (ModuleId, &ModuleName)> {
pub struct ScopeModules { self.by_id
modules: VecMap<ModuleName, ModuleId>, .iter()
sources: VecMap<ModuleId, ScopeModuleSource>, .enumerate()
} .map(|(index, name)| (ModuleId::from_zero_indexed(index), name))
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScopeModuleSource {
Builtin,
Current,
Import(Region),
}
impl ScopeModules {
pub fn get_id(&self, module_name: &ModuleName) -> Option<ModuleId> {
self.modules.get(module_name).copied()
}
pub fn has_id(&self, module_id: ModuleId) -> bool {
self.sources.contains_key(&module_id)
}
pub fn available_names(&self) -> impl Iterator<Item = &ModuleName> {
self.modules.keys()
}
pub fn insert(
&mut self,
module_name: ModuleName,
module_id: ModuleId,
region: Region,
) -> Result<(), ScopeModuleSource> {
if let Some(existing_module_id) = self.modules.get(&module_name) {
if *existing_module_id == module_id {
return Ok(());
}
return Err(*self.sources.get(existing_module_id).unwrap());
}
self.modules.insert(module_name, module_id);
self.sources
.insert(module_id, ScopeModuleSource::Import(region));
Ok(())
}
pub fn len(&self) -> usize {
debug_assert_eq!(self.modules.len(), self.sources.len());
self.modules.len()
}
pub fn is_empty(&self) -> bool {
debug_assert_eq!(self.modules.is_empty(), self.sources.is_empty());
self.modules.is_empty()
}
pub fn truncate(&mut self, len: usize) {
self.modules.truncate(len);
self.sources.truncate(len);
} }
} }
@ -1031,32 +976,6 @@ macro_rules! define_builtins {
} }
} }
impl ScopeModules {
pub fn new(home_id: ModuleId, home_name: ModuleName) -> Self {
// +1 because the user will be compiling at least 1 non-builtin module!
let capacity = $total + 1;
let mut modules = VecMap::with_capacity(capacity);
let mut sources = VecMap::with_capacity(capacity);
modules.insert(home_name, home_id);
sources.insert(home_id, ScopeModuleSource::Current);
let mut insert_both = |id: ModuleId, name_str: &'static str| {
let name: ModuleName = name_str.into();
modules.insert(name, id);
sources.insert(id, ScopeModuleSource::Builtin);
};
$(
insert_both(ModuleId::$module_const, $module_name);
)+
ScopeModules { modules, sources }
}
}
impl<'a> Default for PackageModuleIds<'a> { impl<'a> Default for PackageModuleIds<'a> {
fn default() -> Self { fn default() -> Self {
// +1 because the user will be compiling at least 1 non-builtin module! // +1 because the user will be compiling at least 1 non-builtin module!
@ -1556,6 +1475,8 @@ define_builtins! {
5 RESULT_WITH_DEFAULT: "withDefault" 5 RESULT_WITH_DEFAULT: "withDefault"
6 RESULT_TRY: "try" 6 RESULT_TRY: "try"
7 RESULT_IS_OK: "isOk" 7 RESULT_IS_OK: "isOk"
8 RESULT_MAP_BOTH: "mapBoth"
9 RESULT_MAP_TWO: "map2"
} }
8 DICT: "Dict" => { 8 DICT: "Dict" => {
0 DICT_DICT: "Dict" exposed_type=true // the Dict.Dict type alias 0 DICT_DICT: "Dict" exposed_type=true // the Dict.Dict type alias

View file

@ -4443,6 +4443,15 @@ pub fn with_hole<'a>(
specialize_naked_symbol(env, variable, procs, layout_cache, assigned, hole, symbol) specialize_naked_symbol(env, variable, procs, layout_cache, assigned, hole, symbol)
} }
ParamsVar { .. } => {
unimplemented!("module params code generation")
}
ImportParams(_, _, Some((_, value))) => {
with_hole(env, *value, variable, procs, layout_cache, assigned, hole)
}
ImportParams(_, _, None) => {
internal_error!("Missing module params should've been dropped by now");
}
AbilityMember(member, specialization_id, specialization_var) => { AbilityMember(member, specialization_id, specialization_var) => {
let specialization_symbol = late_resolve_ability_specialization( let specialization_symbol = late_resolve_ability_specialization(
env, env,

View file

@ -2,7 +2,7 @@ use bumpalo::Bump;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{black_box, criterion_group, criterion_main, Criterion};
use roc_parse::{ use roc_parse::{
ast::Defs, ast::Defs,
module::{self, parse_module_defs}, header::{self, parse_module_defs},
state::State, state::State,
}; };
use std::path::PathBuf; use std::path::PathBuf;
@ -20,7 +20,7 @@ pub fn parse_benchmark(c: &mut Criterion) {
let arena = Bump::new(); let arena = Bump::new();
let (_actual, state) = let (_actual, state) =
module::parse_header(&arena, State::new(src.as_bytes())).unwrap(); header::parse_header(&arena, State::new(src.as_bytes())).unwrap();
let res = parse_module_defs(&arena, state, Defs::default()).unwrap(); let res = parse_module_defs(&arena, state, Defs::default()).unwrap();
@ -41,7 +41,7 @@ pub fn parse_benchmark(c: &mut Criterion) {
let arena = Bump::new(); let arena = Bump::new();
let (_actual, state) = let (_actual, state) =
module::parse_header(&arena, State::new(src.as_bytes())).unwrap(); header::parse_header(&arena, State::new(src.as_bytes())).unwrap();
let res = parse_module_defs(&arena, state, Defs::default()).unwrap(); let res = parse_module_defs(&arena, state, Defs::default()).unwrap();

View file

@ -14,6 +14,12 @@ use roc_module::called_via::{BinOp, CalledVia, UnaryOp};
use roc_module::ident::QualifiedModuleName; use roc_module::ident::QualifiedModuleName;
use roc_region::all::{Loc, Position, Region}; use roc_region::all::{Loc, Position, Region};
#[derive(Debug, Clone)]
pub struct FullAst<'a> {
pub header: SpacesBefore<'a, Header<'a>>,
pub defs: Defs<'a>,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Spaces<'a, T> { pub struct Spaces<'a, T> {
pub before: &'a [CommentOrNewline<'a>], pub before: &'a [CommentOrNewline<'a>],
@ -111,15 +117,9 @@ impl<'a, T: ExtractSpaces<'a>> ExtractSpaces<'a> for Loc<T> {
} }
} }
#[derive(Clone, Debug, PartialEq)] impl<'a> Header<'a> {
pub struct Module<'a> {
pub comments: &'a [CommentOrNewline<'a>],
pub header: Header<'a>,
}
impl<'a> Module<'a> {
pub fn upgrade_header_imports(self, arena: &'a Bump) -> (Self, Defs<'a>) { pub fn upgrade_header_imports(self, arena: &'a Bump) -> (Self, Defs<'a>) {
let (header, defs) = match self.header { let (header, defs) = match self {
Header::Module(header) => ( Header::Module(header) => (
Header::Module(ModuleHeader { Header::Module(ModuleHeader {
interface_imports: None, interface_imports: None,
@ -134,12 +134,10 @@ impl<'a> Module<'a> {
}), }),
Self::header_imports_to_defs(arena, header.old_imports), Self::header_imports_to_defs(arena, header.old_imports),
), ),
Header::Package(_) | Header::Platform(_) | Header::Hosted(_) => { Header::Package(_) | Header::Platform(_) | Header::Hosted(_) => (self, Defs::default()),
(self.header, Defs::default())
}
}; };
(Module { header, ..self }, defs) (header, defs)
} }
pub fn header_imports_to_defs( pub fn header_imports_to_defs(
@ -681,9 +679,9 @@ fn is_when_branch_suffixed(branch: &WhenBranch<'_>) -> bool {
fn is_assigned_value_suffixed<'a>(value: &AssignedField<'a, Expr<'a>>) -> bool { fn is_assigned_value_suffixed<'a>(value: &AssignedField<'a, Expr<'a>>) -> bool {
match value { match value {
AssignedField::RequiredValue(_, _, a) | AssignedField::OptionalValue(_, _, a) => { AssignedField::RequiredValue(_, _, a)
is_expr_suffixed(&a.value) | AssignedField::OptionalValue(_, _, a)
} | AssignedField::IgnoredValue(_, _, a) => is_expr_suffixed(&a.value),
AssignedField::LabelOnly(_) => false, AssignedField::LabelOnly(_) => false,
AssignedField::SpaceBefore(a, _) | AssignedField::SpaceAfter(a, _) => { AssignedField::SpaceBefore(a, _) | AssignedField::SpaceAfter(a, _) => {
is_assigned_value_suffixed(a) is_assigned_value_suffixed(a)
@ -869,9 +867,9 @@ impl<'a, 'b> RecursiveValueDefIter<'a, 'b> {
use AssignedField::*; use AssignedField::*;
match current { match current {
RequiredValue(_, _, loc_val) | OptionalValue(_, _, loc_val) => { RequiredValue(_, _, loc_val)
break expr_stack.push(&loc_val.value) | OptionalValue(_, _, loc_val)
} | IgnoredValue(_, _, loc_val) => break expr_stack.push(&loc_val.value),
SpaceBefore(next, _) | SpaceAfter(next, _) => current = *next, SpaceBefore(next, _) | SpaceAfter(next, _) => current = *next,
LabelOnly(_) | Malformed(_) => break, LabelOnly(_) | Malformed(_) => break,
} }
@ -1070,7 +1068,7 @@ impl<'a, 'b> Iterator for RecursiveValueDefIter<'a, 'b> {
params, params,
}) => { }) => {
if let Some(ModuleImportParams { before: _, params }) = params { if let Some(ModuleImportParams { before: _, params }) = params {
for loc_assigned_field in params.items { for loc_assigned_field in params.value.items {
if let Some(expr) = loc_assigned_field.value.value() { if let Some(expr) = loc_assigned_field.value.value() {
self.push_pending_from_expr(&expr.value); self.push_pending_from_expr(&expr.value);
} }
@ -1118,7 +1116,7 @@ pub struct ModuleImport<'a> {
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct ModuleImportParams<'a> { pub struct ModuleImportParams<'a> {
pub before: &'a [CommentOrNewline<'a>], pub before: &'a [CommentOrNewline<'a>],
pub params: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>, pub params: Loc<Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>>,
} }
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
@ -1598,6 +1596,9 @@ pub enum AssignedField<'a, Val> {
// and in destructuring patterns (e.g. `{ name ? "blah" }`) // and in destructuring patterns (e.g. `{ name ? "blah" }`)
OptionalValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc<Val>), OptionalValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc<Val>),
// An ignored field, e.g. `{ _name: "blah" }` or `{ _ : Str }`
IgnoredValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc<Val>),
// A label with no value, e.g. `{ name }` (this is sugar for { name: name }) // A label with no value, e.g. `{ name }` (this is sugar for { name: name })
LabelOnly(Loc<&'a str>), LabelOnly(Loc<&'a str>),
@ -1615,7 +1616,9 @@ impl<'a, Val> AssignedField<'a, Val> {
loop { loop {
match current { match current {
Self::RequiredValue(_, _, val) | Self::OptionalValue(_, _, val) => break Some(val), Self::RequiredValue(_, _, val)
| Self::OptionalValue(_, _, val)
| Self::IgnoredValue(_, _, val) => break Some(val),
Self::LabelOnly(_) | Self::Malformed(_) => break None, Self::LabelOnly(_) | Self::Malformed(_) => break None,
Self::SpaceBefore(next, _) | Self::SpaceAfter(next, _) => current = *next, Self::SpaceBefore(next, _) | Self::SpaceAfter(next, _) => current = *next,
} }
@ -2433,9 +2436,9 @@ pub trait Malformed {
fn is_malformed(&self) -> bool; fn is_malformed(&self) -> bool;
} }
impl<'a> Malformed for Module<'a> { impl<'a> Malformed for FullAst<'a> {
fn is_malformed(&self) -> bool { fn is_malformed(&self) -> bool {
self.header.is_malformed() self.header.item.is_malformed() || self.defs.is_malformed()
} }
} }
@ -2457,6 +2460,12 @@ impl<'a, T: Malformed> Malformed for Spaces<'a, T> {
} }
} }
impl<'a, T: Malformed> Malformed for SpacesBefore<'a, T> {
fn is_malformed(&self) -> bool {
self.item.is_malformed()
}
}
impl<'a> Malformed for Expr<'a> { impl<'a> Malformed for Expr<'a> {
fn is_malformed(&self) -> bool { fn is_malformed(&self) -> bool {
use Expr::*; use Expr::*;
@ -2577,9 +2586,9 @@ impl<T: Malformed> Malformed for Option<T> {
impl<'a, T: Malformed> Malformed for AssignedField<'a, T> { impl<'a, T: Malformed> Malformed for AssignedField<'a, T> {
fn is_malformed(&self) -> bool { fn is_malformed(&self) -> bool {
match self { match self {
AssignedField::RequiredValue(_, _, val) | AssignedField::OptionalValue(_, _, val) => { AssignedField::RequiredValue(_, _, val)
val.is_malformed() | AssignedField::OptionalValue(_, _, val)
} | AssignedField::IgnoredValue(_, _, val) => val.is_malformed(),
AssignedField::LabelOnly(_) => false, AssignedField::LabelOnly(_) => false,
AssignedField::SpaceBefore(field, _) | AssignedField::SpaceAfter(field, _) => { AssignedField::SpaceBefore(field, _) | AssignedField::SpaceAfter(field, _) => {
field.is_malformed() field.is_malformed()

View file

@ -9,10 +9,10 @@ use crate::blankspace::{
loc_space0_e, require_newline_or_eof, space0_after_e, space0_around_ee, space0_before_e, loc_space0_e, require_newline_or_eof, space0_after_e, space0_around_ee, space0_before_e,
space0_before_optional_after, space0_e, spaces, spaces_around, spaces_before, space0_before_optional_after, space0_e, spaces, spaces_around, spaces_before,
}; };
use crate::header::module_name_help;
use crate::ident::{ use crate::ident::{
integer_ident, lowercase_ident, parse_ident, unqualified_ident, Accessor, Ident, Suffix, integer_ident, lowercase_ident, parse_ident, unqualified_ident, Accessor, Ident, Suffix,
}; };
use crate::module::module_name_help;
use crate::parser::{ use crate::parser::{
self, and, backtrackable, between, byte, byte_indent, collection_inner, self, and, backtrackable, between, byte, byte_indent, collection_inner,
collection_trailing_sep_e, either, increment_min_indent, indented_seq_skip_first, loc, map, collection_trailing_sep_e, either, increment_min_indent, indented_seq_skip_first, loc, map,
@ -24,8 +24,8 @@ use crate::parser::{
use crate::pattern::closure_param; use crate::pattern::closure_param;
use crate::state::State; use crate::state::State;
use crate::string_literal::{self, StrLikeLiteral}; use crate::string_literal::{self, StrLikeLiteral};
use crate::type_annotation;
use crate::{header, keyword}; use crate::{header, keyword};
use crate::{module, type_annotation};
use bumpalo::collections::Vec; use bumpalo::collections::Vec;
use bumpalo::Bump; use bumpalo::Bump;
use roc_collections::soa::Slice; use roc_collections::soa::Slice;
@ -892,10 +892,10 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams<
then( then(
and( and(
backtrackable(space0_e(EImportParams::Indent)), backtrackable(space0_e(EImportParams::Indent)),
specialize_err(EImportParams::Record, record_help()), specialize_err(EImportParams::Record, loc(record_help())),
), ),
|arena, state, _, (before, record): (_, RecordHelp<'a>)| { |arena, state, _, (before, loc_record): (_, Loc<RecordHelp<'a>>)| {
if let Some(prefix) = record.prefix { if let Some(prefix) = loc_record.value.prefix {
match prefix { match prefix {
(update, RecordHelpPrefix::Update) => { (update, RecordHelpPrefix::Update) => {
return Err(( return Err((
@ -912,8 +912,15 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams<
} }
} }
let params = record.fields.map_items_result(arena, |loc_field| { let params = loc_record
.value
.fields
.map_items_result(arena, |loc_field| {
match loc_field.value.to_assigned_field(arena) { match loc_field.value.to_assigned_field(arena) {
Ok(AssignedField::IgnoredValue(_, _, _)) => Err((
MadeProgress,
EImportParams::RecordIgnoredFieldFound(loc_field.region),
)),
Ok(field) => Ok(Loc::at(loc_field.region, field)), Ok(field) => Ok(Loc::at(loc_field.region, field)),
Err(FoundApplyValue) => Err(( Err(FoundApplyValue) => Err((
MadeProgress, MadeProgress,
@ -922,7 +929,10 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams<
} }
})?; })?;
let import_params = ModuleImportParams { before, params }; let import_params = ModuleImportParams {
before,
params: Loc::at(loc_record.region, params),
};
Ok((MadeProgress, import_params, state)) Ok((MadeProgress, import_params, state))
}, },
@ -944,7 +954,7 @@ fn imported_module_name<'a>() -> impl Parser<'a, ImportedModuleName<'a>, EImport
fn import_as<'a>( fn import_as<'a>(
) -> impl Parser<'a, header::KeywordItem<'a, ImportAsKeyword, Loc<ImportAlias<'a>>>, EImport<'a>> { ) -> impl Parser<'a, header::KeywordItem<'a, ImportAsKeyword, Loc<ImportAlias<'a>>>, EImport<'a>> {
record!(header::KeywordItem { record!(header::KeywordItem {
keyword: module::spaces_around_keyword( keyword: header::spaces_around_keyword(
ImportAsKeyword, ImportAsKeyword,
EImport::As, EImport::As,
EImport::IndentAs, EImport::IndentAs,
@ -978,7 +988,7 @@ fn import_exposing<'a>() -> impl Parser<
EImport<'a>, EImport<'a>,
> { > {
record!(header::KeywordItem { record!(header::KeywordItem {
keyword: module::spaces_around_keyword( keyword: header::spaces_around_keyword(
ImportExposingKeyword, ImportExposingKeyword,
EImport::Exposing, EImport::Exposing,
EImport::IndentExposing, EImport::IndentExposing,
@ -1023,7 +1033,7 @@ fn import_ingested_file_body<'a>() -> impl Parser<'a, ValueDef<'a>, EImport<'a>>
fn import_ingested_file_as<'a>( fn import_ingested_file_as<'a>(
) -> impl Parser<'a, header::KeywordItem<'a, ImportAsKeyword, Loc<&'a str>>, EImport<'a>> { ) -> impl Parser<'a, header::KeywordItem<'a, ImportAsKeyword, Loc<&'a str>>, EImport<'a>> {
record!(header::KeywordItem { record!(header::KeywordItem {
keyword: module::spaces_around_keyword( keyword: header::spaces_around_keyword(
ImportAsKeyword, ImportAsKeyword,
EImport::As, EImport::As,
EImport::IndentAs, EImport::IndentAs,
@ -2234,6 +2244,7 @@ fn assigned_expr_field_to_pattern_help<'a>(
spaces, spaces,
), ),
AssignedField::Malformed(string) => Pattern::Malformed(string), AssignedField::Malformed(string) => Pattern::Malformed(string),
AssignedField::IgnoredValue(_, _, _) => return Err(()),
}) })
} }
@ -3322,6 +3333,7 @@ fn list_literal_help<'a>() -> impl Parser<'a, Expr<'a>, EList<'a>> {
pub enum RecordField<'a> { pub enum RecordField<'a> {
RequiredValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc<Expr<'a>>), RequiredValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc<Expr<'a>>),
OptionalValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc<Expr<'a>>), OptionalValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc<Expr<'a>>),
IgnoredValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc<Expr<'a>>),
LabelOnly(Loc<&'a str>), LabelOnly(Loc<&'a str>),
SpaceBefore(&'a RecordField<'a>, &'a [CommentOrNewline<'a>]), SpaceBefore(&'a RecordField<'a>, &'a [CommentOrNewline<'a>]),
SpaceAfter(&'a RecordField<'a>, &'a [CommentOrNewline<'a>]), SpaceAfter(&'a RecordField<'a>, &'a [CommentOrNewline<'a>]),
@ -3337,7 +3349,10 @@ pub enum RecordField<'a> {
pub struct FoundApplyValue; pub struct FoundApplyValue;
#[derive(Debug)] #[derive(Debug)]
struct FoundOptionalValue; pub enum NotOldBuilderFieldValue {
FoundOptionalValue,
FoundIgnoredValue,
}
impl<'a> RecordField<'a> { impl<'a> RecordField<'a> {
fn is_apply_value(&self) -> bool { fn is_apply_value(&self) -> bool {
@ -3354,6 +3369,20 @@ impl<'a> RecordField<'a> {
} }
} }
fn is_ignored_value(&self) -> bool {
let mut current = self;
loop {
match current {
RecordField::IgnoredValue(_, _, _) => break true,
RecordField::SpaceBefore(field, _) | RecordField::SpaceAfter(field, _) => {
current = *field;
}
_ => break false,
}
}
}
pub fn to_assigned_field( pub fn to_assigned_field(
self, self,
arena: &'a Bump, arena: &'a Bump,
@ -3369,6 +3398,10 @@ impl<'a> RecordField<'a> {
Ok(OptionalValue(loc_label, spaces, loc_expr)) Ok(OptionalValue(loc_label, spaces, loc_expr))
} }
RecordField::IgnoredValue(loc_label, spaces, loc_expr) => {
Ok(IgnoredValue(loc_label, spaces, loc_expr))
}
RecordField::LabelOnly(loc_label) => Ok(LabelOnly(loc_label)), RecordField::LabelOnly(loc_label) => Ok(LabelOnly(loc_label)),
RecordField::ApplyValue(_, _, _, _) => Err(FoundApplyValue), RecordField::ApplyValue(_, _, _, _) => Err(FoundApplyValue),
@ -3390,7 +3423,7 @@ impl<'a> RecordField<'a> {
fn to_builder_field( fn to_builder_field(
self, self,
arena: &'a Bump, arena: &'a Bump,
) -> Result<OldRecordBuilderField<'a>, FoundOptionalValue> { ) -> Result<OldRecordBuilderField<'a>, NotOldBuilderFieldValue> {
use OldRecordBuilderField::*; use OldRecordBuilderField::*;
match self { match self {
@ -3398,7 +3431,9 @@ impl<'a> RecordField<'a> {
Ok(Value(loc_label, spaces, loc_expr)) Ok(Value(loc_label, spaces, loc_expr))
} }
RecordField::OptionalValue(_, _, _) => Err(FoundOptionalValue), RecordField::OptionalValue(_, _, _) => Err(NotOldBuilderFieldValue::FoundOptionalValue),
RecordField::IgnoredValue(_, _, _) => Err(NotOldBuilderFieldValue::FoundIgnoredValue),
RecordField::LabelOnly(loc_label) => Ok(LabelOnly(loc_label)), RecordField::LabelOnly(loc_label) => Ok(LabelOnly(loc_label)),
@ -3434,6 +3469,7 @@ pub fn record_field<'a>() -> impl Parser<'a, RecordField<'a>, ERecord<'a>> {
use RecordField::*; use RecordField::*;
map_with_arena( map_with_arena(
either(
and( and(
specialize_err(|_, pos| ERecord::Field(pos), loc(lowercase_ident())), specialize_err(|_, pos| ERecord::Field(pos), loc(lowercase_ident())),
and( and(
@ -3447,7 +3483,26 @@ pub fn record_field<'a>() -> impl Parser<'a, RecordField<'a>, ERecord<'a>> {
)), )),
), ),
), ),
|arena: &'a bumpalo::Bump, (loc_label, (spaces, opt_loc_val))| { and(
loc(skip_first(
byte(b'_', ERecord::UnderscoreField),
optional(specialize_err(
|_, pos| ERecord::Field(pos),
lowercase_ident(),
)),
)),
and(
spaces(),
skip_first(
byte(b':', ERecord::Colon),
spaces_before(specialize_err_ref(ERecord::Expr, loc_expr(false))),
),
),
),
),
|arena: &'a bumpalo::Bump, field_data| {
match field_data {
Either::First((loc_label, (spaces, opt_loc_val))) => {
match opt_loc_val { match opt_loc_val {
Some(Either::First((_, RecordFieldExpr::Value(loc_val)))) => { Some(Either::First((_, RecordFieldExpr::Value(loc_val)))) => {
RequiredValue(loc_label, spaces, arena.alloc(loc_val)) RequiredValue(loc_label, spaces, arena.alloc(loc_val))
@ -3471,6 +3526,14 @@ pub fn record_field<'a>() -> impl Parser<'a, RecordField<'a>, ERecord<'a>> {
} }
} }
} }
}
Either::Second((loc_opt_label, (spaces, loc_val))) => {
let loc_label = loc_opt_label
.map(|opt_label| opt_label.unwrap_or_else(|| arena.alloc_str("")));
IgnoredValue(loc_label, spaces, arena.alloc(loc_val))
}
}
}, },
) )
} }
@ -3573,20 +3636,23 @@ fn record_literal_help<'a>() -> impl Parser<'a, Expr<'a>, EExpr<'a>> {
new_record_builder_help(arena, mapper, record.fields) new_record_builder_help(arena, mapper, record.fields)
} }
None => { None => {
let is_old_record_builder = record let special_field_found = record.fields.iter().find_map(|field| {
.fields if field.value.is_apply_value() {
.iter() Some(old_record_builder_help(arena, record.fields))
.any(|field| field.value.is_apply_value()); } else if field.value.is_ignored_value() {
Some(Err(EExpr::RecordUpdateIgnoredField(field.region)))
if is_old_record_builder {
old_record_builder_help(arena, record.fields)
} else { } else {
None
}
});
special_field_found.unwrap_or_else(|| {
let fields = record.fields.map_items(arena, |loc_field| { let fields = record.fields.map_items(arena, |loc_field| {
loc_field.map(|field| field.to_assigned_field(arena).unwrap()) loc_field.map(|field| field.to_assigned_field(arena).unwrap())
}); });
Ok(Expr::Record(fields)) Ok(Expr::Record(fields))
} })
} }
}; };
@ -3609,11 +3675,14 @@ fn record_update_help<'a>(
) -> Result<Expr<'a>, EExpr<'a>> { ) -> Result<Expr<'a>, EExpr<'a>> {
let result = fields.map_items_result(arena, |loc_field| { let result = fields.map_items_result(arena, |loc_field| {
match loc_field.value.to_assigned_field(arena) { match loc_field.value.to_assigned_field(arena) {
Ok(AssignedField::IgnoredValue(_, _, _)) => {
Err(EExpr::RecordUpdateIgnoredField(loc_field.region))
}
Ok(builder_field) => Ok(Loc { Ok(builder_field) => Ok(Loc {
region: loc_field.region, region: loc_field.region,
value: builder_field, value: builder_field,
}), }),
Err(FoundApplyValue) => Err(EExpr::RecordUpdateAccumulator(loc_field.region)), Err(FoundApplyValue) => Err(EExpr::RecordUpdateOldBuilderField(loc_field.region)),
} }
}); });
@ -3634,7 +3703,7 @@ fn new_record_builder_help<'a>(
region: loc_field.region, region: loc_field.region,
value: builder_field, value: builder_field,
}), }),
Err(FoundApplyValue) => Err(EExpr::RecordBuilderAccumulator(loc_field.region)), Err(FoundApplyValue) => Err(EExpr::RecordBuilderOldBuilderField(loc_field.region)),
} }
}); });
@ -3654,7 +3723,12 @@ fn old_record_builder_help<'a>(
region: loc_field.region, region: loc_field.region,
value: builder_field, value: builder_field,
}), }),
Err(FoundOptionalValue) => Err(EExpr::OptionalValueInRecordBuilder(loc_field.region)), Err(NotOldBuilderFieldValue::FoundOptionalValue) => {
Err(EExpr::OptionalValueInOldRecordBuilder(loc_field.region))
}
Err(NotOldBuilderFieldValue::FoundIgnoredValue) => {
Err(EExpr::IgnoredValueInOldRecordBuilder(loc_field.region))
}
} }
}); });

File diff suppressed because it is too large Load diff

View file

@ -74,7 +74,7 @@ pub fn highlight(text: &str) -> Vec<Loc<Token>> {
let header_keywords = HEADER_KEYWORDS.iter().copied().collect::<HashSet<_>>(); let header_keywords = HEADER_KEYWORDS.iter().copied().collect::<HashSet<_>>();
let body_keywords = KEYWORDS.iter().copied().collect::<HashSet<_>>(); let body_keywords = KEYWORDS.iter().copied().collect::<HashSet<_>>();
if let Ok((_prog, _, new_state)) = crate::module::header().parse(&arena, state.clone(), 0) { if let Ok((_prog, _, new_state)) = crate::header::header().parse(&arena, state.clone(), 0) {
let inner_state = let inner_state =
State::new(text[..state.bytes().len() - new_state.bytes().len()].as_bytes()); State::new(text[..state.bytes().len() - new_state.bytes().len()].as_bytes());
highlight_inner(&arena, inner_state, &mut tokens, &header_keywords); highlight_inner(&arena, inner_state, &mut tokens, &header_keywords);

View file

@ -13,11 +13,10 @@ pub mod header;
pub mod highlight; pub mod highlight;
pub mod ident; pub mod ident;
pub mod keyword; pub mod keyword;
pub mod module; pub mod normalize;
pub mod number_literal; pub mod number_literal;
pub mod pattern; pub mod pattern;
pub mod problems; pub mod problems;
pub mod remove_spaces;
pub mod src64; pub mod src64;
pub mod state; pub mod state;
pub mod string_literal; pub mod string_literal;

View file

@ -1,945 +0,0 @@
use crate::ast::{Collection, CommentOrNewline, Defs, Header, Module, Spaced, Spaces};
use crate::blankspace::{space0_around_ee, space0_before_e, space0_e};
use crate::expr::merge_spaces;
use crate::header::{
package_entry, package_name, AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword,
HostedHeader, ImportsCollection, ImportsEntry, ImportsKeyword, ImportsKeywordItem, Keyword,
KeywordItem, ModuleHeader, ModuleName, ModuleParams, PackageEntry, PackageHeader,
PackagesKeyword, PlatformHeader, PlatformRequires, ProvidesKeyword, ProvidesTo,
RequiresKeyword, To, ToKeyword, TypedIdent, WithKeyword,
};
use crate::ident::{self, lowercase_ident, unqualified_ident, uppercase, UppercaseIdent};
use crate::parser::Progress::{self, *};
use crate::parser::{
and, backtrackable, byte, collection_trailing_sep_e, increment_min_indent, loc, map,
map_with_arena, optional, reset_min_indent, skip_first, skip_second, specialize_err, succeed,
two_bytes, zero_or_more, EExposes, EGenerates, EGeneratesWith, EHeader, EImports, EPackages,
EParams, EProvides, ERequires, ETypedIdent, Parser, SourceError, SpaceProblem, SyntaxError,
};
use crate::pattern::record_pattern_fields;
use crate::state::State;
use crate::string_literal::{self, parse_str_literal};
use crate::type_annotation;
use roc_region::all::{Loc, Position, Region};
fn end_of_file<'a>() -> impl Parser<'a, (), SyntaxError<'a>> {
|_arena, state: State<'a>, _min_indent: u32| {
if state.has_reached_end() {
Ok((NoProgress, (), state))
} else {
Err((NoProgress, SyntaxError::NotEndOfFile(state.pos())))
}
}
}
pub fn parse_module_defs<'a>(
arena: &'a bumpalo::Bump,
state: State<'a>,
defs: Defs<'a>,
) -> Result<Defs<'a>, SyntaxError<'a>> {
let min_indent = 0;
match crate::expr::parse_top_level_defs(arena, state.clone(), defs) {
Ok((_, defs, state)) => match end_of_file().parse(arena, state, min_indent) {
Ok(_) => Ok(defs),
Err((_, fail)) => Err(fail),
},
Err((_, fail)) => Err(SyntaxError::Expr(fail, state.pos())),
}
}
pub fn parse_header<'a>(
arena: &'a bumpalo::Bump,
state: State<'a>,
) -> Result<(Module<'a>, State<'a>), SourceError<'a, EHeader<'a>>> {
let min_indent = 0;
match header().parse(arena, state.clone(), min_indent) {
Ok((_, module, state)) => Ok((module, state)),
Err((_, fail)) => Err(SourceError::new(fail, &state)),
}
}
pub fn header<'a>() -> impl Parser<'a, Module<'a>, EHeader<'a>> {
use crate::parser::keyword;
record!(Module {
comments: space0_e(EHeader::IndentStart),
header: one_of![
map(
skip_first(
keyword("module", EHeader::Start),
increment_min_indent(module_header())
),
Header::Module
),
map(
skip_first(
keyword("interface", EHeader::Start),
increment_min_indent(interface_header())
),
Header::Module
),
map(
skip_first(
keyword("app", EHeader::Start),
increment_min_indent(one_of![app_header(), old_app_header()])
),
Header::App
),
map(
skip_first(
keyword("package", EHeader::Start),
increment_min_indent(one_of![package_header(), old_package_header()])
),
Header::Package
),
map(
skip_first(
keyword("platform", EHeader::Start),
increment_min_indent(platform_header())
),
Header::Platform
),
map(
skip_first(
keyword("hosted", EHeader::Start),
increment_min_indent(hosted_header())
),
Header::Hosted
),
]
})
}
#[inline(always)]
fn module_header<'a>() -> impl Parser<'a, ModuleHeader<'a>, EHeader<'a>> {
record!(ModuleHeader {
after_keyword: space0_e(EHeader::IndentStart),
params: optional(specialize_err(EHeader::Params, module_params())),
exposes: specialize_err(EHeader::Exposes, exposes_list()),
interface_imports: succeed(None)
})
.trace("module_header")
}
fn module_params<'a>() -> impl Parser<'a, ModuleParams<'a>, EParams<'a>> {
record!(ModuleParams {
params: specialize_err(EParams::Pattern, record_pattern_fields()),
before_arrow: skip_second(
space0_e(EParams::BeforeArrow),
loc(two_bytes(b'-', b'>', EParams::Arrow))
),
after_arrow: space0_e(EParams::AfterArrow),
})
}
// TODO does this need to be a macro?
macro_rules! merge_n_spaces {
($arena:expr, $($slice:expr),*) => {
{
let mut merged = bumpalo::collections::Vec::with_capacity_in(0 $(+ $slice.len())*, $arena);
$(merged.extend_from_slice($slice);)*
merged.into_bump_slice()
}
};
}
/// Parse old interface headers so we can format them into module headers
#[inline(always)]
fn interface_header<'a>() -> impl Parser<'a, ModuleHeader<'a>, EHeader<'a>> {
let after_keyword = map_with_arena(
and(
skip_second(
space0_e(EHeader::IndentStart),
loc(module_name_help(EHeader::ModuleName)),
),
specialize_err(EHeader::Exposes, exposes_kw()),
),
|arena: &'a bumpalo::Bump,
(before_name, kw): (&'a [CommentOrNewline<'a>], Spaces<'a, ExposesKeyword>)| {
merge_n_spaces!(arena, before_name, kw.before, kw.after)
},
);
record!(ModuleHeader {
after_keyword: after_keyword,
params: succeed(None),
exposes: specialize_err(EHeader::Exposes, exposes_list()).trace("exposes_list"),
interface_imports: map(
specialize_err(EHeader::Imports, imports()),
imports_none_if_empty
)
.trace("imports"),
})
.trace("interface_header")
}
fn imports_none_if_empty(value: ImportsKeywordItem<'_>) -> Option<ImportsKeywordItem<'_>> {
if value.item.is_empty() {
None
} else {
Some(value)
}
}
#[inline(always)]
fn hosted_header<'a>() -> impl Parser<'a, HostedHeader<'a>, EHeader<'a>> {
record!(HostedHeader {
before_name: space0_e(EHeader::IndentStart),
name: loc(module_name_help(EHeader::ModuleName)),
exposes: specialize_err(EHeader::Exposes, exposes_values_kw()),
imports: specialize_err(EHeader::Imports, imports()),
generates: specialize_err(EHeader::Generates, generates()),
generates_with: specialize_err(EHeader::GeneratesWith, generates_with()),
})
.trace("hosted_header")
}
fn chomp_module_name(buffer: &[u8]) -> Result<&str, Progress> {
use encode_unicode::CharExt;
let mut chomped = 0;
if let Ok((first_letter, width)) = char::from_utf8_slice_start(&buffer[chomped..]) {
if first_letter.is_uppercase() {
chomped += width;
} else {
return Err(Progress::NoProgress);
}
}
while let Ok((ch, width)) = char::from_utf8_slice_start(&buffer[chomped..]) {
// After the first character, only these are allowed:
//
// * Unicode alphabetic chars - you might include `鹏` if that's clear to your readers
// * ASCII digits - e.g. `1` but not `¾`, both of which pass .is_numeric()
// * A '.' separating module parts
if ch.is_alphabetic() || ch.is_ascii_digit() {
chomped += width;
} else if ch == '.' {
chomped += width;
if let Ok((first_letter, width)) = char::from_utf8_slice_start(&buffer[chomped..]) {
if first_letter.is_uppercase() {
chomped += width;
} else if first_letter == '{' {
// the .{ starting a `Foo.{ bar, baz }` importing clauses
chomped -= width;
break;
} else {
return Err(Progress::MadeProgress);
}
}
} else {
// we're done
break;
}
}
let name = unsafe { std::str::from_utf8_unchecked(&buffer[..chomped]) };
Ok(name)
}
#[inline(always)]
fn module_name<'a>() -> impl Parser<'a, ModuleName<'a>, ()> {
|_, mut state: State<'a>, _min_indent: u32| match chomp_module_name(state.bytes()) {
Ok(name) => {
let width = name.len();
state = state.advance(width);
Ok((MadeProgress, ModuleName::new(name), state))
}
Err(progress) => Err((progress, ())),
}
}
#[inline(always)]
fn app_header<'a>() -> impl Parser<'a, AppHeader<'a>, EHeader<'a>> {
record!(AppHeader {
before_provides: space0_e(EHeader::IndentStart),
provides: specialize_err(EHeader::Exposes, exposes_list()),
before_packages: space0_e(EHeader::IndentStart),
packages: specialize_err(EHeader::Packages, loc(packages_collection())),
old_imports: succeed(None),
old_provides_to_new_package: succeed(None),
})
.trace("app_header")
}
struct OldAppHeader<'a> {
pub before_name: &'a [CommentOrNewline<'a>],
pub packages: Option<Loc<OldAppPackages<'a>>>,
pub imports: Option<KeywordItem<'a, ImportsKeyword, ImportsCollection<'a>>>,
pub provides: ProvidesTo<'a>,
}
type OldAppPackages<'a> =
KeywordItem<'a, PackagesKeyword, Collection<'a, Loc<Spaced<'a, PackageEntry<'a>>>>>;
#[inline(always)]
fn old_app_header<'a>() -> impl Parser<'a, AppHeader<'a>, EHeader<'a>> {
let old = record!(OldAppHeader {
before_name: skip_second(
space0_e(EHeader::IndentStart),
loc(crate::parser::specialize_err(
EHeader::AppName,
string_literal::parse_str_literal()
))
),
packages: optional(specialize_err(EHeader::Packages, loc(packages()))),
imports: optional(specialize_err(EHeader::Imports, imports())),
provides: specialize_err(EHeader::Provides, provides_to()),
});
map_with_arena(old, |arena: &'a bumpalo::Bump, old: OldAppHeader<'a>| {
let mut before_packages: &'a [CommentOrNewline] = &[];
let packages = match old.packages {
Some(packages) => {
before_packages = merge_spaces(
arena,
packages.value.keyword.before,
packages.value.keyword.after,
);
if let To::ExistingPackage(platform_shorthand) = old.provides.to.value {
packages.map(|coll| {
coll.item.map_items(arena, |loc_spaced_pkg| {
if loc_spaced_pkg.value.item().shorthand == platform_shorthand {
loc_spaced_pkg.map(|spaced_pkg| {
spaced_pkg.map(arena, |pkg| {
let mut new_pkg = *pkg;
new_pkg.platform_marker = Some(merge_spaces(
arena,
old.provides.to_keyword.before,
old.provides.to_keyword.after,
));
new_pkg
})
})
} else {
*loc_spaced_pkg
}
})
})
} else {
packages.map(|kw| kw.item)
}
}
None => Loc {
region: Region::zero(),
value: Collection::empty(),
},
};
let provides = match old.provides.types {
Some(types) => {
let mut combined_items = bumpalo::collections::Vec::with_capacity_in(
old.provides.entries.items.len() + types.items.len(),
arena,
);
combined_items.extend_from_slice(old.provides.entries.items);
for loc_spaced_type_ident in types.items {
combined_items.push(loc_spaced_type_ident.map(|spaced_type_ident| {
spaced_type_ident.map(arena, |type_ident| {
ExposedName::new(From::from(*type_ident))
})
}));
}
let value_comments = old.provides.entries.final_comments();
let type_comments = types.final_comments();
let mut combined_comments = bumpalo::collections::Vec::with_capacity_in(
value_comments.len() + type_comments.len(),
arena,
);
combined_comments.extend_from_slice(value_comments);
combined_comments.extend_from_slice(type_comments);
Collection::with_items_and_comments(
arena,
combined_items.into_bump_slice(),
combined_comments.into_bump_slice(),
)
}
None => old.provides.entries,
};
AppHeader {
before_provides: merge_spaces(
arena,
old.before_name,
old.provides.provides_keyword.before,
),
provides,
before_packages: merge_spaces(
arena,
before_packages,
old.provides.provides_keyword.after,
),
packages,
old_imports: old.imports.and_then(imports_none_if_empty),
old_provides_to_new_package: match old.provides.to.value {
To::NewPackage(new_pkg) => Some(new_pkg),
To::ExistingPackage(_) => None,
},
}
})
}
#[inline(always)]
fn package_header<'a>() -> impl Parser<'a, PackageHeader<'a>, EHeader<'a>> {
record!(PackageHeader {
before_exposes: space0_e(EHeader::IndentStart),
exposes: specialize_err(EHeader::Exposes, exposes_module_collection()),
before_packages: space0_e(EHeader::IndentStart),
packages: specialize_err(EHeader::Packages, loc(packages_collection())),
})
.trace("package_header")
}
#[derive(Debug, Clone, PartialEq)]
struct OldPackageHeader<'a> {
before_name: &'a [CommentOrNewline<'a>],
exposes: KeywordItem<'a, ExposesKeyword, Collection<'a, Loc<Spaced<'a, ModuleName<'a>>>>>,
packages:
Loc<KeywordItem<'a, PackagesKeyword, Collection<'a, Loc<Spaced<'a, PackageEntry<'a>>>>>>,
}
#[inline(always)]
fn old_package_header<'a>() -> impl Parser<'a, PackageHeader<'a>, EHeader<'a>> {
map_with_arena(
record!(OldPackageHeader {
before_name: skip_second(
space0_e(EHeader::IndentStart),
specialize_err(EHeader::PackageName, package_name())
),
exposes: specialize_err(EHeader::Exposes, exposes_modules()),
packages: specialize_err(EHeader::Packages, loc(packages())),
}),
|arena: &'a bumpalo::Bump, old: OldPackageHeader<'a>| {
let before_exposes = merge_n_spaces!(
arena,
old.before_name,
old.exposes.keyword.before,
old.exposes.keyword.after
);
let before_packages = merge_spaces(
arena,
old.packages.value.keyword.before,
old.packages.value.keyword.after,
);
PackageHeader {
before_exposes,
exposes: old.exposes.item,
before_packages,
packages: old.packages.map(|kw| kw.item),
}
},
)
.trace("old_package_header")
}
#[inline(always)]
fn platform_header<'a>() -> impl Parser<'a, PlatformHeader<'a>, EHeader<'a>> {
record!(PlatformHeader {
before_name: space0_e(EHeader::IndentStart),
name: loc(specialize_err(EHeader::PlatformName, package_name())),
requires: specialize_err(EHeader::Requires, requires()),
exposes: specialize_err(EHeader::Exposes, exposes_modules()),
packages: specialize_err(EHeader::Packages, packages()),
imports: specialize_err(EHeader::Imports, imports()),
provides: specialize_err(EHeader::Provides, provides_exposed()),
})
.trace("platform_header")
}
fn provides_to_package<'a>() -> impl Parser<'a, To<'a>, EProvides<'a>> {
one_of![
specialize_err(
|_, pos| EProvides::Identifier(pos),
map(lowercase_ident(), To::ExistingPackage)
),
specialize_err(EProvides::Package, map(package_name(), To::NewPackage))
]
}
#[inline(always)]
fn provides_to<'a>() -> impl Parser<'a, ProvidesTo<'a>, EProvides<'a>> {
record!(ProvidesTo {
provides_keyword: spaces_around_keyword(
ProvidesKeyword,
EProvides::Provides,
EProvides::IndentProvides,
EProvides::IndentListStart
),
entries: collection_trailing_sep_e(
byte(b'[', EProvides::ListStart),
exposes_entry(EProvides::Identifier),
byte(b',', EProvides::ListEnd),
byte(b']', EProvides::ListEnd),
Spaced::SpaceBefore
),
types: optional(backtrackable(provides_types())),
to_keyword: spaces_around_keyword(
ToKeyword,
EProvides::To,
EProvides::IndentTo,
EProvides::IndentListStart
),
to: loc(provides_to_package()),
})
.trace("provides_to")
}
fn provides_exposed<'a>() -> impl Parser<
'a,
KeywordItem<'a, ProvidesKeyword, Collection<'a, Loc<Spaced<'a, ExposedName<'a>>>>>,
EProvides<'a>,
> {
record!(KeywordItem {
keyword: spaces_around_keyword(
ProvidesKeyword,
EProvides::Provides,
EProvides::IndentProvides,
EProvides::IndentListStart
),
item: collection_trailing_sep_e(
byte(b'[', EProvides::ListStart),
exposes_entry(EProvides::Identifier),
byte(b',', EProvides::ListEnd),
byte(b']', EProvides::ListEnd),
Spaced::SpaceBefore
),
})
}
#[inline(always)]
fn provides_types<'a>(
) -> impl Parser<'a, Collection<'a, Loc<Spaced<'a, UppercaseIdent<'a>>>>, EProvides<'a>> {
skip_first(
// We only support spaces here, not newlines, because this is not intended
// to be the design forever. Someday it will hopefully work like Elm,
// where platform authors can provide functions like Browser.sandbox which
// present an API based on ordinary-looking type variables.
zero_or_more(byte(
b' ',
// HACK: If this errors, EProvides::Provides is not an accurate reflection
// of what went wrong. However, this is both skipped and zero_or_more,
// so this error should never be visible to anyone in practice!
EProvides::Provides,
)),
collection_trailing_sep_e(
byte(b'{', EProvides::ListStart),
provides_type_entry(EProvides::Identifier),
byte(b',', EProvides::ListEnd),
byte(b'}', EProvides::ListEnd),
Spaced::SpaceBefore,
),
)
}
fn provides_type_entry<'a, F, E>(
to_expectation: F,
) -> impl Parser<'a, Loc<Spaced<'a, UppercaseIdent<'a>>>, E>
where
F: Fn(Position) -> E,
F: Copy,
E: 'a,
{
loc(map(
specialize_err(move |_, pos| to_expectation(pos), ident::uppercase()),
Spaced::Item,
))
}
fn exposes_entry<'a, F, E>(
to_expectation: F,
) -> impl Parser<'a, Loc<Spaced<'a, ExposedName<'a>>>, E>
where
F: Fn(Position) -> E,
F: Copy,
E: 'a,
{
loc(map(
specialize_err(move |_, pos| to_expectation(pos), unqualified_ident()),
|n| Spaced::Item(ExposedName::new(n)),
))
}
#[inline(always)]
fn requires<'a>(
) -> impl Parser<'a, KeywordItem<'a, RequiresKeyword, PlatformRequires<'a>>, ERequires<'a>> {
record!(KeywordItem {
keyword: spaces_around_keyword(
RequiresKeyword,
ERequires::Requires,
ERequires::IndentRequires,
ERequires::IndentListStart
),
item: platform_requires(),
})
}
#[inline(always)]
fn platform_requires<'a>() -> impl Parser<'a, PlatformRequires<'a>, ERequires<'a>> {
record!(PlatformRequires {
rigids: skip_second(requires_rigids(), space0_e(ERequires::ListStart)),
signature: requires_typed_ident()
})
}
#[inline(always)]
fn requires_rigids<'a>(
) -> impl Parser<'a, Collection<'a, Loc<Spaced<'a, UppercaseIdent<'a>>>>, ERequires<'a>> {
collection_trailing_sep_e(
byte(b'{', ERequires::ListStart),
specialize_err(
|_, pos| ERequires::Rigid(pos),
loc(map(ident::uppercase(), Spaced::Item)),
),
byte(b',', ERequires::ListEnd),
byte(b'}', ERequires::ListEnd),
Spaced::SpaceBefore,
)
}
#[inline(always)]
fn requires_typed_ident<'a>() -> impl Parser<'a, Loc<Spaced<'a, TypedIdent<'a>>>, ERequires<'a>> {
skip_first(
byte(b'{', ERequires::ListStart),
skip_second(
reset_min_indent(space0_around_ee(
specialize_err(ERequires::TypedIdent, loc(typed_ident())),
ERequires::ListStart,
ERequires::ListEnd,
)),
byte(b'}', ERequires::ListStart),
),
)
}
#[inline(always)]
fn exposes_values_kw<'a>() -> impl Parser<
'a,
KeywordItem<'a, ExposesKeyword, Collection<'a, Loc<Spaced<'a, ExposedName<'a>>>>>,
EExposes,
> {
record!(KeywordItem {
keyword: exposes_kw(),
item: exposes_list()
})
}
#[inline(always)]
fn exposes_kw<'a>() -> impl Parser<'a, Spaces<'a, ExposesKeyword>, EExposes> {
spaces_around_keyword(
ExposesKeyword,
EExposes::Exposes,
EExposes::IndentExposes,
EExposes::IndentListStart,
)
}
#[inline(always)]
fn exposes_list<'a>() -> impl Parser<'a, Collection<'a, Loc<Spaced<'a, ExposedName<'a>>>>, EExposes>
{
collection_trailing_sep_e(
byte(b'[', EExposes::ListStart),
exposes_entry(EExposes::Identifier),
byte(b',', EExposes::ListEnd),
byte(b']', EExposes::ListEnd),
Spaced::SpaceBefore,
)
}
pub fn spaces_around_keyword<'a, K: Keyword, E>(
keyword_item: K,
expectation: fn(Position) -> E,
indent_problem1: fn(Position) -> E,
indent_problem2: fn(Position) -> E,
) -> impl Parser<'a, Spaces<'a, K>, E>
where
E: 'a + SpaceProblem,
{
map(
and(
skip_second(
// parse any leading space before the keyword
backtrackable(space0_e(indent_problem1)),
// parse the keyword
crate::parser::keyword(K::KEYWORD, expectation),
),
// parse the trailing space
space0_e(indent_problem2),
),
move |(before, after)| Spaces {
before,
item: keyword_item,
after,
},
)
}
#[inline(always)]
fn exposes_modules<'a>() -> impl Parser<
'a,
KeywordItem<'a, ExposesKeyword, Collection<'a, Loc<Spaced<'a, ModuleName<'a>>>>>,
EExposes,
> {
record!(KeywordItem {
keyword: spaces_around_keyword(
ExposesKeyword,
EExposes::Exposes,
EExposes::IndentExposes,
EExposes::IndentListStart
),
item: exposes_module_collection(),
})
}
fn exposes_module_collection<'a>(
) -> impl Parser<'a, Collection<'a, Loc<Spaced<'a, ModuleName<'a>>>>, EExposes> {
collection_trailing_sep_e(
byte(b'[', EExposes::ListStart),
exposes_module(EExposes::Identifier),
byte(b',', EExposes::ListEnd),
byte(b']', EExposes::ListEnd),
Spaced::SpaceBefore,
)
}
fn exposes_module<'a, F, E>(
to_expectation: F,
) -> impl Parser<'a, Loc<Spaced<'a, ModuleName<'a>>>, E>
where
F: Fn(Position) -> E,
F: Copy,
E: 'a,
{
loc(map(
specialize_err(move |_, pos| to_expectation(pos), module_name()),
Spaced::Item,
))
}
#[inline(always)]
fn packages<'a>() -> impl Parser<
'a,
KeywordItem<'a, PackagesKeyword, Collection<'a, Loc<Spaced<'a, PackageEntry<'a>>>>>,
EPackages<'a>,
> {
record!(KeywordItem {
keyword: packages_kw(),
item: packages_collection()
})
}
#[inline(always)]
fn packages_kw<'a>() -> impl Parser<'a, Spaces<'a, PackagesKeyword>, EPackages<'a>> {
spaces_around_keyword(
PackagesKeyword,
EPackages::Packages,
EPackages::IndentPackages,
EPackages::IndentListStart,
)
}
#[inline(always)]
fn packages_collection<'a>(
) -> impl Parser<'a, Collection<'a, Loc<Spaced<'a, PackageEntry<'a>>>>, EPackages<'a>> {
collection_trailing_sep_e(
byte(b'{', EPackages::ListStart),
specialize_err(EPackages::PackageEntry, loc(package_entry())),
byte(b',', EPackages::ListEnd),
byte(b'}', EPackages::ListEnd),
Spaced::SpaceBefore,
)
}
#[inline(always)]
fn generates<'a>(
) -> impl Parser<'a, KeywordItem<'a, GeneratesKeyword, UppercaseIdent<'a>>, EGenerates> {
record!(KeywordItem {
keyword: spaces_around_keyword(
GeneratesKeyword,
EGenerates::Generates,
EGenerates::IndentGenerates,
EGenerates::IndentTypeStart
),
item: specialize_err(|(), pos| EGenerates::Identifier(pos), uppercase())
})
}
#[inline(always)]
fn generates_with<'a>() -> impl Parser<
'a,
KeywordItem<'a, WithKeyword, Collection<'a, Loc<Spaced<'a, ExposedName<'a>>>>>,
EGeneratesWith,
> {
record!(KeywordItem {
keyword: spaces_around_keyword(
WithKeyword,
EGeneratesWith::With,
EGeneratesWith::IndentWith,
EGeneratesWith::IndentListStart
),
item: collection_trailing_sep_e(
byte(b'[', EGeneratesWith::ListStart),
exposes_entry(EGeneratesWith::Identifier),
byte(b',', EGeneratesWith::ListEnd),
byte(b']', EGeneratesWith::ListEnd),
Spaced::SpaceBefore
)
})
}
#[inline(always)]
fn imports<'a>() -> impl Parser<
'a,
KeywordItem<'a, ImportsKeyword, Collection<'a, Loc<Spaced<'a, ImportsEntry<'a>>>>>,
EImports,
> {
record!(KeywordItem {
keyword: spaces_around_keyword(
ImportsKeyword,
EImports::Imports,
EImports::IndentImports,
EImports::IndentListStart
),
item: collection_trailing_sep_e(
byte(b'[', EImports::ListStart),
loc(imports_entry()),
byte(b',', EImports::ListEnd),
byte(b']', EImports::ListEnd),
Spaced::SpaceBefore
)
})
.trace("imports")
}
#[inline(always)]
pub fn typed_ident<'a>() -> impl Parser<'a, Spaced<'a, TypedIdent<'a>>, ETypedIdent<'a>> {
// e.g.
//
// printLine : Str -> Effect {}
map(
and(
and(
loc(specialize_err(
|_, pos| ETypedIdent::Identifier(pos),
lowercase_ident(),
)),
space0_e(ETypedIdent::IndentHasType),
),
skip_first(
byte(b':', ETypedIdent::HasType),
space0_before_e(
specialize_err(
ETypedIdent::Type,
reset_min_indent(type_annotation::located(true)),
),
ETypedIdent::IndentType,
),
),
),
|((ident, spaces_before_colon), ann)| {
Spaced::Item(TypedIdent {
ident,
spaces_before_colon,
ann,
})
},
)
}
fn shortname<'a>() -> impl Parser<'a, &'a str, EImports> {
specialize_err(|_, pos| EImports::Shorthand(pos), lowercase_ident())
}
pub fn module_name_help<'a, F, E>(to_expectation: F) -> impl Parser<'a, ModuleName<'a>, E>
where
F: Fn(Position) -> E,
E: 'a,
F: 'a,
{
specialize_err(move |_, pos| to_expectation(pos), module_name())
}
#[inline(always)]
fn imports_entry<'a>() -> impl Parser<'a, Spaced<'a, ImportsEntry<'a>>, EImports> {
type Temp<'a> = (
(Option<&'a str>, ModuleName<'a>),
Option<Collection<'a, Loc<Spaced<'a, ExposedName<'a>>>>>,
);
let spaced_import = |((opt_shortname, module_name), opt_values): Temp<'a>| {
let exposed_values = opt_values.unwrap_or_else(Collection::empty);
let entry = match opt_shortname {
Some(shortname) => ImportsEntry::Package(shortname, module_name, exposed_values),
None => ImportsEntry::Module(module_name, exposed_values),
};
Spaced::Item(entry)
};
one_of!(
map(
and(
and(
// e.g. `pf.`
optional(backtrackable(skip_second(
shortname(),
byte(b'.', EImports::ShorthandDot)
))),
// e.g. `Task`
module_name_help(EImports::ModuleName)
),
// e.g. `.{ Task, after}`
optional(skip_first(
byte(b'.', EImports::ExposingDot),
collection_trailing_sep_e(
byte(b'{', EImports::SetStart),
exposes_entry(EImports::Identifier),
byte(b',', EImports::SetEnd),
byte(b'}', EImports::SetEnd),
Spaced::SpaceBefore
)
))
),
spaced_import
)
.trace("normal_import"),
map(
and(
and(
// e.g. "filename"
// TODO: str literal allows for multiline strings. We probably don't want that for file names.
specialize_err(|_, pos| EImports::StrLiteral(pos), parse_str_literal()),
// e.g. as
and(
and(
space0_e(EImports::AsKeyword),
two_bytes(b'a', b's', EImports::AsKeyword)
),
space0_e(EImports::AsKeyword)
)
),
// e.g. file : Str
specialize_err(|_, pos| EImports::TypedIdent(pos), typed_ident())
),
|((file_name, _), typed_ident)| {
// TODO: look at blacking block strings during parsing.
Spaced::Item(ImportsEntry::IngestedFile(file_name, typed_ident))
}
)
.trace("ingest_file_import")
)
.trace("imports_entry")
}

View file

@ -372,9 +372,11 @@ pub enum EExpr<'a> {
InParens(EInParens<'a>, Position), InParens(EInParens<'a>, Position),
Record(ERecord<'a>, Position), Record(ERecord<'a>, Position),
OptionalValueInRecordBuilder(Region), OptionalValueInOldRecordBuilder(Region),
RecordUpdateAccumulator(Region), IgnoredValueInOldRecordBuilder(Region),
RecordBuilderAccumulator(Region), RecordUpdateOldBuilderField(Region),
RecordUpdateIgnoredField(Region),
RecordBuilderOldBuilderField(Region),
// SingleQuote errors are folded into the EString // SingleQuote errors are folded into the EString
Str(EString<'a>, Position), Str(EString<'a>, Position),
@ -428,6 +430,7 @@ pub enum ERecord<'a> {
Prefix(Position), Prefix(Position),
Field(Position), Field(Position),
UnderscoreField(Position),
Colon(Position), Colon(Position),
QuestionMark(Position), QuestionMark(Position),
Arrow(Position), Arrow(Position),
@ -577,6 +580,7 @@ pub enum EImportParams<'a> {
RecordUpdateFound(Region), RecordUpdateFound(Region),
RecordBuilderFound(Region), RecordBuilderFound(Region),
RecordApplyFound(Region), RecordApplyFound(Region),
RecordIgnoredFieldFound(Region),
Space(BadInputError, Position), Space(BadInputError, Position),
} }
@ -735,6 +739,7 @@ pub enum ETypeAbilityImpl<'a> {
Open(Position), Open(Position),
Field(Position), Field(Position),
UnderscoreField(Position),
Colon(Position), Colon(Position),
Arrow(Position), Arrow(Position),
Optional(Position), Optional(Position),
@ -756,6 +761,7 @@ impl<'a> From<ERecord<'a>> for ETypeAbilityImpl<'a> {
ERecord::End(p) => ETypeAbilityImpl::End(p), ERecord::End(p) => ETypeAbilityImpl::End(p),
ERecord::Open(p) => ETypeAbilityImpl::Open(p), ERecord::Open(p) => ETypeAbilityImpl::Open(p),
ERecord::Field(p) => ETypeAbilityImpl::Field(p), ERecord::Field(p) => ETypeAbilityImpl::Field(p),
ERecord::UnderscoreField(p) => ETypeAbilityImpl::UnderscoreField(p),
ERecord::Colon(p) => ETypeAbilityImpl::Colon(p), ERecord::Colon(p) => ETypeAbilityImpl::Colon(p),
ERecord::Arrow(p) => ETypeAbilityImpl::Arrow(p), ERecord::Arrow(p) => ETypeAbilityImpl::Arrow(p),
ERecord::Space(s, p) => ETypeAbilityImpl::Space(s, p), ERecord::Space(s, p) => ETypeAbilityImpl::Space(s, p),

View file

@ -25,6 +25,7 @@ pub enum PatternType {
DefExpr, DefExpr,
FunctionArg, FunctionArg,
WhenBranch, WhenBranch,
ModuleParams,
} }
pub fn closure_param<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, EPattern<'a>> { pub fn closure_param<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, EPattern<'a>> {

View file

@ -1,6 +1,8 @@
use crate::ast; use crate::ast;
use crate::ast::Defs; use crate::ast::Defs;
use crate::module::parse_module_defs; use crate::ast::Header;
use crate::ast::SpacesBefore;
use crate::header::parse_module_defs;
use crate::parser::SourceError; use crate::parser::SourceError;
use crate::parser::SyntaxError; use crate::parser::SyntaxError;
use crate::state::State; use crate::state::State;
@ -39,10 +41,10 @@ pub fn parse_defs_with<'a>(arena: &'a Bump, input: &'a str) -> Result<Defs<'a>,
pub fn parse_header_with<'a>( pub fn parse_header_with<'a>(
arena: &'a Bump, arena: &'a Bump,
input: &'a str, input: &'a str,
) -> Result<ast::Module<'a>, SyntaxError<'a>> { ) -> Result<SpacesBefore<'a, Header<'a>>, SyntaxError<'a>> {
let state = State::new(input.as_bytes()); let state = State::new(input.as_bytes());
match crate::module::parse_header(arena, state.clone()) { match crate::header::parse_header(arena, state.clone()) {
Ok((header, _)) => Ok(header), Ok((header, _)) => Ok(header),
Err(fail) => Err(SyntaxError::Header(fail.problem)), Err(fail) => Err(SyntaxError::Header(fail.problem)),
} }

View file

@ -565,6 +565,9 @@ fn parse_implements_ability<'a>() -> impl Parser<'a, ImplementsAbility<'a>, ETyp
fn ability_impl_field<'a>() -> impl Parser<'a, AssignedField<'a, Expr<'a>>, ERecord<'a>> { fn ability_impl_field<'a>() -> impl Parser<'a, AssignedField<'a, Expr<'a>>, ERecord<'a>> {
then(record_field(), move |arena, state, _, field| { then(record_field(), move |arena, state, _, field| {
match field.to_assigned_field(arena) { match field.to_assigned_field(arena) {
Ok(AssignedField::IgnoredValue(_, _, _)) => {
Err((MadeProgress, ERecord::Field(state.pos())))
}
Ok(assigned_field) => Ok((MadeProgress, assigned_field, state)), Ok(assigned_field) => Ok((MadeProgress, assigned_field, state)),
Err(FoundApplyValue) => Err((MadeProgress, ERecord::Field(state.pos()))), Err(FoundApplyValue) => Err((MadeProgress, ERecord::Field(state.pos()))),
} }

View file

@ -22,7 +22,7 @@ mod test_parse {
use roc_parse::ast::StrSegment::*; use roc_parse::ast::StrSegment::*;
use roc_parse::ast::{self, EscapedChar}; use roc_parse::ast::{self, EscapedChar};
use roc_parse::ast::{CommentOrNewline, StrLiteral::*}; use roc_parse::ast::{CommentOrNewline, StrLiteral::*};
use roc_parse::module::parse_module_defs; use roc_parse::header::parse_module_defs;
use roc_parse::parser::SyntaxError; use roc_parse::parser::SyntaxError;
use roc_parse::state::State; use roc_parse::state::State;
use roc_parse::test_helpers::parse_expr_with; use roc_parse::test_helpers::parse_expr_with;

View file

@ -4,7 +4,7 @@ use std::path::PathBuf;
use roc_collections::all::MutSet; use roc_collections::all::MutSet;
use roc_module::called_via::BinOp; use roc_module::called_via::BinOp;
use roc_module::ident::{Ident, Lowercase, ModuleName, TagName}; use roc_module::ident::{Ident, Lowercase, ModuleName, TagName};
use roc_module::symbol::{ModuleId, ScopeModuleSource, Symbol}; use roc_module::symbol::{ModuleId, Symbol};
use roc_parse::ast::Base; use roc_parse::ast::Base;
use roc_parse::pattern::PatternType; use roc_parse::pattern::PatternType;
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
@ -238,6 +238,13 @@ pub enum Problem {
}, },
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScopeModuleSource {
Builtin,
Current,
Import(Region),
}
impl Problem { impl Problem {
pub fn severity(&self) -> Severity { pub fn severity(&self) -> Severity {
use Severity::{Fatal, RuntimeError, Warning}; use Severity::{Fatal, RuntimeError, Warning};

View file

@ -80,6 +80,10 @@ pub struct SolveConfig<'a> {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
/// The checkmate collector for this module. /// The checkmate collector for this module.
pub checkmate: Option<roc_checkmate::Collector>, pub checkmate: Option<roc_checkmate::Collector>,
/// Module params
pub params_pattern: Option<roc_can::pattern::Pattern>,
pub module_params_vars: VecMap<ModuleId, Variable>,
} }
pub struct SolveOutput { pub struct SolveOutput {
@ -144,6 +148,7 @@ pub fn exposed_types_storage_subs(
home: ModuleId, home: ModuleId,
solved_subs: &mut Solved<Subs>, solved_subs: &mut Solved<Subs>,
exposed_vars_by_symbol: &[(Symbol, Variable)], exposed_vars_by_symbol: &[(Symbol, Variable)],
params_var: Option<Variable>,
solved_implementations: &ResolvedImplementations, solved_implementations: &ResolvedImplementations,
abilities_store: &AbilitiesStore, abilities_store: &AbilitiesStore,
) -> ExposedTypesStorageSubs { ) -> ExposedTypesStorageSubs {
@ -156,6 +161,9 @@ pub fn exposed_types_storage_subs(
stored_vars_by_symbol.insert(*symbol, new_var); stored_vars_by_symbol.insert(*symbol, new_var);
} }
let stored_params_var =
params_var.map(|params_var| storage_subs.import_variable_from(subs, params_var).variable);
let mut stored_specialization_lambda_set_vars = let mut stored_specialization_lambda_set_vars =
VecMap::with_capacity(solved_implementations.len()); VecMap::with_capacity(solved_implementations.len());
@ -213,6 +221,7 @@ pub fn exposed_types_storage_subs(
stored_vars_by_symbol, stored_vars_by_symbol,
stored_specialization_lambda_set_vars, stored_specialization_lambda_set_vars,
stored_ability_member_vars, stored_ability_member_vars,
stored_params_var,
} }
} }

View file

@ -16,11 +16,12 @@ use roc_can::abilities::{AbilitiesStore, MemberSpecializationInfo};
use roc_can::constraint::Constraint::{self, *}; use roc_can::constraint::Constraint::{self, *};
use roc_can::constraint::{Cycle, LetConstraint, OpportunisticResolve}; use roc_can::constraint::{Cycle, LetConstraint, OpportunisticResolve};
use roc_can::expected::{Expected, PExpected}; use roc_can::expected::{Expected, PExpected};
use roc_collections::VecMap;
use roc_debug_flags::dbg_do; use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use roc_debug_flags::ROC_VERIFY_RIGID_LET_GENERALIZED; use roc_debug_flags::ROC_VERIFY_RIGID_LET_GENERALIZED;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::symbol::Symbol; use roc_module::symbol::{ModuleId, Symbol};
use roc_problem::can::CycleEntry; use roc_problem::can::CycleEntry;
use roc_region::all::Loc; use roc_region::all::Loc;
use roc_solve_problem::TypeError; use roc_solve_problem::TypeError;
@ -129,15 +130,13 @@ fn run_help(
exposed_by_module, exposed_by_module,
derived_module, derived_module,
function_kind, function_kind,
params_pattern,
module_params_vars,
.. ..
} = config; } = config;
let mut pools = Pools::default(); let mut pools = Pools::default();
let state = State {
scope: Scope::default(),
mark: Mark::NONE.next(),
};
let rank = Rank::toplevel(); let rank = Rank::toplevel();
let arena = Bump::new(); let arena = Bump::new();
@ -178,7 +177,6 @@ fn run_help(
let state = solve( let state = solve(
&mut env, &mut env,
types, types,
state,
rank, rank,
problems, problems,
aliases, aliases,
@ -186,6 +184,8 @@ fn run_help(
abilities_store, abilities_store,
&mut obligation_cache, &mut obligation_cache,
&mut awaiting_specializations, &mut awaiting_specializations,
params_pattern,
module_params_vars,
); );
RunSolveOutput { RunSolveOutput {
@ -236,7 +236,6 @@ enum Work<'a> {
fn solve( fn solve(
env: &mut InferenceEnv, env: &mut InferenceEnv,
mut can_types: Types, mut can_types: Types,
mut state: State,
rank: Rank, rank: Rank,
problems: &mut Vec<TypeError>, problems: &mut Vec<TypeError>,
aliases: &mut Aliases, aliases: &mut Aliases,
@ -244,15 +243,24 @@ fn solve(
abilities_store: &mut AbilitiesStore, abilities_store: &mut AbilitiesStore,
obligation_cache: &mut ObligationCache, obligation_cache: &mut ObligationCache,
awaiting_specializations: &mut AwaitingSpecializations, awaiting_specializations: &mut AwaitingSpecializations,
params_pattern: Option<roc_can::pattern::Pattern>,
module_params_vars: VecMap<ModuleId, Variable>,
) -> State { ) -> State {
let scope = Scope::new(params_pattern);
let initial = Work::Constraint { let initial = Work::Constraint {
scope: &Scope::default(), scope: &scope.clone(),
rank, rank,
constraint, constraint,
}; };
let mut stack = vec![initial]; let mut stack = vec![initial];
let mut state = State {
scope,
mark: Mark::NONE.next(),
};
while let Some(work_item) = stack.pop() { while let Some(work_item) = stack.pop() {
let (scope, rank, constraint) = match work_item { let (scope, rank, constraint) = match work_item {
Work::Constraint { Work::Constraint {
@ -1392,6 +1400,86 @@ fn solve(
} }
} }
} }
ImportParams(opt_provided, module_id, region) => {
match (module_params_vars.get(module_id), opt_provided) {
(Some(expected), Some(provided)) => {
let actual = either_type_index_to_var(
env,
rank,
problems,
abilities_store,
obligation_cache,
&mut can_types,
aliases,
*provided,
);
match unify(
&mut env.uenv(),
actual,
*expected,
UnificationMode::EQ,
Polarity::OF_VALUE,
) {
Success {
vars,
must_implement_ability,
lambda_sets_to_specialize,
extra_metadata: _,
} => {
env.introduce(rank, &vars);
problems.extend(obligation_cache.check_obligations(
env.subs,
abilities_store,
must_implement_ability,
AbilityImplError::DoesNotImplement,
));
compact_lambdas_and_check_obligations(
env,
problems,
abilities_store,
obligation_cache,
awaiting_specializations,
lambda_sets_to_specialize,
);
state
}
Failure(vars, actual_type, expected_type, _) => {
env.introduce(rank, &vars);
problems.push(TypeError::ModuleParamsMismatch(
*region,
*module_id,
actual_type,
expected_type,
));
state
}
}
}
(Some(expected), None) => {
let expected_type = env.uenv().var_to_error_type(*expected, Polarity::Neg);
problems.push(TypeError::MissingModuleParams(
*region,
*module_id,
expected_type,
));
state
}
(None, Some(_)) => {
problems.push(TypeError::UnexpectedModuleParams(*region, *module_id));
state
}
(None, None) => state,
}
}
}; };
} }

View file

@ -2,13 +2,43 @@ use roc_module::symbol::Symbol;
use roc_types::subs::Variable; use roc_types::subs::Variable;
/// The scope of the solver, as symbols are introduced. /// The scope of the solver, as symbols are introduced.
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug)]
pub struct Scope { pub struct Scope {
symbols: Vec<Symbol>, symbols: Vec<Symbol>,
variables: Vec<Variable>, variables: Vec<Variable>,
} }
impl Scope { impl Scope {
pub fn new(params_pattern: Option<roc_can::pattern::Pattern>) -> Self {
match params_pattern {
Some(params_pattern) => match params_pattern {
roc_can::pattern::Pattern::RecordDestructure {
whole_var: _,
ext_var: _,
destructs,
} => {
let mut symbols = Vec::with_capacity(destructs.len());
let mut variables = Vec::with_capacity(destructs.len());
for destruct in destructs {
symbols.push(destruct.value.symbol);
variables.push(destruct.value.var);
}
Self { symbols, variables }
}
_ => unreachable!(
"other pattern types should have parsed: {:?}",
params_pattern
),
},
None => Self {
symbols: Vec::default(),
variables: Vec::default(),
},
}
}
pub fn vars_by_symbol(&self) -> impl Iterator<Item = (Symbol, Variable)> + '_ { pub fn vars_by_symbol(&self) -> impl Iterator<Item = (Symbol, Variable)> + '_ {
let it1 = self.symbols.iter().copied(); let it1 = self.symbols.iter().copied();
let it2 = self.variables.iter().copied(); let it2 = self.variables.iter().copied();

View file

@ -2,7 +2,10 @@
use std::{path::PathBuf, str::Utf8Error}; use std::{path::PathBuf, str::Utf8Error};
use roc_can::expected::{Expected, PExpected}; use roc_can::expected::{Expected, PExpected};
use roc_module::{ident::Lowercase, symbol::Symbol}; use roc_module::{
ident::Lowercase,
symbol::{ModuleId, Symbol},
};
use roc_problem::{can::CycleEntry, Severity}; use roc_problem::{can::CycleEntry, Severity};
use roc_region::all::Region; use roc_region::all::Region;
@ -33,6 +36,9 @@ pub enum TypeError {
}, },
IngestedFileBadUtf8(Box<PathBuf>, Utf8Error), IngestedFileBadUtf8(Box<PathBuf>, Utf8Error),
IngestedFileUnsupportedType(Box<PathBuf>, ErrorType), IngestedFileUnsupportedType(Box<PathBuf>, ErrorType),
UnexpectedModuleParams(Region, ModuleId),
MissingModuleParams(Region, ModuleId, ErrorType),
ModuleParamsMismatch(Region, ModuleId, ErrorType, ErrorType),
} }
impl TypeError { impl TypeError {
@ -52,6 +58,9 @@ impl TypeError {
TypeError::Exhaustive(exhtv) => exhtv.severity(), TypeError::Exhaustive(exhtv) => exhtv.severity(),
TypeError::StructuralSpecialization { .. } => RuntimeError, TypeError::StructuralSpecialization { .. } => RuntimeError,
TypeError::WrongSpecialization { .. } => RuntimeError, TypeError::WrongSpecialization { .. } => RuntimeError,
TypeError::UnexpectedModuleParams(..) => Warning,
TypeError::MissingModuleParams(..) => RuntimeError,
TypeError::ModuleParamsMismatch(..) => RuntimeError,
TypeError::IngestedFileBadUtf8(..) => Fatal, TypeError::IngestedFileBadUtf8(..) => Fatal,
TypeError::IngestedFileUnsupportedType(..) => Fatal, TypeError::IngestedFileUnsupportedType(..) => Fatal,
} }
@ -66,7 +75,10 @@ impl TypeError {
| TypeError::BadExprMissingAbility(region, ..) | TypeError::BadExprMissingAbility(region, ..)
| TypeError::StructuralSpecialization { region, .. } | TypeError::StructuralSpecialization { region, .. }
| TypeError::WrongSpecialization { region, .. } | TypeError::WrongSpecialization { region, .. }
| TypeError::BadPatternMissingAbility(region, ..) => Some(*region), | TypeError::BadPatternMissingAbility(region, ..)
| TypeError::UnexpectedModuleParams(region, ..)
| TypeError::MissingModuleParams(region, ..)
| TypeError::ModuleParamsMismatch(region, ..) => Some(*region),
TypeError::UnfulfilledAbility(ab, ..) => ab.region(), TypeError::UnfulfilledAbility(ab, ..) => ab.region(),
TypeError::Exhaustive(e) => Some(e.region()), TypeError::Exhaustive(e) => Some(e.region()),
TypeError::CircularDef(c) => c.first().map(|ce| ce.symbol_region), TypeError::CircularDef(c) => c.first().map(|ce| ce.symbol_region),

View file

@ -405,7 +405,7 @@ fn check_derived_typechecks_and_golden(
let mut def_types = Default::default(); let mut def_types = Default::default();
let mut rigid_vars = Default::default(); let mut rigid_vars = Default::default();
let mut flex_vars = Default::default(); let mut flex_vars = Default::default();
let (import_variables, abilities_store) = add_imports( let (import_variables, imported_param_vars, abilities_store) = add_imports(
test_module, test_module,
&mut constraints, &mut constraints,
&mut test_subs, &mut test_subs,
@ -438,6 +438,8 @@ fn check_derived_typechecks_and_golden(
pending_derives: Default::default(), pending_derives: Default::default(),
exposed_by_module: &exposed_for_module.exposed_by_module, exposed_by_module: &exposed_for_module.exposed_by_module,
derived_module: Default::default(), derived_module: Default::default(),
params_pattern: None,
module_params_vars: imported_param_vars,
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
checkmate: None, checkmate: None,

View file

@ -354,3 +354,85 @@ fn roc_result_after_err() {
RocResult<RocStr, i64> RocResult<RocStr, i64>
); );
} }
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn roc_result_map_both() {
assert_evals_to!(
indoc!(
r#"
result : Result I64 I64
result = Ok 42
result |> Result.mapBoth Num.toStr Num.toStr
"#
),
RocResult::ok(RocStr::from("42")),
RocResult<RocStr, RocStr>
);
assert_evals_to!(
indoc!(
r#"
result : Result I64 I64
result = Err 24
result |> Result.mapBoth Num.toStr Num.toStr
"#
),
RocResult::err(RocStr::from("24")),
RocResult<RocStr, RocStr>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn roc_result_map_two() {
assert_evals_to!(
indoc!(
r#"
first : Result I64 Str
first = Ok 24
second : Result I64 Str
second = Ok -10
Result.map2 first second \a, b -> a + b
"#
),
RocResult::ok(14i64),
RocResult<i64, RocStr>
);
assert_evals_to!(
indoc!(
r#"
first : Result I64 Str
first = Err "foo"
second : Result I64 Str
second = Err "bar"
Result.map2 first second \a, b -> a + b
"#
),
RocResult::err(RocStr::from("foo")),
RocResult<i64, RocStr>
);
assert_evals_to!(
indoc!(
r#"
first : Result I64 Str
first = Ok 42
second : Result I64 Str
second = Err "bar"
Result.map2 first second \a, b -> a + b
"#
),
RocResult::err(RocStr::from("bar")),
RocResult<i64, RocStr>
);
}

View file

@ -2,93 +2,93 @@ procedure Bool.11 (#Attr.2, #Attr.3):
let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3;
ret Bool.23; ret Bool.23;
procedure List.107 (List.536, List.537, List.538): procedure List.110 (List.539, List.540, List.541):
let List.640 : U64 = 0i64; let List.643 : U64 = 0i64;
let List.641 : U64 = CallByName List.6 List.536; let List.644 : U64 = CallByName List.6 List.539;
let List.639 : [C U64, C U64] = CallByName List.80 List.536 List.537 List.538 List.640 List.641; let List.642 : [C U64, C U64] = CallByName List.80 List.539 List.540 List.541 List.643 List.644;
ret List.639; ret List.642;
procedure List.26 (List.204, List.205, List.206): procedure List.26 (List.207, List.208, List.209):
let List.633 : [C U64, C U64] = CallByName List.107 List.204 List.205 List.206; let List.636 : [C U64, C U64] = CallByName List.110 List.207 List.208 List.209;
let List.636 : U8 = 1i64; let List.639 : U8 = 1i64;
let List.637 : U8 = GetTagId List.633; let List.640 : U8 = GetTagId List.636;
let List.638 : Int1 = lowlevel Eq List.636 List.637; let List.641 : Int1 = lowlevel Eq List.639 List.640;
if List.638 then if List.641 then
let List.207 : U64 = UnionAtIndex (Id 1) (Index 0) List.633; let List.210 : U64 = UnionAtIndex (Id 1) (Index 0) List.636;
ret List.207; ret List.210;
else else
let List.208 : U64 = UnionAtIndex (Id 0) (Index 0) List.633; let List.211 : U64 = UnionAtIndex (Id 0) (Index 0) List.636;
ret List.208; ret List.211;
procedure List.38 (List.392, List.393): procedure List.38 (List.395, List.396):
let List.632 : U64 = CallByName List.6 List.392; let List.635 : U64 = CallByName List.6 List.395;
let List.394 : U64 = CallByName Num.77 List.632 List.393; let List.397 : U64 = CallByName Num.77 List.635 List.396;
let List.622 : List U8 = CallByName List.43 List.392 List.394; let List.625 : List U8 = CallByName List.43 List.395 List.397;
ret List.622;
procedure List.43 (List.390, List.391):
let List.630 : U64 = CallByName List.6 List.390;
let List.629 : U64 = CallByName Num.77 List.630 List.391;
let List.624 : {U64, U64} = Struct {List.391, List.629};
let List.623 : List U8 = CallByName List.49 List.390 List.624;
ret List.623;
procedure List.49 (List.468, List.469):
let List.626 : U64 = StructAtIndex 1 List.469;
let List.627 : U64 = StructAtIndex 0 List.469;
let List.625 : List U8 = CallByName List.72 List.468 List.626 List.627;
ret List.625; ret List.625;
procedure List.6 (#Attr.2): procedure List.43 (List.393, List.394):
let List.631 : U64 = lowlevel ListLenU64 #Attr.2; let List.633 : U64 = CallByName List.6 List.393;
ret List.631; let List.632 : U64 = CallByName Num.77 List.633 List.394;
let List.627 : {U64, U64} = Struct {List.394, List.632};
let List.626 : List U8 = CallByName List.49 List.393 List.627;
ret List.626;
procedure List.66 (#Attr.2, #Attr.3): procedure List.49 (List.471, List.472):
let List.654 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.629 : U64 = StructAtIndex 1 List.472;
ret List.654; let List.630 : U64 = StructAtIndex 0 List.472;
let List.628 : List U8 = CallByName List.72 List.471 List.629 List.630;
procedure List.72 (#Attr.2, #Attr.3, #Attr.4):
let List.628 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4;
ret List.628; ret List.628;
procedure List.6 (#Attr.2):
let List.634 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.634;
procedure List.66 (#Attr.2, #Attr.3):
let List.657 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.657;
procedure List.72 (#Attr.2, #Attr.3, #Attr.4):
let List.631 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4;
ret List.631;
procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4):
joinpoint List.642 List.539 List.540 List.541 List.542 List.543: joinpoint List.645 List.542 List.543 List.544 List.545 List.546:
let List.644 : Int1 = CallByName Num.22 List.542 List.543; let List.647 : Int1 = CallByName Num.22 List.545 List.546;
if List.644 then if List.647 then
let List.653 : U8 = CallByName List.66 List.539 List.542; let List.656 : U8 = CallByName List.66 List.542 List.545;
let List.645 : [C U64, C U64] = CallByName Test.4 List.540 List.653; let List.648 : [C U64, C U64] = CallByName Test.4 List.543 List.656;
let List.650 : U8 = 1i64; let List.653 : U8 = 1i64;
let List.651 : U8 = GetTagId List.645; let List.654 : U8 = GetTagId List.648;
let List.652 : Int1 = lowlevel Eq List.650 List.651; let List.655 : Int1 = lowlevel Eq List.653 List.654;
if List.652 then if List.655 then
let List.544 : U64 = UnionAtIndex (Id 1) (Index 0) List.645; let List.547 : U64 = UnionAtIndex (Id 1) (Index 0) List.648;
let List.648 : U64 = 1i64; let List.651 : U64 = 1i64;
let List.647 : U64 = CallByName Num.51 List.542 List.648; let List.650 : U64 = CallByName Num.51 List.545 List.651;
jump List.642 List.539 List.544 List.541 List.647 List.543; jump List.645 List.542 List.547 List.544 List.650 List.546;
else else
dec List.539; dec List.542;
let List.545 : U64 = UnionAtIndex (Id 0) (Index 0) List.645; let List.548 : U64 = UnionAtIndex (Id 0) (Index 0) List.648;
let List.649 : [C U64, C U64] = TagId(0) List.545; let List.652 : [C U64, C U64] = TagId(0) List.548;
ret List.649; ret List.652;
else else
dec List.539; dec List.542;
let List.643 : [C U64, C U64] = TagId(1) List.540; let List.646 : [C U64, C U64] = TagId(1) List.543;
ret List.643; ret List.646;
in in
inc #Derived_gen.0; inc #Derived_gen.0;
jump List.642 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; jump List.645 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282; ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Num.77 (#Attr.2, #Attr.3): procedure Num.77 (#Attr.2, #Attr.3):
let Num.280 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; let Num.282 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Test.1 (Test.2): procedure Test.1 (Test.2):
let Test.13 : U64 = 0i64; let Test.13 : U64 = 0i64;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.4 (Test.27): procedure Test.4 (Test.27):
let Test.39 : [<rnu>C [<rnu><null>, C *self *self] *self, <null>] = TagId(0) ; let Test.39 : [<rnu>C [<rnu><null>, C *self *self] *self, <null>] = TagId(0) ;

View file

@ -1,59 +1,59 @@
procedure List.18 (List.163, List.164, List.165): procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64; let List.629 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.163; let List.630 : U64 = CallByName List.6 List.166;
let List.625 : List {} = CallByName List.92 List.163 List.164 List.165 List.626 List.627; let List.628 : List {} = CallByName List.95 List.166 List.167 List.168 List.629 List.630;
ret List.625; ret List.628;
procedure List.275 (List.276, List.277, List.273): procedure List.278 (List.279, List.280, List.276):
let List.639 : {} = CallByName Test.2 List.277; let List.642 : {} = CallByName Test.2 List.280;
let List.638 : List {} = CallByName List.71 List.276 List.639; let List.641 : List {} = CallByName List.71 List.279 List.642;
ret List.638;
procedure List.5 (List.272, List.273):
let List.274 : U64 = CallByName List.6 List.272;
let List.623 : List {} = CallByName List.68 List.274;
let List.622 : List {} = CallByName List.18 List.272 List.623 List.273;
ret List.622;
procedure List.6 (#Attr.2):
let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.636;
procedure List.66 (#Attr.2, #Attr.3):
let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.68 (#Attr.2):
let List.641 : List {} = lowlevel ListWithCapacity #Attr.2;
ret List.641; ret List.641;
procedure List.71 (#Attr.2, #Attr.3): procedure List.5 (List.275, List.276):
let List.640 : List {} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.277 : U64 = CallByName List.6 List.275;
ret List.640; let List.626 : List {} = CallByName List.68 List.277;
let List.625 : List {} = CallByName List.18 List.275 List.626 List.276;
ret List.625;
procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): procedure List.6 (#Attr.2):
joinpoint List.628 List.166 List.167 List.168 List.169 List.170: let List.639 : U64 = lowlevel ListLenU64 #Attr.2;
let List.630 : Int1 = CallByName Num.22 List.169 List.170; ret List.639;
if List.630 then
let List.634 : [] = CallByName List.66 List.166 List.169; procedure List.66 (#Attr.2, #Attr.3):
let List.171 : List {} = CallByName List.275 List.167 List.634 List.168; let List.638 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
let List.633 : U64 = 1i64; ret List.638;
let List.632 : U64 = CallByName Num.51 List.169 List.633;
jump List.628 List.166 List.171 List.168 List.632 List.170; procedure List.68 (#Attr.2):
let List.644 : List {} = lowlevel ListWithCapacity #Attr.2;
ret List.644;
procedure List.71 (#Attr.2, #Attr.3):
let List.643 : List {} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.643;
procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4):
joinpoint List.631 List.169 List.170 List.171 List.172 List.173:
let List.633 : Int1 = CallByName Num.22 List.172 List.173;
if List.633 then
let List.637 : [] = CallByName List.66 List.169 List.172;
let List.174 : List {} = CallByName List.278 List.170 List.637 List.171;
let List.636 : U64 = 1i64;
let List.635 : U64 = CallByName Num.51 List.172 List.636;
jump List.631 List.169 List.174 List.171 List.635 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.3; inc #Derived_gen.0;
jump List.628 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; jump List.631 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.2 (Test.3): procedure Test.2 (Test.3):
let Test.7 : {} = Struct {}; let Test.7 : {} = Struct {};

View file

@ -1,59 +1,59 @@
procedure List.18 (List.163, List.164, List.165): procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64; let List.629 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.163; let List.630 : U64 = CallByName List.6 List.166;
let List.625 : List [] = CallByName List.92 List.163 List.164 List.165 List.626 List.627; let List.628 : List [] = CallByName List.95 List.166 List.167 List.168 List.629 List.630;
ret List.625; ret List.628;
procedure List.275 (List.276, List.277, List.273): procedure List.278 (List.279, List.280, List.276):
let List.639 : [] = CallByName Test.2 List.277; let List.642 : [] = CallByName Test.2 List.280;
let List.638 : List [] = CallByName List.71 List.276 List.639; let List.641 : List [] = CallByName List.71 List.279 List.642;
ret List.638;
procedure List.5 (List.272, List.273):
let List.274 : U64 = CallByName List.6 List.272;
let List.623 : List [] = CallByName List.68 List.274;
let List.622 : List [] = CallByName List.18 List.272 List.623 List.273;
ret List.622;
procedure List.6 (#Attr.2):
let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.636;
procedure List.66 (#Attr.2, #Attr.3):
let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.68 (#Attr.2):
let List.641 : List [] = lowlevel ListWithCapacity #Attr.2;
ret List.641; ret List.641;
procedure List.71 (#Attr.2, #Attr.3): procedure List.5 (List.275, List.276):
let List.640 : List [] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.277 : U64 = CallByName List.6 List.275;
ret List.640; let List.626 : List [] = CallByName List.68 List.277;
let List.625 : List [] = CallByName List.18 List.275 List.626 List.276;
ret List.625;
procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): procedure List.6 (#Attr.2):
joinpoint List.628 List.166 List.167 List.168 List.169 List.170: let List.639 : U64 = lowlevel ListLenU64 #Attr.2;
let List.630 : Int1 = CallByName Num.22 List.169 List.170; ret List.639;
if List.630 then
let List.634 : [] = CallByName List.66 List.166 List.169; procedure List.66 (#Attr.2, #Attr.3):
let List.171 : List [] = CallByName List.275 List.167 List.634 List.168; let List.638 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
let List.633 : U64 = 1i64; ret List.638;
let List.632 : U64 = CallByName Num.51 List.169 List.633;
jump List.628 List.166 List.171 List.168 List.632 List.170; procedure List.68 (#Attr.2):
let List.644 : List [] = lowlevel ListWithCapacity #Attr.2;
ret List.644;
procedure List.71 (#Attr.2, #Attr.3):
let List.643 : List [] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.643;
procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4):
joinpoint List.631 List.169 List.170 List.171 List.172 List.173:
let List.633 : Int1 = CallByName Num.22 List.172 List.173;
if List.633 then
let List.637 : [] = CallByName List.66 List.169 List.172;
let List.174 : List [] = CallByName List.278 List.170 List.637 List.171;
let List.636 : U64 = 1i64;
let List.635 : U64 = CallByName Num.51 List.172 List.636;
jump List.631 List.169 List.174 List.171 List.635 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.3; inc #Derived_gen.0;
jump List.628 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; jump List.631 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.2 (Test.3): procedure Test.2 (Test.3):
let Test.7 : {} = Struct {}; let Test.7 : {} = Struct {};

View file

@ -1,40 +1,40 @@
procedure List.18 (List.163, List.164, List.165): procedure List.18 (List.166, List.167, List.168):
let List.623 : U64 = 0i64; let List.626 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163; let List.627 : U64 = CallByName List.6 List.166;
let List.622 : [<r>C {}, C *self {{}, []}] = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let List.625 : [<r>C {}, C *self {{}, []}] = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.622; ret List.625;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2; let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633; ret List.636;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.92 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): procedure List.95 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : [] = CallByName List.66 List.166 List.169; let List.634 : [] = CallByName List.66 List.169 List.172;
let List.171 : [<r>C {}, C *self {{}, []}] = CallByName Test.29 List.167 List.631 List.168; let List.174 : [<r>C {}, C *self {{}, []}] = CallByName Test.29 List.170 List.634 List.171;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.11; inc #Derived_gen.13;
jump List.625 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; jump List.628 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.10 (Test.69, #Attr.12): procedure Test.10 (Test.69, #Attr.12):
let Test.72 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; let Test.72 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12;

View file

@ -2,112 +2,112 @@ procedure Bool.1 ():
let Bool.24 : Int1 = false; let Bool.24 : Int1 = false;
ret Bool.24; ret Bool.24;
procedure List.18 (List.163, List.164, List.165): procedure List.18 (List.166, List.167, List.168):
let List.642 : U64 = 0i64; let List.645 : U64 = 0i64;
let List.643 : U64 = CallByName List.6 List.163; let List.646 : U64 = CallByName List.6 List.166;
let List.641 : List Str = CallByName List.92 List.163 List.164 List.165 List.642 List.643; let List.644 : List Str = CallByName List.95 List.166 List.167 List.168 List.645 List.646;
ret List.641; ret List.644;
procedure List.2 (List.111, List.112): procedure List.2 (List.114, List.115):
let List.636 : U64 = CallByName List.6 List.111; let List.639 : U64 = CallByName List.6 List.114;
let List.632 : Int1 = CallByName Num.22 List.112 List.636; let List.635 : Int1 = CallByName Num.22 List.115 List.639;
if List.632 then if List.635 then
let List.634 : Str = CallByName List.66 List.111 List.112; let List.637 : Str = CallByName List.66 List.114 List.115;
inc List.634; inc List.637;
let List.633 : [C {}, C Str] = TagId(1) List.634; let List.636 : [C {}, C Str] = TagId(1) List.637;
ret List.633; ret List.636;
else else
let List.631 : {} = Struct {}; let List.634 : {} = Struct {};
let List.630 : [C {}, C Str] = TagId(0) List.631; let List.633 : [C {}, C Str] = TagId(0) List.634;
ret List.630; ret List.633;
procedure List.275 (List.276, List.277, List.273): procedure List.278 (List.279, List.280, List.276):
let List.655 : Str = CallByName Test.10 List.277; let List.658 : Str = CallByName Test.10 List.280;
let List.654 : List Str = CallByName List.71 List.276 List.655; let List.657 : List Str = CallByName List.71 List.279 List.658;
ret List.654;
procedure List.5 (List.272, List.273):
let List.274 : U64 = CallByName List.6 List.272;
let List.639 : List Str = CallByName List.68 List.274;
let List.638 : List Str = CallByName List.18 List.272 List.639 List.273;
ret List.638;
procedure List.6 (#Attr.2):
let List.637 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.637;
procedure List.6 (#Attr.2):
let List.652 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.652;
procedure List.66 (#Attr.2, #Attr.3):
let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.66 (#Attr.2, #Attr.3):
let List.651 : [<r>C List [<r>C List *self, C *self], C [<r>C List *self, C *self]] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.651;
procedure List.68 (#Attr.2):
let List.657 : List Str = lowlevel ListWithCapacity #Attr.2;
ret List.657; ret List.657;
procedure List.5 (List.275, List.276):
let List.277 : U64 = CallByName List.6 List.275;
let List.642 : List Str = CallByName List.68 List.277;
let List.641 : List Str = CallByName List.18 List.275 List.642 List.276;
ret List.641;
procedure List.6 (#Attr.2):
let List.640 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.640;
procedure List.6 (#Attr.2):
let List.655 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.655;
procedure List.66 (#Attr.2, #Attr.3):
let List.638 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.638;
procedure List.66 (#Attr.2, #Attr.3):
let List.654 : [<r>C List [<r>C List *self, C *self], C [<r>C List *self, C *self]] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.654;
procedure List.68 (#Attr.2):
let List.660 : List Str = lowlevel ListWithCapacity #Attr.2;
ret List.660;
procedure List.71 (#Attr.2, #Attr.3): procedure List.71 (#Attr.2, #Attr.3):
let List.656 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.659 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.656; ret List.659;
procedure List.9 (List.383): procedure List.9 (List.386):
let List.629 : U64 = 0i64; let List.632 : U64 = 0i64;
let List.622 : [C {}, C Str] = CallByName List.2 List.383 List.629; let List.625 : [C {}, C Str] = CallByName List.2 List.386 List.632;
let List.626 : U8 = 1i64; let List.629 : U8 = 1i64;
let List.627 : U8 = GetTagId List.622; let List.630 : U8 = GetTagId List.625;
let List.628 : Int1 = lowlevel Eq List.626 List.627; let List.631 : Int1 = lowlevel Eq List.629 List.630;
if List.628 then if List.631 then
let List.384 : Str = UnionAtIndex (Id 1) (Index 0) List.622; let List.387 : Str = UnionAtIndex (Id 1) (Index 0) List.625;
let List.623 : [C {}, C Str] = TagId(1) List.384; let List.626 : [C {}, C Str] = TagId(1) List.387;
ret List.623; ret List.626;
else else
dec List.622; dec List.625;
let List.625 : {} = Struct {}; let List.628 : {} = Struct {};
let List.624 : [C {}, C Str] = TagId(0) List.625; let List.627 : [C {}, C Str] = TagId(0) List.628;
ret List.624; ret List.627;
procedure List.92 (#Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8): procedure List.95 (#Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8):
joinpoint List.644 List.166 List.167 List.168 List.169 List.170: joinpoint List.647 List.169 List.170 List.171 List.172 List.173:
let List.646 : Int1 = CallByName Num.22 List.169 List.170; let List.649 : Int1 = CallByName Num.22 List.172 List.173;
if List.646 then if List.649 then
let List.650 : [<r>C List [<r>C List *self, C *self], C [<r>C List *self, C *self]] = CallByName List.66 List.166 List.169; let List.653 : [<r>C List [<r>C List *self, C *self], C [<r>C List *self, C *self]] = CallByName List.66 List.169 List.172;
inc List.650; inc List.653;
let List.171 : List Str = CallByName List.275 List.167 List.650 List.168; let List.174 : List Str = CallByName List.278 List.170 List.653 List.171;
let List.649 : U64 = 1i64; let List.652 : U64 = 1i64;
let List.648 : U64 = CallByName Num.51 List.169 List.649; let List.651 : U64 = CallByName Num.51 List.172 List.652;
jump List.644 List.166 List.171 List.168 List.648 List.170; jump List.647 List.169 List.174 List.171 List.651 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.4; inc #Derived_gen.4;
jump List.644 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8; jump List.647 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Result.5 (Result.10, Result.11): procedure Result.5 (Result.13, Result.14):
let Result.37 : U8 = 1i64; let Result.57 : U8 = 1i64;
let Result.38 : U8 = GetTagId Result.10; let Result.58 : U8 = GetTagId Result.13;
let Result.39 : Int1 = lowlevel Eq Result.37 Result.38; let Result.59 : Int1 = lowlevel Eq Result.57 Result.58;
if Result.39 then if Result.59 then
dec Result.11; dec Result.14;
let Result.12 : Str = UnionAtIndex (Id 1) (Index 0) Result.10; let Result.15 : Str = UnionAtIndex (Id 1) (Index 0) Result.13;
ret Result.12; ret Result.15;
else else
dec Result.10; dec Result.13;
ret Result.11; ret Result.14;
procedure Test.10 (Test.11): procedure Test.10 (Test.11):
let Test.12 : Str = CallByName Test.2 Test.11; let Test.12 : Str = CallByName Test.2 Test.11;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.280 : I128 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.282 : I128 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Test.0 (): procedure Test.0 ():
let Test.6 : I128 = 18446744073709551616i64; let Test.6 : I128 = 18446744073709551616i64;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : U128 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.281 : U128 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.0 (): procedure Test.0 ():
let Test.2 : U128 = 170141183460469231731687303715884105728u128; let Test.2 : U128 = 170141183460469231731687303715884105728u128;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.281 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.0 (): procedure Test.0 ():
let Test.2 : U64 = 9999999999999999999i64; let Test.2 : U64 = 9999999999999999999i64;

View file

@ -1,6 +1,6 @@
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.622 : U64 = lowlevel ListLenU64 #Attr.2; let List.625 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.622; ret List.625;
procedure Test.1 (Test.5): procedure Test.1 (Test.5):
let Test.2 : I64 = 41i64; let Test.2 : I64 = 41i64;

View file

@ -2,47 +2,47 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true; let Bool.23 : Int1 = true;
ret Bool.23; ret Bool.23;
procedure List.18 (List.163, List.164, List.165): procedure List.18 (List.166, List.167, List.168):
let List.623 : U64 = 0i64; let List.626 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163; let List.627 : U64 = CallByName List.6 List.166;
let List.622 : [<rnw><null>, C *self Int1, C *self Int1] = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let List.625 : [<rnw><null>, C *self Int1, C *self Int1] = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.622; ret List.625;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2; let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633; ret List.636;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.92 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9): procedure List.95 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : Int1 = CallByName List.66 List.166 List.169; let List.634 : Int1 = CallByName List.66 List.169 List.172;
let List.171 : [<rnw><null>, C *self Int1, C *self Int1] = CallByName Test.6 List.167 List.631 List.168; let List.174 : [<rnw><null>, C *self Int1, C *self Int1] = CallByName Test.6 List.170 List.634 List.171;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.5; inc #Derived_gen.5;
jump List.625 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9; jump List.628 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.234 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.238 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.234; ret Str.238;
procedure Test.1 (Test.5): procedure Test.1 (Test.5):
ret Test.5; ret Test.5;

View file

@ -2,50 +2,50 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true; let Bool.23 : Int1 = true;
ret Bool.23; ret Bool.23;
procedure Inspect.246 (Inspect.247, Inspect.245): procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.323 : Str = "\"";
let Inspect.322 : Str = CallByName Inspect.63 Inspect.251 Inspect.323;
dec Inspect.323;
let Inspect.318 : Str = CallByName Inspect.63 Inspect.322 Inspect.249;
let Inspect.319 : Str = "\""; let Inspect.319 : Str = "\"";
let Inspect.318 : Str = CallByName Inspect.59 Inspect.247 Inspect.319; let Inspect.317 : Str = CallByName Inspect.63 Inspect.318 Inspect.319;
dec Inspect.319; dec Inspect.319;
let Inspect.314 : Str = CallByName Inspect.59 Inspect.318 Inspect.245;
let Inspect.315 : Str = "\"";
let Inspect.313 : Str = CallByName Inspect.59 Inspect.314 Inspect.315;
dec Inspect.315;
ret Inspect.313;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.43 (Inspect.245):
let Inspect.309 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.309;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : Str = CallByName Inspect.43 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName Inspect.246 Inspect.304 Inspect.308;
dec Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.317 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.317; ret Inspect.317;
procedure Inspect.60 (Inspect.298): procedure Inspect.30 (Inspect.147):
ret Inspect.298; ret Inspect.147;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.47 (Inspect.249):
let Inspect.313 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.313;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : Str = CallByName Inspect.47 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName Inspect.250 Inspect.308 Inspect.312;
dec Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.321 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.321;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232; ret Str.236;
procedure Test.1 (): procedure Test.1 ():
let Test.4 : Str = ""; let Test.4 : Str = "";

View file

@ -1,47 +1,47 @@
procedure Inspect.246 (Inspect.247, Inspect.245): procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.323 : Str = "\"";
let Inspect.322 : Str = CallByName Inspect.63 Inspect.251 Inspect.323;
dec Inspect.323;
let Inspect.318 : Str = CallByName Inspect.63 Inspect.322 Inspect.249;
let Inspect.319 : Str = "\""; let Inspect.319 : Str = "\"";
let Inspect.318 : Str = CallByName Inspect.59 Inspect.247 Inspect.319; let Inspect.317 : Str = CallByName Inspect.63 Inspect.318 Inspect.319;
dec Inspect.319; dec Inspect.319;
let Inspect.314 : Str = CallByName Inspect.59 Inspect.318 Inspect.245;
let Inspect.315 : Str = "\"";
let Inspect.313 : Str = CallByName Inspect.59 Inspect.314 Inspect.315;
dec Inspect.315;
ret Inspect.313;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.43 (Inspect.245):
let Inspect.309 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.309;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : Str = CallByName Inspect.43 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName Inspect.246 Inspect.304 Inspect.308;
dec Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.317 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.317; ret Inspect.317;
procedure Inspect.60 (Inspect.298): procedure Inspect.30 (Inspect.147):
ret Inspect.298; ret Inspect.147;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.47 (Inspect.249):
let Inspect.313 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.313;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : Str = CallByName Inspect.47 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName Inspect.250 Inspect.308 Inspect.312;
dec Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.321 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.321;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232; ret Str.236;
procedure Test.0 (): procedure Test.0 ():
let Test.3 : Str = ""; let Test.3 : Str = "";

View file

@ -1,37 +1,37 @@
procedure Dict.1 (Dict.723): procedure Dict.1 (Dict.730):
let Dict.732 : List {U32, U32} = Array []; let Dict.739 : List {U32, U32} = Array [];
let Dict.733 : List {[], []} = Array []; let Dict.740 : List {[], []} = Array [];
let Dict.734 : U64 = 0i64; let Dict.741 : U64 = 0i64;
let Dict.44 : Float32 = CallByName Dict.44; let Dict.51 : Float32 = CallByName Dict.51;
let Dict.45 : U8 = CallByName Dict.45; let Dict.52 : U8 = CallByName Dict.52;
let Dict.731 : {List {U32, U32}, List {[], []}, U64, Float32, U8} = Struct {Dict.732, Dict.733, Dict.734, Dict.44, Dict.45}; let Dict.738 : {List {U32, U32}, List {[], []}, U64, Float32, U8} = Struct {Dict.739, Dict.740, Dict.741, Dict.51, Dict.52};
ret Dict.731;
procedure Dict.4 (Dict.729):
let Dict.156 : List {[], []} = StructAtIndex 1 Dict.729;
let #Derived_gen.0 : List {U32, U32} = StructAtIndex 0 Dict.729;
dec #Derived_gen.0;
let Dict.730 : U64 = CallByName List.6 Dict.156;
dec Dict.156;
ret Dict.730;
procedure Dict.44 ():
let Dict.738 : Float32 = 0.8f64;
ret Dict.738; ret Dict.738;
procedure Dict.45 (): procedure Dict.4 (Dict.736):
let Dict.736 : U8 = 64i64; let Dict.163 : List {[], []} = StructAtIndex 1 Dict.736;
let Dict.737 : U8 = 3i64; let #Derived_gen.0 : List {U32, U32} = StructAtIndex 0 Dict.736;
let Dict.735 : U8 = CallByName Num.75 Dict.736 Dict.737; dec #Derived_gen.0;
ret Dict.735; let Dict.737 : U64 = CallByName List.6 Dict.163;
dec Dict.163;
ret Dict.737;
procedure Dict.51 ():
let Dict.745 : Float32 = 0.8f64;
ret Dict.745;
procedure Dict.52 ():
let Dict.743 : U8 = 64i64;
let Dict.744 : U8 = 3i64;
let Dict.742 : U8 = CallByName Num.75 Dict.743 Dict.744;
ret Dict.742;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.622 : U64 = lowlevel ListLenU64 #Attr.2; let List.625 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.622; ret List.625;
procedure Num.75 (#Attr.2, #Attr.3): procedure Num.75 (#Attr.2, #Attr.3):
let Num.279 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3; let Num.281 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.0 (): procedure Test.0 ():
let Test.3 : {} = Struct {}; let Test.3 : {} = Struct {};

View file

@ -2,29 +2,29 @@ procedure Bool.1 ():
let Bool.23 : Int1 = false; let Bool.23 : Int1 = false;
ret Bool.23; ret Bool.23;
procedure List.2 (List.111, List.112): procedure List.2 (List.114, List.115):
let List.628 : U64 = CallByName List.6 List.111; let List.631 : U64 = CallByName List.6 List.114;
let List.624 : Int1 = CallByName Num.22 List.112 List.628; let List.627 : Int1 = CallByName Num.22 List.115 List.631;
if List.624 then if List.627 then
let List.626 : {} = CallByName List.66 List.111 List.112; let List.629 : {} = CallByName List.66 List.114 List.115;
let List.625 : [C {}, C {}] = TagId(1) List.626; let List.628 : [C {}, C {}] = TagId(1) List.629;
ret List.625; ret List.628;
else else
let List.623 : {} = Struct {}; let List.626 : {} = Struct {};
let List.622 : [C {}, C {}] = TagId(0) List.623; let List.625 : [C {}, C {}] = TagId(0) List.626;
ret List.622; ret List.625;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.629 : U64 = lowlevel ListLenU64 #Attr.2; let List.632 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.629; ret List.632;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.627 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.630 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.627; ret List.630;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.279 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.2 (Test.5): procedure Test.2 (Test.5):
let Test.17 : Str = "bar"; let Test.17 : Str = "bar";

View file

@ -1,16 +1,16 @@
procedure List.4 (List.127, List.128): procedure List.4 (List.130, List.131):
let List.625 : U64 = 1i64; let List.628 : U64 = 1i64;
let List.623 : List U8 = CallByName List.70 List.127 List.625; let List.626 : List U8 = CallByName List.70 List.130 List.628;
let List.622 : List U8 = CallByName List.71 List.623 List.128; let List.625 : List U8 = CallByName List.71 List.626 List.131;
ret List.622; ret List.625;
procedure List.70 (#Attr.2, #Attr.3): procedure List.70 (#Attr.2, #Attr.3):
let List.626 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; let List.629 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.626; ret List.629;
procedure List.71 (#Attr.2, #Attr.3): procedure List.71 (#Attr.2, #Attr.3):
let List.624 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.627 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.624; ret List.627;
procedure Test.23 (Test.24, Test.35, Test.22): procedure Test.23 (Test.24, Test.35, Test.22):
let Test.37 : List U8 = CallByName List.4 Test.24 Test.22; let Test.37 : List U8 = CallByName List.4 Test.24 Test.22;

View file

@ -7,7 +7,7 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1):
let #Derived_gen.8 : Str = CallByName #Derived.5 #Derived.1; let #Derived_gen.8 : Str = CallByName #Derived.5 #Derived.1;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6];
let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5;
let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4;
dec #Derived_gen.4; dec #Derived_gen.4;
ret #Derived_gen.3; ret #Derived_gen.3;
@ -18,263 +18,263 @@ procedure #Derived.5 (#Derived.6):
procedure #Derived.7 (#Derived.8, #Derived.9, #Derived.6): procedure #Derived.7 (#Derived.8, #Derived.9, #Derived.6):
let #Derived_gen.17 : Str = "b"; let #Derived_gen.17 : Str = "b";
let #Derived_gen.18 : Str = CallByName Test.19 #Derived.6; let #Derived_gen.18 : Str = CallByName Test.20 #Derived.6;
let #Derived_gen.16 : {Str, Str} = Struct {#Derived_gen.17, #Derived_gen.18}; let #Derived_gen.16 : {Str, Str} = Struct {#Derived_gen.17, #Derived_gen.18};
let #Derived_gen.15 : List {Str, Str} = Array [#Derived_gen.16]; let #Derived_gen.15 : List {Str, Str} = Array [#Derived_gen.16];
let #Derived_gen.14 : List {Str, Str} = CallByName Test.21 #Derived_gen.15; let #Derived_gen.14 : List {Str, Str} = CallByName Test.22 #Derived_gen.15;
let #Derived_gen.13 : List U8 = CallByName Encode.24 #Derived.8 #Derived_gen.14 #Derived.9; let #Derived_gen.13 : List U8 = CallByName Encode.24 #Derived.8 #Derived_gen.14 #Derived.9;
dec #Derived_gen.14; dec #Derived_gen.14;
ret #Derived_gen.13; ret #Derived_gen.13;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107; let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107;
ret Encode.113; ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.116 : List U8 = CallByName #Derived.7 Encode.99 Encode.101 Encode.107; let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109;
ret Encode.116; ret Encode.115;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.119 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; let Encode.118 : List U8 = CallByName #Derived.7 Encode.101 Encode.103 Encode.109;
ret Encode.119; ret Encode.118;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.124 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; let Encode.121 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109;
ret Encode.124; ret Encode.121;
procedure Encode.26 (Encode.105, Encode.106): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.109 : List U8 = Array []; let Encode.126 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
let Encode.110 : Str = CallByName #Derived.0 Encode.105; ret Encode.126;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure List.18 (List.163, List.164, List.165): procedure Encode.26 (Encode.107, Encode.108):
let List.623 : U64 = 0i64; let Encode.111 : List U8 = Array [];
let List.624 : U64 = CallByName List.6 List.163; let Encode.112 : Str = CallByName #Derived.0 Encode.107;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret List.622; ret Encode.110;
procedure List.18 (List.163, List.164, List.165): procedure List.18 (List.166, List.167, List.168):
let List.649 : U64 = 0i64; let List.626 : U64 = 0i64;
let List.650 : U64 = CallByName List.6 List.163; let List.627 : U64 = CallByName List.6 List.166;
let List.648 : List U8 = CallByName List.92 List.163 List.164 List.165 List.649 List.650; let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.648; ret List.625;
procedure List.4 (List.127, List.128): procedure List.18 (List.166, List.167, List.168):
let List.670 : U64 = 1i64; let List.652 : U64 = 0i64;
let List.669 : List U8 = CallByName List.70 List.127 List.670; let List.653 : U64 = CallByName List.6 List.166;
let List.668 : List U8 = CallByName List.71 List.669 List.128; let List.651 : List U8 = CallByName List.95 List.166 List.167 List.168 List.652 List.653;
ret List.668; ret List.651;
procedure List.4 (List.130, List.131):
let List.673 : U64 = 1i64;
let List.672 : List U8 = CallByName List.70 List.130 List.673;
let List.671 : List U8 = CallByName List.71 List.672 List.131;
ret List.671;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2; let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647; ret List.650;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.673 : U64 = lowlevel ListLenU64 #Attr.2; let List.676 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.673; ret List.676;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.658 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.661 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.658; ret List.661;
procedure List.70 (#Attr.2, #Attr.3): procedure List.70 (#Attr.2, #Attr.3):
let List.664 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; let List.667 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.664; ret List.667;
procedure List.71 (#Attr.2, #Attr.3): procedure List.71 (#Attr.2, #Attr.3):
let List.662 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.665 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.662; ret List.665;
procedure List.8 (#Attr.2, #Attr.3): procedure List.8 (#Attr.2, #Attr.3):
let List.672 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; let List.675 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.672; ret List.675;
procedure List.92 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): procedure List.95 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30):
joinpoint List.651 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.653 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.653 then if List.630 then
let List.657 : {Str, Str} = CallByName List.66 List.166 List.169; let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.657; inc List.634;
let List.171 : List U8 = CallByName Test.70 List.167 List.657; let List.174 : List U8 = CallByName Test.71 List.170 List.634;
let List.656 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.655 : U64 = CallByName Num.51 List.169 List.656; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.651 List.166 List.171 List.168 List.655 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.29; inc #Derived_gen.26;
jump List.651 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; jump List.628 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30;
procedure List.92 (#Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41): procedure List.95 (#Derived_gen.40, #Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_gen.44):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.654 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.656 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.656 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; let List.660 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.631; inc List.660;
let List.171 : List U8 = CallByName Test.70 List.167 List.631; let List.174 : List U8 = CallByName Test.71 List.170 List.660;
let List.630 : U64 = 1i64; let List.659 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.658 : U64 = CallByName Num.51 List.172 List.659;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.654 List.169 List.174 List.171 List.658 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.37; inc #Derived_gen.40;
jump List.625 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41; jump List.654 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44;
procedure Num.127 (#Attr.2): procedure Num.127 (#Attr.2):
let Num.284 : U8 = lowlevel NumIntCast #Attr.2; let Num.286 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.284;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.286; ret Num.286;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.288 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.288;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.285 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.287 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.285; ret Num.287;
procedure Num.96 (#Attr.2): procedure Num.96 (#Attr.2):
let Num.283 : Str = lowlevel NumToStr #Attr.2; let Num.285 : Str = lowlevel NumToStr #Attr.2;
ret Num.283; ret Num.285;
procedure Str.12 (#Attr.2): procedure Str.12 (#Attr.2):
let Str.244 : List U8 = lowlevel StrToUtf8 #Attr.2; let Str.248 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.244; ret Str.248;
procedure Str.36 (#Attr.2): procedure Str.36 (#Attr.2):
let Str.245 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; let Str.249 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.245; ret Str.249;
procedure Str.43 (#Attr.2): procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239; ret Str.243;
procedure Str.9 (Str.67): procedure Str.9 (Str.71):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.236 : Int1 = StructAtIndex 2 Str.68; let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.236 then if Str.240 then
let Str.238 : Str = StructAtIndex 1 Str.68; let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.237; ret Str.241;
else else
let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.235 : U64 = StructAtIndex 0 Str.68; let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.45 : Str = StructAtIndex 1 Str.68; let #Derived_gen.45 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.45; dec #Derived_gen.45;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.232; ret Str.236;
procedure Test.19 (Test.55): procedure Test.20 (Test.56):
let Test.324 : Str = CallByName Encode.23 Test.55; let Test.325 : Str = CallByName Encode.23 Test.56;
ret Test.324; ret Test.325;
procedure Test.2 (): procedure Test.22 (Test.67):
let Test.257 : {} = Struct {}; let Test.261 : List {Str, Str} = CallByName Encode.23 Test.67;
ret Test.257; ret Test.261;
procedure Test.21 (Test.66): procedure Test.22 (Test.67):
let Test.260 : List {Str, Str} = CallByName Encode.23 Test.66; let Test.293 : List {Str, Str} = CallByName Encode.23 Test.67;
ret Test.260; ret Test.293;
procedure Test.21 (Test.66): procedure Test.3 ():
let Test.292 : List {Str, Str} = CallByName Encode.23 Test.66; let Test.258 : {} = Struct {};
ret Test.292; ret Test.258;
procedure Test.3 (Test.48, Test.49, Test.50): procedure Test.4 (Test.49, Test.50, Test.51):
let Test.321 : U8 = CallByName Num.127 Test.49; let Test.322 : U8 = CallByName Num.127 Test.50;
let Test.318 : List U8 = CallByName List.4 Test.48 Test.321; let Test.319 : List U8 = CallByName List.4 Test.49 Test.322;
let Test.320 : Str = CallByName Num.96 Test.50; let Test.321 : Str = CallByName Num.96 Test.51;
let Test.319 : List U8 = CallByName Str.12 Test.320; let Test.320 : List U8 = CallByName Str.12 Test.321;
let Test.316 : List U8 = CallByName List.8 Test.318 Test.319; let Test.317 : List U8 = CallByName List.8 Test.319 Test.320;
let Test.317 : U8 = 32i64; let Test.318 : U8 = 32i64;
let Test.315 : List U8 = CallByName List.4 Test.316 Test.317; let Test.316 : List U8 = CallByName List.4 Test.317 Test.318;
ret Test.315; ret Test.316;
procedure Test.56 (Test.57, Test.274, Test.55): procedure Test.57 (Test.58, Test.275, Test.56):
let Test.313 : I64 = 115i64; let Test.314 : I64 = 115i64;
let Test.314 : U64 = CallByName Str.36 Test.55; let Test.315 : U64 = CallByName Str.36 Test.56;
let Test.311 : List U8 = CallByName Test.3 Test.57 Test.313 Test.314; let Test.312 : List U8 = CallByName Test.4 Test.58 Test.314 Test.315;
let Test.312 : List U8 = CallByName Str.12 Test.55; let Test.313 : List U8 = CallByName Str.12 Test.56;
let Test.309 : List U8 = CallByName List.8 Test.311 Test.312; let Test.310 : List U8 = CallByName List.8 Test.312 Test.313;
let Test.310 : U8 = 32i64; let Test.311 : U8 = 32i64;
let Test.308 : List U8 = CallByName List.4 Test.309 Test.310; let Test.309 : List U8 = CallByName List.4 Test.310 Test.311;
ret Test.308; ret Test.309;
procedure Test.67 (Test.68, Test.262, Test.66): procedure Test.68 (Test.69, Test.263, Test.67):
let Test.290 : I64 = 114i64; let Test.291 : I64 = 114i64;
let Test.291 : U64 = CallByName List.6 Test.66; let Test.292 : U64 = CallByName List.6 Test.67;
let Test.69 : List U8 = CallByName Test.3 Test.68 Test.290 Test.291; let Test.70 : List U8 = CallByName Test.4 Test.69 Test.291 Test.292;
let Test.265 : {} = Struct {}; let Test.266 : {} = Struct {};
let Test.264 : List U8 = CallByName List.18 Test.66 Test.69 Test.265; let Test.265 : List U8 = CallByName List.18 Test.67 Test.70 Test.266;
ret Test.264; ret Test.265;
procedure Test.67 (Test.68, Test.262, Test.66): procedure Test.68 (Test.69, Test.263, Test.67):
let Test.322 : I64 = 114i64; let Test.323 : I64 = 114i64;
let Test.323 : U64 = CallByName List.6 Test.66; let Test.324 : U64 = CallByName List.6 Test.67;
let Test.69 : List U8 = CallByName Test.3 Test.68 Test.322 Test.323; let Test.70 : List U8 = CallByName Test.4 Test.69 Test.323 Test.324;
let Test.297 : {} = Struct {}; let Test.298 : {} = Struct {};
let Test.296 : List U8 = CallByName List.18 Test.66 Test.69 Test.297; let Test.297 : List U8 = CallByName List.18 Test.67 Test.70 Test.298;
ret Test.296; ret Test.297;
procedure Test.70 (Test.71, Test.266): procedure Test.71 (Test.72, Test.267):
let Test.72 : Str = StructAtIndex 0 Test.266; let Test.73 : Str = StructAtIndex 0 Test.267;
let Test.73 : Str = StructAtIndex 1 Test.266; let Test.74 : Str = StructAtIndex 1 Test.267;
let Test.270 : Str = CallByName Test.19 Test.72; let Test.271 : Str = CallByName Test.20 Test.73;
let Test.271 : {} = Struct {}; let Test.272 : {} = Struct {};
let Test.268 : List U8 = CallByName Encode.24 Test.71 Test.270 Test.271; let Test.269 : List U8 = CallByName Encode.24 Test.72 Test.271 Test.272;
let Test.269 : {} = Struct {}; let Test.270 : {} = Struct {};
let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.73 Test.269; let Test.268 : List U8 = CallByName Encode.24 Test.269 Test.74 Test.270;
ret Test.267; ret Test.268;
procedure Test.70 (Test.71, Test.266): procedure Test.71 (Test.72, Test.267):
let Test.72 : Str = StructAtIndex 0 Test.266; let Test.73 : Str = StructAtIndex 0 Test.267;
let Test.73 : Str = StructAtIndex 1 Test.266; let Test.74 : Str = StructAtIndex 1 Test.267;
let Test.302 : Str = CallByName Test.19 Test.72; let Test.303 : Str = CallByName Test.20 Test.73;
let Test.303 : {} = Struct {}; let Test.304 : {} = Struct {};
let Test.300 : List U8 = CallByName Encode.24 Test.71 Test.302 Test.303; let Test.301 : List U8 = CallByName Encode.24 Test.72 Test.303 Test.304;
let Test.301 : {} = Struct {}; let Test.302 : {} = Struct {};
let Test.299 : List U8 = CallByName Encode.24 Test.300 Test.73 Test.301; let Test.300 : List U8 = CallByName Encode.24 Test.301 Test.74 Test.302;
ret Test.299; ret Test.300;
procedure Test.0 (): procedure Test.0 ():
let Test.259 : Str = "bar"; let Test.260 : Str = "bar";
let Test.256 : {} = CallByName Test.2; let Test.257 : {} = CallByName Test.3;
let Test.254 : List U8 = CallByName Encode.26 Test.259 Test.256; let Test.255 : List U8 = CallByName Encode.26 Test.260 Test.257;
let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255;
let Test.251 : U8 = 1i64; let Test.252 : U8 = 1i64;
let Test.252 : U8 = GetTagId Test.209; let Test.253 : U8 = GetTagId Test.210;
let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; let Test.254 : Int1 = lowlevel Eq Test.252 Test.253;
if Test.253 then if Test.254 then
let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.210; ret Test.211;
else else
dec Test.209; dec Test.210;
let Test.250 : Str = "<bad>"; let Test.251 : Str = "<bad>";
ret Test.250; ret Test.251;

View file

@ -4,196 +4,196 @@ procedure #Derived.0 (#Derived.1):
procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1): procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1):
let #Derived_gen.7 : Str = "a"; let #Derived_gen.7 : Str = "a";
let #Derived_gen.8 : Str = CallByName Test.19 #Derived.1; let #Derived_gen.8 : Str = CallByName Test.20 #Derived.1;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6];
let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5;
let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4;
dec #Derived_gen.4; dec #Derived_gen.4;
ret #Derived_gen.3; ret #Derived_gen.3;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107; let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107;
ret Encode.113; ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.118 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109;
ret Encode.118; ret Encode.115;
procedure Encode.26 (Encode.105, Encode.106): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.109 : List U8 = Array []; let Encode.120 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
let Encode.110 : Str = CallByName #Derived.0 Encode.105; ret Encode.120;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure List.18 (List.163, List.164, List.165): procedure Encode.26 (Encode.107, Encode.108):
let List.623 : U64 = 0i64; let Encode.111 : List U8 = Array [];
let List.624 : U64 = CallByName List.6 List.163; let Encode.112 : Str = CallByName #Derived.0 Encode.107;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret List.622; ret Encode.110;
procedure List.4 (List.127, List.128): procedure List.18 (List.166, List.167, List.168):
let List.644 : U64 = 1i64; let List.626 : U64 = 0i64;
let List.643 : List U8 = CallByName List.70 List.127 List.644; let List.627 : U64 = CallByName List.6 List.166;
let List.642 : List U8 = CallByName List.71 List.643 List.128; let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.642; ret List.625;
procedure List.4 (List.130, List.131):
let List.647 : U64 = 1i64;
let List.646 : List U8 = CallByName List.70 List.130 List.647;
let List.645 : List U8 = CallByName List.71 List.646 List.131;
ret List.645;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2; let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647; ret List.650;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.70 (#Attr.2, #Attr.3): procedure List.70 (#Attr.2, #Attr.3):
let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.638; ret List.641;
procedure List.71 (#Attr.2, #Attr.3): procedure List.71 (#Attr.2, #Attr.3):
let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.636; ret List.639;
procedure List.8 (#Attr.2, #Attr.3): procedure List.8 (#Attr.2, #Attr.3):
let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.646; ret List.649;
procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): procedure List.95 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : List U8 = CallByName Test.70 List.167 List.631; let List.174 : List U8 = CallByName Test.71 List.170 List.634;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.13; inc #Derived_gen.13;
jump List.625 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; jump List.628 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17;
procedure Num.127 (#Attr.2): procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2; let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282; ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Num.96 (#Attr.2): procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2; let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.279; ret Num.281;
procedure Str.12 (#Attr.2): procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241; ret Str.245;
procedure Str.36 (#Attr.2): procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242; ret Str.246;
procedure Str.43 (#Attr.2): procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239; ret Str.243;
procedure Str.9 (Str.67): procedure Str.9 (Str.71):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.236 : Int1 = StructAtIndex 2 Str.68; let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.236 then if Str.240 then
let Str.238 : Str = StructAtIndex 1 Str.68; let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.237; ret Str.241;
else else
let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.235 : U64 = StructAtIndex 0 Str.68; let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.24 : Str = StructAtIndex 1 Str.68; let #Derived_gen.24 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.24; dec #Derived_gen.24;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.232; ret Str.236;
procedure Test.19 (Test.55): procedure Test.20 (Test.56):
let Test.291 : Str = CallByName Encode.23 Test.55; let Test.292 : Str = CallByName Encode.23 Test.56;
ret Test.291; ret Test.292;
procedure Test.2 (): procedure Test.22 (Test.67):
let Test.257 : {} = Struct {}; let Test.260 : List {Str, Str} = CallByName Encode.23 Test.67;
ret Test.257; ret Test.260;
procedure Test.21 (Test.66): procedure Test.3 ():
let Test.259 : List {Str, Str} = CallByName Encode.23 Test.66; let Test.258 : {} = Struct {};
ret Test.259; ret Test.258;
procedure Test.3 (Test.48, Test.49, Test.50): procedure Test.4 (Test.49, Test.50, Test.51):
let Test.288 : U8 = CallByName Num.127 Test.49; let Test.289 : U8 = CallByName Num.127 Test.50;
let Test.285 : List U8 = CallByName List.4 Test.48 Test.288; let Test.286 : List U8 = CallByName List.4 Test.49 Test.289;
let Test.287 : Str = CallByName Num.96 Test.50; let Test.288 : Str = CallByName Num.96 Test.51;
let Test.286 : List U8 = CallByName Str.12 Test.287; let Test.287 : List U8 = CallByName Str.12 Test.288;
let Test.283 : List U8 = CallByName List.8 Test.285 Test.286; let Test.284 : List U8 = CallByName List.8 Test.286 Test.287;
let Test.284 : U8 = 32i64; let Test.285 : U8 = 32i64;
let Test.282 : List U8 = CallByName List.4 Test.283 Test.284; let Test.283 : List U8 = CallByName List.4 Test.284 Test.285;
ret Test.282; ret Test.283;
procedure Test.56 (Test.57, Test.273, Test.55): procedure Test.57 (Test.58, Test.274, Test.56):
let Test.280 : I64 = 115i64; let Test.281 : I64 = 115i64;
let Test.281 : U64 = CallByName Str.36 Test.55; let Test.282 : U64 = CallByName Str.36 Test.56;
let Test.278 : List U8 = CallByName Test.3 Test.57 Test.280 Test.281; let Test.279 : List U8 = CallByName Test.4 Test.58 Test.281 Test.282;
let Test.279 : List U8 = CallByName Str.12 Test.55; let Test.280 : List U8 = CallByName Str.12 Test.56;
let Test.276 : List U8 = CallByName List.8 Test.278 Test.279; let Test.277 : List U8 = CallByName List.8 Test.279 Test.280;
let Test.277 : U8 = 32i64; let Test.278 : U8 = 32i64;
let Test.275 : List U8 = CallByName List.4 Test.276 Test.277; let Test.276 : List U8 = CallByName List.4 Test.277 Test.278;
ret Test.275; ret Test.276;
procedure Test.67 (Test.68, Test.261, Test.66): procedure Test.68 (Test.69, Test.262, Test.67):
let Test.289 : I64 = 114i64; let Test.290 : I64 = 114i64;
let Test.290 : U64 = CallByName List.6 Test.66; let Test.291 : U64 = CallByName List.6 Test.67;
let Test.69 : List U8 = CallByName Test.3 Test.68 Test.289 Test.290; let Test.70 : List U8 = CallByName Test.4 Test.69 Test.290 Test.291;
let Test.264 : {} = Struct {}; let Test.265 : {} = Struct {};
let Test.263 : List U8 = CallByName List.18 Test.66 Test.69 Test.264; let Test.264 : List U8 = CallByName List.18 Test.67 Test.70 Test.265;
ret Test.263; ret Test.264;
procedure Test.70 (Test.71, Test.265): procedure Test.71 (Test.72, Test.266):
let Test.72 : Str = StructAtIndex 0 Test.265; let Test.73 : Str = StructAtIndex 0 Test.266;
let Test.73 : Str = StructAtIndex 1 Test.265; let Test.74 : Str = StructAtIndex 1 Test.266;
let Test.269 : Str = CallByName Test.19 Test.72; let Test.270 : Str = CallByName Test.20 Test.73;
let Test.270 : {} = Struct {}; let Test.271 : {} = Struct {};
let Test.267 : List U8 = CallByName Encode.24 Test.71 Test.269 Test.270; let Test.268 : List U8 = CallByName Encode.24 Test.72 Test.270 Test.271;
let Test.268 : {} = Struct {}; let Test.269 : {} = Struct {};
let Test.266 : List U8 = CallByName Encode.24 Test.267 Test.73 Test.268; let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.74 Test.269;
ret Test.266; ret Test.267;
procedure Test.0 (): procedure Test.0 ():
let Test.258 : Str = "foo"; let Test.259 : Str = "foo";
let Test.256 : {} = CallByName Test.2; let Test.257 : {} = CallByName Test.3;
let Test.254 : List U8 = CallByName Encode.26 Test.258 Test.256; let Test.255 : List U8 = CallByName Encode.26 Test.259 Test.257;
let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255;
let Test.251 : U8 = 1i64; let Test.252 : U8 = 1i64;
let Test.252 : U8 = GetTagId Test.209; let Test.253 : U8 = GetTagId Test.210;
let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; let Test.254 : Int1 = lowlevel Eq Test.252 Test.253;
if Test.253 then if Test.254 then
let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.210; ret Test.211;
else else
dec Test.209; dec Test.210;
let Test.250 : Str = "<bad>"; let Test.251 : Str = "<bad>";
ret Test.250; ret Test.251;

View file

@ -6,203 +6,203 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1):
let #Derived_gen.11 : Str = "a"; let #Derived_gen.11 : Str = "a";
let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1; let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1;
inc #Derived_gen.13; inc #Derived_gen.13;
let #Derived_gen.12 : Str = CallByName Test.19 #Derived_gen.13; let #Derived_gen.12 : Str = CallByName Test.20 #Derived_gen.13;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.11, #Derived_gen.12}; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.11, #Derived_gen.12};
let #Derived_gen.8 : Str = "b"; let #Derived_gen.8 : Str = "b";
let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1; let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1;
dec #Derived_gen.13; dec #Derived_gen.13;
let #Derived_gen.9 : Str = CallByName Test.19 #Derived_gen.10; let #Derived_gen.9 : Str = CallByName Test.20 #Derived_gen.10;
let #Derived_gen.7 : {Str, Str} = Struct {#Derived_gen.8, #Derived_gen.9}; let #Derived_gen.7 : {Str, Str} = Struct {#Derived_gen.8, #Derived_gen.9};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6, #Derived_gen.7]; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6, #Derived_gen.7];
let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5;
let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4;
dec #Derived_gen.4; dec #Derived_gen.4;
ret #Derived_gen.3; ret #Derived_gen.3;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107; let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107;
ret Encode.113; ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.119 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109;
ret Encode.119; ret Encode.115;
procedure Encode.26 (Encode.105, Encode.106): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.109 : List U8 = Array []; let Encode.121 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
let Encode.110 : {Str, Str} = CallByName #Derived.0 Encode.105; ret Encode.121;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure List.18 (List.163, List.164, List.165): procedure Encode.26 (Encode.107, Encode.108):
let List.623 : U64 = 0i64; let Encode.111 : List U8 = Array [];
let List.624 : U64 = CallByName List.6 List.163; let Encode.112 : {Str, Str} = CallByName #Derived.0 Encode.107;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret List.622; ret Encode.110;
procedure List.4 (List.127, List.128): procedure List.18 (List.166, List.167, List.168):
let List.644 : U64 = 1i64; let List.626 : U64 = 0i64;
let List.643 : List U8 = CallByName List.70 List.127 List.644; let List.627 : U64 = CallByName List.6 List.166;
let List.642 : List U8 = CallByName List.71 List.643 List.128; let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.642; ret List.625;
procedure List.4 (List.130, List.131):
let List.647 : U64 = 1i64;
let List.646 : List U8 = CallByName List.70 List.130 List.647;
let List.645 : List U8 = CallByName List.71 List.646 List.131;
ret List.645;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2; let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647; ret List.650;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.70 (#Attr.2, #Attr.3): procedure List.70 (#Attr.2, #Attr.3):
let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.638; ret List.641;
procedure List.71 (#Attr.2, #Attr.3): procedure List.71 (#Attr.2, #Attr.3):
let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.636; ret List.639;
procedure List.8 (#Attr.2, #Attr.3): procedure List.8 (#Attr.2, #Attr.3):
let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.646; ret List.649;
procedure List.92 (#Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21): procedure List.95 (#Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : List U8 = CallByName Test.70 List.167 List.631; let List.174 : List U8 = CallByName Test.71 List.170 List.634;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.17; inc #Derived_gen.17;
jump List.625 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21; jump List.628 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21;
procedure Num.127 (#Attr.2): procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2; let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282; ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Num.96 (#Attr.2): procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2; let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.279; ret Num.281;
procedure Str.12 (#Attr.2): procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241; ret Str.245;
procedure Str.36 (#Attr.2): procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242; ret Str.246;
procedure Str.43 (#Attr.2): procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239; ret Str.243;
procedure Str.9 (Str.67): procedure Str.9 (Str.71):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.236 : Int1 = StructAtIndex 2 Str.68; let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.236 then if Str.240 then
let Str.238 : Str = StructAtIndex 1 Str.68; let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.237; ret Str.241;
else else
let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.235 : U64 = StructAtIndex 0 Str.68; let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.28 : Str = StructAtIndex 1 Str.68; let #Derived_gen.28 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.28; dec #Derived_gen.28;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.232; ret Str.236;
procedure Test.19 (Test.55): procedure Test.20 (Test.56):
let Test.295 : Str = CallByName Encode.23 Test.55; let Test.296 : Str = CallByName Encode.23 Test.56;
ret Test.295; ret Test.296;
procedure Test.2 (): procedure Test.22 (Test.67):
let Test.257 : {} = Struct {}; let Test.261 : List {Str, Str} = CallByName Encode.23 Test.67;
ret Test.257; ret Test.261;
procedure Test.21 (Test.66): procedure Test.3 ():
let Test.260 : List {Str, Str} = CallByName Encode.23 Test.66; let Test.258 : {} = Struct {};
ret Test.260; ret Test.258;
procedure Test.3 (Test.48, Test.49, Test.50): procedure Test.4 (Test.49, Test.50, Test.51):
let Test.289 : U8 = CallByName Num.127 Test.49; let Test.290 : U8 = CallByName Num.127 Test.50;
let Test.286 : List U8 = CallByName List.4 Test.48 Test.289; let Test.287 : List U8 = CallByName List.4 Test.49 Test.290;
let Test.288 : Str = CallByName Num.96 Test.50; let Test.289 : Str = CallByName Num.96 Test.51;
let Test.287 : List U8 = CallByName Str.12 Test.288; let Test.288 : List U8 = CallByName Str.12 Test.289;
let Test.284 : List U8 = CallByName List.8 Test.286 Test.287; let Test.285 : List U8 = CallByName List.8 Test.287 Test.288;
let Test.285 : U8 = 32i64; let Test.286 : U8 = 32i64;
let Test.283 : List U8 = CallByName List.4 Test.284 Test.285; let Test.284 : List U8 = CallByName List.4 Test.285 Test.286;
ret Test.283; ret Test.284;
procedure Test.56 (Test.57, Test.274, Test.55): procedure Test.57 (Test.58, Test.275, Test.56):
let Test.281 : I64 = 115i64; let Test.282 : I64 = 115i64;
let Test.282 : U64 = CallByName Str.36 Test.55; let Test.283 : U64 = CallByName Str.36 Test.56;
let Test.279 : List U8 = CallByName Test.3 Test.57 Test.281 Test.282; let Test.280 : List U8 = CallByName Test.4 Test.58 Test.282 Test.283;
let Test.280 : List U8 = CallByName Str.12 Test.55; let Test.281 : List U8 = CallByName Str.12 Test.56;
let Test.277 : List U8 = CallByName List.8 Test.279 Test.280; let Test.278 : List U8 = CallByName List.8 Test.280 Test.281;
let Test.278 : U8 = 32i64; let Test.279 : U8 = 32i64;
let Test.276 : List U8 = CallByName List.4 Test.277 Test.278; let Test.277 : List U8 = CallByName List.4 Test.278 Test.279;
ret Test.276; ret Test.277;
procedure Test.67 (Test.68, Test.262, Test.66): procedure Test.68 (Test.69, Test.263, Test.67):
let Test.290 : I64 = 114i64; let Test.291 : I64 = 114i64;
let Test.291 : U64 = CallByName List.6 Test.66; let Test.292 : U64 = CallByName List.6 Test.67;
let Test.69 : List U8 = CallByName Test.3 Test.68 Test.290 Test.291; let Test.70 : List U8 = CallByName Test.4 Test.69 Test.291 Test.292;
let Test.265 : {} = Struct {}; let Test.266 : {} = Struct {};
let Test.264 : List U8 = CallByName List.18 Test.66 Test.69 Test.265; let Test.265 : List U8 = CallByName List.18 Test.67 Test.70 Test.266;
ret Test.264; ret Test.265;
procedure Test.70 (Test.71, Test.266): procedure Test.71 (Test.72, Test.267):
let Test.72 : Str = StructAtIndex 0 Test.266; let Test.73 : Str = StructAtIndex 0 Test.267;
let Test.73 : Str = StructAtIndex 1 Test.266; let Test.74 : Str = StructAtIndex 1 Test.267;
let Test.270 : Str = CallByName Test.19 Test.72; let Test.271 : Str = CallByName Test.20 Test.73;
let Test.271 : {} = Struct {}; let Test.272 : {} = Struct {};
let Test.268 : List U8 = CallByName Encode.24 Test.71 Test.270 Test.271; let Test.269 : List U8 = CallByName Encode.24 Test.72 Test.271 Test.272;
let Test.269 : {} = Struct {}; let Test.270 : {} = Struct {};
let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.73 Test.269; let Test.268 : List U8 = CallByName Encode.24 Test.269 Test.74 Test.270;
ret Test.267; ret Test.268;
procedure Test.0 (): procedure Test.0 ():
let Test.258 : Str = "foo"; let Test.259 : Str = "foo";
let Test.259 : Str = "bar"; let Test.260 : Str = "bar";
let Test.255 : {Str, Str} = Struct {Test.258, Test.259}; let Test.256 : {Str, Str} = Struct {Test.259, Test.260};
let Test.256 : {} = CallByName Test.2; let Test.257 : {} = CallByName Test.3;
let Test.254 : List U8 = CallByName Encode.26 Test.255 Test.256; let Test.255 : List U8 = CallByName Encode.26 Test.256 Test.257;
let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255;
let Test.251 : U8 = 1i64; let Test.252 : U8 = 1i64;
let Test.252 : U8 = GetTagId Test.209; let Test.253 : U8 = GetTagId Test.210;
let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; let Test.254 : Int1 = lowlevel Eq Test.252 Test.253;
if Test.253 then if Test.254 then
let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.210; ret Test.211;
else else
dec Test.209; dec Test.210;
let Test.250 : Str = "<bad>"; let Test.251 : Str = "<bad>";
ret Test.250; ret Test.251;

View file

@ -1,110 +1,110 @@
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.111 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; let Encode.113 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
ret Encode.111; ret Encode.113;
procedure Encode.26 (Encode.105, Encode.106): procedure Encode.26 (Encode.107, Encode.108):
let Encode.109 : List U8 = Array []; let Encode.111 : List U8 = Array [];
let Encode.110 : Str = CallByName Test.19 Encode.105; let Encode.112 : Str = CallByName Test.20 Encode.107;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.108; ret Encode.110;
procedure List.4 (List.127, List.128): procedure List.4 (List.130, List.131):
let List.632 : U64 = 1i64; let List.635 : U64 = 1i64;
let List.631 : List U8 = CallByName List.70 List.127 List.632; let List.634 : List U8 = CallByName List.70 List.130 List.635;
let List.630 : List U8 = CallByName List.71 List.631 List.128; let List.633 : List U8 = CallByName List.71 List.634 List.131;
ret List.630; ret List.633;
procedure List.70 (#Attr.2, #Attr.3): procedure List.70 (#Attr.2, #Attr.3):
let List.626 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; let List.629 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.626; ret List.629;
procedure List.71 (#Attr.2, #Attr.3): procedure List.71 (#Attr.2, #Attr.3):
let List.624 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.627 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.624; ret List.627;
procedure List.8 (#Attr.2, #Attr.3): procedure List.8 (#Attr.2, #Attr.3):
let List.634 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; let List.637 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.634; ret List.637;
procedure Num.127 (#Attr.2): procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2; let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280; ret Num.282;
procedure Num.96 (#Attr.2): procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2; let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.279; ret Num.281;
procedure Str.12 (#Attr.2): procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241; ret Str.245;
procedure Str.36 (#Attr.2): procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242; ret Str.246;
procedure Str.43 (#Attr.2): procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239; ret Str.243;
procedure Str.9 (Str.67): procedure Str.9 (Str.71):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.236 : Int1 = StructAtIndex 2 Str.68; let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.236 then if Str.240 then
let Str.238 : Str = StructAtIndex 1 Str.68; let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.237; ret Str.241;
else else
let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.235 : U64 = StructAtIndex 0 Str.68; let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.3 : Str = StructAtIndex 1 Str.68; let #Derived_gen.3 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.3; dec #Derived_gen.3;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.232; ret Str.236;
procedure Test.19 (Test.55): procedure Test.20 (Test.56):
let Test.258 : Str = CallByName Encode.23 Test.55; let Test.259 : Str = CallByName Encode.23 Test.56;
ret Test.259;
procedure Test.3 ():
let Test.258 : {} = Struct {};
ret Test.258; ret Test.258;
procedure Test.2 (): procedure Test.4 (Test.49, Test.50, Test.51):
let Test.257 : {} = Struct {}; let Test.276 : U8 = CallByName Num.127 Test.50;
ret Test.257; let Test.273 : List U8 = CallByName List.4 Test.49 Test.276;
let Test.275 : Str = CallByName Num.96 Test.51;
let Test.274 : List U8 = CallByName Str.12 Test.275;
let Test.271 : List U8 = CallByName List.8 Test.273 Test.274;
let Test.272 : U8 = 32i64;
let Test.270 : List U8 = CallByName List.4 Test.271 Test.272;
ret Test.270;
procedure Test.3 (Test.48, Test.49, Test.50): procedure Test.57 (Test.58, Test.261, Test.56):
let Test.275 : U8 = CallByName Num.127 Test.49; let Test.268 : I64 = 115i64;
let Test.272 : List U8 = CallByName List.4 Test.48 Test.275; let Test.269 : U64 = CallByName Str.36 Test.56;
let Test.274 : Str = CallByName Num.96 Test.50; let Test.266 : List U8 = CallByName Test.4 Test.58 Test.268 Test.269;
let Test.273 : List U8 = CallByName Str.12 Test.274; let Test.267 : List U8 = CallByName Str.12 Test.56;
let Test.270 : List U8 = CallByName List.8 Test.272 Test.273; let Test.264 : List U8 = CallByName List.8 Test.266 Test.267;
let Test.271 : U8 = 32i64; let Test.265 : U8 = 32i64;
let Test.269 : List U8 = CallByName List.4 Test.270 Test.271; let Test.263 : List U8 = CallByName List.4 Test.264 Test.265;
ret Test.269; ret Test.263;
procedure Test.56 (Test.57, Test.260, Test.55):
let Test.267 : I64 = 115i64;
let Test.268 : U64 = CallByName Str.36 Test.55;
let Test.265 : List U8 = CallByName Test.3 Test.57 Test.267 Test.268;
let Test.266 : List U8 = CallByName Str.12 Test.55;
let Test.263 : List U8 = CallByName List.8 Test.265 Test.266;
let Test.264 : U8 = 32i64;
let Test.262 : List U8 = CallByName List.4 Test.263 Test.264;
ret Test.262;
procedure Test.0 (): procedure Test.0 ():
let Test.255 : Str = "abc"; let Test.256 : Str = "abc";
let Test.256 : {} = CallByName Test.2; let Test.257 : {} = CallByName Test.3;
let Test.254 : List U8 = CallByName Encode.26 Test.255 Test.256; let Test.255 : List U8 = CallByName Encode.26 Test.256 Test.257;
let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255;
let Test.251 : U8 = 1i64; let Test.252 : U8 = 1i64;
let Test.252 : U8 = GetTagId Test.209; let Test.253 : U8 = GetTagId Test.210;
let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; let Test.254 : Int1 = lowlevel Eq Test.252 Test.253;
if Test.253 then if Test.254 then
let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.210; ret Test.211;
else else
dec Test.209; dec Test.210;
let Test.250 : Str = "<bad>"; let Test.251 : Str = "<bad>";
ret Test.250; ret Test.251;

View file

@ -8,212 +8,212 @@ procedure #Derived.3 (#Derived.4, #Derived.5, #Derived.1):
ret #Derived_gen.3; ret #Derived_gen.3;
in in
let #Derived_gen.7 : Str = "A"; let #Derived_gen.7 : Str = "A";
let #Derived_gen.9 : Str = CallByName Test.19 #Derived.1; let #Derived_gen.9 : Str = CallByName Test.20 #Derived.1;
let #Derived_gen.8 : List Str = Array [#Derived_gen.9]; let #Derived_gen.8 : List Str = Array [#Derived_gen.9];
let #Derived_gen.6 : {List Str, {}} = CallByName Test.23 #Derived_gen.7 #Derived_gen.8; let #Derived_gen.6 : {List Str, {}} = CallByName Test.24 #Derived_gen.7 #Derived_gen.8;
jump #Derived_gen.5 #Derived_gen.6; jump #Derived_gen.5 #Derived_gen.6;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.111 : List U8 = CallByName #Derived.3 Encode.99 Encode.101 Encode.107; let Encode.113 : List U8 = CallByName #Derived.3 Encode.101 Encode.103 Encode.109;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.60 Encode.99 Encode.101 Encode.107;
ret Encode.113; ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.117 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; let Encode.115 : List U8 = CallByName Test.61 Encode.101 Encode.103 Encode.109;
ret Encode.117; ret Encode.115;
procedure Encode.26 (Encode.105, Encode.106): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.109 : List U8 = Array []; let Encode.119 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
let Encode.110 : Str = CallByName #Derived.0 Encode.105; ret Encode.119;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108; procedure Encode.26 (Encode.107, Encode.108):
let Encode.111 : List U8 = Array [];
let Encode.112 : Str = CallByName #Derived.0 Encode.107;
let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.110;
procedure List.13 (#Attr.2, #Attr.3): procedure List.13 (#Attr.2, #Attr.3):
let List.648 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; let List.651 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3;
ret List.648; ret List.651;
procedure List.18 (List.163, List.164, List.165): procedure List.18 (List.166, List.167, List.168):
let List.623 : U64 = 0i64; let List.626 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163; let List.627 : U64 = CallByName List.6 List.166;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.622; ret List.625;
procedure List.4 (List.127, List.128): procedure List.4 (List.130, List.131):
let List.644 : U64 = 1i64; let List.647 : U64 = 1i64;
let List.643 : List U8 = CallByName List.70 List.127 List.644; let List.646 : List U8 = CallByName List.70 List.130 List.647;
let List.642 : List U8 = CallByName List.71 List.643 List.128; let List.645 : List U8 = CallByName List.71 List.646 List.131;
ret List.642; ret List.645;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2; let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647; ret List.650;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.70 (#Attr.2, #Attr.3): procedure List.70 (#Attr.2, #Attr.3):
let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.638; ret List.641;
procedure List.71 (#Attr.2, #Attr.3): procedure List.71 (#Attr.2, #Attr.3):
let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.636; ret List.639;
procedure List.8 (#Attr.2, #Attr.3): procedure List.8 (#Attr.2, #Attr.3):
let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.646; ret List.649;
procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): procedure List.95 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : Str = CallByName List.66 List.166 List.169; let List.634 : Str = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : List U8 = CallByName Test.63 List.167 List.631 List.168; let List.174 : List U8 = CallByName Test.64 List.170 List.634 List.171;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.13; inc #Derived_gen.10;
jump List.625 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; jump List.628 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14;
procedure Num.127 (#Attr.2): procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2; let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282; ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Num.96 (#Attr.2): procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2; let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.279; ret Num.281;
procedure Str.12 (#Attr.2): procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241; ret Str.245;
procedure Str.36 (#Attr.2): procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242; ret Str.246;
procedure Str.43 (#Attr.2): procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239; ret Str.243;
procedure Str.9 (Str.67): procedure Str.9 (Str.71):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.236 : Int1 = StructAtIndex 2 Str.68; let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.236 then if Str.240 then
let Str.238 : Str = StructAtIndex 1 Str.68; let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.237; ret Str.241;
else else
let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.235 : U64 = StructAtIndex 0 Str.68; let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.27 : Str = StructAtIndex 1 Str.68; let #Derived_gen.27 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.27; dec #Derived_gen.27;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.232; ret Str.236;
procedure Test.19 (Test.55): procedure Test.20 (Test.56):
let Test.296 : Str = CallByName Encode.23 Test.55; let Test.297 : Str = CallByName Encode.23 Test.56;
ret Test.296; ret Test.297;
procedure Test.2 (): procedure Test.21 (Test.59, Test.60):
let Test.258 : {} = Struct {}; inc Test.59;
ret Test.258; let Test.266 : {List Str, {}} = Struct {Test.59, Test.60};
let Test.265 : {List Str, {}} = CallByName Encode.23 Test.266;
ret Test.265;
procedure Test.20 (Test.58, Test.59): procedure Test.23 (Test.75):
inc Test.58; let Test.264 : {} = Struct {};
let Test.265 : {List Str, {}} = Struct {Test.58, Test.59}; let Test.263 : {List Str, {}} = CallByName Test.21 Test.75 Test.264;
let Test.264 : {List Str, {}} = CallByName Encode.23 Test.265; ret Test.263;
ret Test.264;
procedure Test.22 (Test.74): procedure Test.24 (Test.78, Test.79):
let Test.263 : {} = Struct {}; let Test.285 : Str = CallByName Test.20 Test.78;
let Test.262 : {List Str, {}} = CallByName Test.20 Test.74 Test.263; let Test.262 : List Str = CallByName List.13 Test.79 Test.285;
ret Test.262; let Test.261 : {List Str, {}} = CallByName Test.23 Test.262;
dec Test.262;
ret Test.261;
procedure Test.23 (Test.77, Test.78): procedure Test.3 ():
let Test.284 : Str = CallByName Test.19 Test.77; let Test.259 : {} = Struct {};
let Test.261 : List Str = CallByName List.13 Test.78 Test.284; ret Test.259;
let Test.260 : {List Str, {}} = CallByName Test.22 Test.261;
dec Test.261;
ret Test.260;
procedure Test.3 (Test.48, Test.49, Test.50): procedure Test.4 (Test.49, Test.50, Test.51):
let Test.282 : U8 = CallByName Num.127 Test.49; let Test.283 : U8 = CallByName Num.127 Test.50;
let Test.279 : List U8 = CallByName List.4 Test.48 Test.282; let Test.280 : List U8 = CallByName List.4 Test.49 Test.283;
let Test.281 : Str = CallByName Num.96 Test.50; let Test.282 : Str = CallByName Num.96 Test.51;
let Test.280 : List U8 = CallByName Str.12 Test.281; let Test.281 : List U8 = CallByName Str.12 Test.282;
let Test.277 : List U8 = CallByName List.8 Test.279 Test.280; let Test.278 : List U8 = CallByName List.8 Test.280 Test.281;
let Test.278 : U8 = 32i64; let Test.279 : U8 = 32i64;
let Test.276 : List U8 = CallByName List.4 Test.277 Test.278; let Test.277 : List U8 = CallByName List.4 Test.278 Test.279;
ret Test.276; ret Test.277;
procedure Test.56 (Test.57, Test.287, Test.55): procedure Test.57 (Test.58, Test.288, Test.56):
let Test.294 : I64 = 115i64; let Test.295 : I64 = 115i64;
let Test.295 : U64 = CallByName Str.36 Test.55; let Test.296 : U64 = CallByName Str.36 Test.56;
let Test.292 : List U8 = CallByName Test.3 Test.57 Test.294 Test.295; let Test.293 : List U8 = CallByName Test.4 Test.58 Test.295 Test.296;
let Test.293 : List U8 = CallByName Str.12 Test.55; let Test.294 : List U8 = CallByName Str.12 Test.56;
let Test.290 : List U8 = CallByName List.8 Test.292 Test.293; let Test.291 : List U8 = CallByName List.8 Test.293 Test.294;
let Test.291 : U8 = 32i64; let Test.292 : U8 = 32i64;
let Test.289 : List U8 = CallByName List.4 Test.290 Test.291; let Test.290 : List U8 = CallByName List.4 Test.291 Test.292;
ret Test.289; ret Test.290;
procedure Test.60 (Test.61, Test.266, #Attr.12): procedure Test.61 (Test.62, Test.267, #Attr.12):
let Test.59 : {} = StructAtIndex 1 #Attr.12; let Test.60 : {} = StructAtIndex 1 #Attr.12;
let Test.58 : List Str = StructAtIndex 0 #Attr.12; let Test.59 : List Str = StructAtIndex 0 #Attr.12;
let Test.274 : I64 = 108i64; let Test.275 : I64 = 108i64;
let Test.275 : U64 = CallByName List.6 Test.58; let Test.276 : U64 = CallByName List.6 Test.59;
let Test.62 : List U8 = CallByName Test.3 Test.61 Test.274 Test.275; let Test.63 : List U8 = CallByName Test.4 Test.62 Test.275 Test.276;
let Test.268 : List U8 = CallByName List.18 Test.58 Test.62 Test.59; let Test.269 : List U8 = CallByName List.18 Test.59 Test.63 Test.60;
dec Test.58; dec Test.59;
ret Test.268; ret Test.269;
procedure Test.63 (Test.64, Test.65, Test.59): procedure Test.64 (Test.65, Test.66, Test.60):
let Test.272 : Str = CallByName Test.75 Test.65; let Test.273 : Str = CallByName Test.76 Test.66;
let Test.273 : {} = Struct {}; let Test.274 : {} = Struct {};
let Test.271 : List U8 = CallByName Encode.24 Test.64 Test.272 Test.273; let Test.272 : List U8 = CallByName Encode.24 Test.65 Test.273 Test.274;
ret Test.271; ret Test.272;
procedure Test.75 (Test.76): procedure Test.76 (Test.77):
ret Test.76; ret Test.77;
procedure Test.0 (): procedure Test.0 ():
let Test.259 : Str = "foo"; let Test.260 : Str = "foo";
let Test.257 : {} = CallByName Test.2; let Test.258 : {} = CallByName Test.3;
let Test.256 : List U8 = CallByName Encode.26 Test.259 Test.257; let Test.257 : List U8 = CallByName Encode.26 Test.260 Test.258;
let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.256; let Test.211 : [C {U64, U8}, C Str] = CallByName Str.9 Test.257;
let Test.253 : U8 = 1i64; let Test.254 : U8 = 1i64;
let Test.254 : U8 = GetTagId Test.210; let Test.255 : U8 = GetTagId Test.211;
let Test.255 : Int1 = lowlevel Eq Test.253 Test.254; let Test.256 : Int1 = lowlevel Eq Test.254 Test.255;
if Test.255 then if Test.256 then
let Test.212 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; let Test.213 : Str = UnionAtIndex (Id 1) (Index 0) Test.211;
ret Test.212; ret Test.213;
else else
dec Test.210; dec Test.211;
let Test.252 : Str = "<bad>"; let Test.253 : Str = "<bad>";
ret Test.252; ret Test.253;

View file

@ -10,215 +10,215 @@ procedure #Derived.4 (#Derived.5, #Derived.6, #Derived.1):
let #Derived.2 : Str = StructAtIndex 0 #Derived.1; let #Derived.2 : Str = StructAtIndex 0 #Derived.1;
let #Derived.3 : Str = StructAtIndex 1 #Derived.1; let #Derived.3 : Str = StructAtIndex 1 #Derived.1;
let #Derived_gen.7 : Str = "A"; let #Derived_gen.7 : Str = "A";
let #Derived_gen.9 : Str = CallByName Test.19 #Derived.2; let #Derived_gen.9 : Str = CallByName Test.20 #Derived.2;
let #Derived_gen.10 : Str = CallByName Test.19 #Derived.3; let #Derived_gen.10 : Str = CallByName Test.20 #Derived.3;
let #Derived_gen.8 : List Str = Array [#Derived_gen.9, #Derived_gen.10]; let #Derived_gen.8 : List Str = Array [#Derived_gen.9, #Derived_gen.10];
let #Derived_gen.6 : {List Str, {}} = CallByName Test.23 #Derived_gen.7 #Derived_gen.8; let #Derived_gen.6 : {List Str, {}} = CallByName Test.24 #Derived_gen.7 #Derived_gen.8;
jump #Derived_gen.5 #Derived_gen.6; jump #Derived_gen.5 #Derived_gen.6;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.100):
ret Encode.98; ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.111 : List U8 = CallByName #Derived.4 Encode.99 Encode.101 Encode.107; let Encode.113 : List U8 = CallByName #Derived.4 Encode.101 Encode.103 Encode.109;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.60 Encode.99 Encode.101 Encode.107;
ret Encode.113; ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.118 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; let Encode.115 : List U8 = CallByName Test.61 Encode.101 Encode.103 Encode.109;
ret Encode.118; ret Encode.115;
procedure Encode.26 (Encode.105, Encode.106): procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.109 : List U8 = Array []; let Encode.120 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
let Encode.110 : {Str, Str} = CallByName #Derived.0 Encode.105; ret Encode.120;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108; procedure Encode.26 (Encode.107, Encode.108):
let Encode.111 : List U8 = Array [];
let Encode.112 : {Str, Str} = CallByName #Derived.0 Encode.107;
let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.110;
procedure List.13 (#Attr.2, #Attr.3): procedure List.13 (#Attr.2, #Attr.3):
let List.648 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; let List.651 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3;
ret List.648; ret List.651;
procedure List.18 (List.163, List.164, List.165): procedure List.18 (List.166, List.167, List.168):
let List.623 : U64 = 0i64; let List.626 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163; let List.627 : U64 = CallByName List.6 List.166;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.622; ret List.625;
procedure List.4 (List.127, List.128): procedure List.4 (List.130, List.131):
let List.644 : U64 = 1i64; let List.647 : U64 = 1i64;
let List.643 : List U8 = CallByName List.70 List.127 List.644; let List.646 : List U8 = CallByName List.70 List.130 List.647;
let List.642 : List U8 = CallByName List.71 List.643 List.128; let List.645 : List U8 = CallByName List.71 List.646 List.131;
ret List.642; ret List.645;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2; let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647; ret List.650;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.70 (#Attr.2, #Attr.3): procedure List.70 (#Attr.2, #Attr.3):
let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.638; ret List.641;
procedure List.71 (#Attr.2, #Attr.3): procedure List.71 (#Attr.2, #Attr.3):
let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.636; ret List.639;
procedure List.8 (#Attr.2, #Attr.3): procedure List.8 (#Attr.2, #Attr.3):
let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.646; ret List.649;
procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): procedure List.95 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : Str = CallByName List.66 List.166 List.169; let List.634 : Str = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : List U8 = CallByName Test.63 List.167 List.631 List.168; let List.174 : List U8 = CallByName Test.64 List.170 List.634 List.171;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.14; inc #Derived_gen.11;
jump List.625 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; jump List.628 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15;
procedure Num.127 (#Attr.2): procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2; let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282; ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Num.96 (#Attr.2): procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2; let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.279; ret Num.281;
procedure Str.12 (#Attr.2): procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241; ret Str.245;
procedure Str.36 (#Attr.2): procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242; ret Str.246;
procedure Str.43 (#Attr.2): procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239; ret Str.243;
procedure Str.9 (Str.67): procedure Str.9 (Str.71):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.236 : Int1 = StructAtIndex 2 Str.68; let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.236 then if Str.240 then
let Str.238 : Str = StructAtIndex 1 Str.68; let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.237; ret Str.241;
else else
let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.235 : U64 = StructAtIndex 0 Str.68; let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.28 : Str = StructAtIndex 1 Str.68; let #Derived_gen.28 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.28; dec #Derived_gen.28;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.232; ret Str.236;
procedure Test.19 (Test.55): procedure Test.20 (Test.56):
let Test.300 : Str = CallByName Encode.23 Test.55; let Test.301 : Str = CallByName Encode.23 Test.56;
ret Test.300; ret Test.301;
procedure Test.2 (): procedure Test.21 (Test.59, Test.60):
let Test.258 : {} = Struct {}; inc Test.59;
ret Test.258; let Test.267 : {List Str, {}} = Struct {Test.59, Test.60};
let Test.266 : {List Str, {}} = CallByName Encode.23 Test.267;
ret Test.266;
procedure Test.20 (Test.58, Test.59): procedure Test.23 (Test.75):
inc Test.58; let Test.265 : {} = Struct {};
let Test.266 : {List Str, {}} = Struct {Test.58, Test.59}; let Test.264 : {List Str, {}} = CallByName Test.21 Test.75 Test.265;
let Test.265 : {List Str, {}} = CallByName Encode.23 Test.266; ret Test.264;
ret Test.265;
procedure Test.22 (Test.74): procedure Test.24 (Test.78, Test.79):
let Test.264 : {} = Struct {}; let Test.286 : Str = CallByName Test.20 Test.78;
let Test.263 : {List Str, {}} = CallByName Test.20 Test.74 Test.264; let Test.263 : List Str = CallByName List.13 Test.79 Test.286;
ret Test.263; let Test.262 : {List Str, {}} = CallByName Test.23 Test.263;
dec Test.263;
ret Test.262;
procedure Test.23 (Test.77, Test.78): procedure Test.3 ():
let Test.285 : Str = CallByName Test.19 Test.77; let Test.259 : {} = Struct {};
let Test.262 : List Str = CallByName List.13 Test.78 Test.285; ret Test.259;
let Test.261 : {List Str, {}} = CallByName Test.22 Test.262;
dec Test.262;
ret Test.261;
procedure Test.3 (Test.48, Test.49, Test.50): procedure Test.4 (Test.49, Test.50, Test.51):
let Test.283 : U8 = CallByName Num.127 Test.49; let Test.284 : U8 = CallByName Num.127 Test.50;
let Test.280 : List U8 = CallByName List.4 Test.48 Test.283; let Test.281 : List U8 = CallByName List.4 Test.49 Test.284;
let Test.282 : Str = CallByName Num.96 Test.50; let Test.283 : Str = CallByName Num.96 Test.51;
let Test.281 : List U8 = CallByName Str.12 Test.282; let Test.282 : List U8 = CallByName Str.12 Test.283;
let Test.278 : List U8 = CallByName List.8 Test.280 Test.281; let Test.279 : List U8 = CallByName List.8 Test.281 Test.282;
let Test.279 : U8 = 32i64; let Test.280 : U8 = 32i64;
let Test.277 : List U8 = CallByName List.4 Test.278 Test.279; let Test.278 : List U8 = CallByName List.4 Test.279 Test.280;
ret Test.277; ret Test.278;
procedure Test.56 (Test.57, Test.288, Test.55): procedure Test.57 (Test.58, Test.289, Test.56):
let Test.295 : I64 = 115i64; let Test.296 : I64 = 115i64;
let Test.296 : U64 = CallByName Str.36 Test.55; let Test.297 : U64 = CallByName Str.36 Test.56;
let Test.293 : List U8 = CallByName Test.3 Test.57 Test.295 Test.296; let Test.294 : List U8 = CallByName Test.4 Test.58 Test.296 Test.297;
let Test.294 : List U8 = CallByName Str.12 Test.55; let Test.295 : List U8 = CallByName Str.12 Test.56;
let Test.291 : List U8 = CallByName List.8 Test.293 Test.294; let Test.292 : List U8 = CallByName List.8 Test.294 Test.295;
let Test.292 : U8 = 32i64; let Test.293 : U8 = 32i64;
let Test.290 : List U8 = CallByName List.4 Test.291 Test.292; let Test.291 : List U8 = CallByName List.4 Test.292 Test.293;
ret Test.290; ret Test.291;
procedure Test.60 (Test.61, Test.267, #Attr.12): procedure Test.61 (Test.62, Test.268, #Attr.12):
let Test.59 : {} = StructAtIndex 1 #Attr.12; let Test.60 : {} = StructAtIndex 1 #Attr.12;
let Test.58 : List Str = StructAtIndex 0 #Attr.12; let Test.59 : List Str = StructAtIndex 0 #Attr.12;
let Test.275 : I64 = 108i64; let Test.276 : I64 = 108i64;
let Test.276 : U64 = CallByName List.6 Test.58; let Test.277 : U64 = CallByName List.6 Test.59;
let Test.62 : List U8 = CallByName Test.3 Test.61 Test.275 Test.276; let Test.63 : List U8 = CallByName Test.4 Test.62 Test.276 Test.277;
let Test.269 : List U8 = CallByName List.18 Test.58 Test.62 Test.59; let Test.270 : List U8 = CallByName List.18 Test.59 Test.63 Test.60;
dec Test.58; dec Test.59;
ret Test.269; ret Test.270;
procedure Test.63 (Test.64, Test.65, Test.59): procedure Test.64 (Test.65, Test.66, Test.60):
let Test.273 : Str = CallByName Test.75 Test.65; let Test.274 : Str = CallByName Test.76 Test.66;
let Test.274 : {} = Struct {}; let Test.275 : {} = Struct {};
let Test.272 : List U8 = CallByName Encode.24 Test.64 Test.273 Test.274; let Test.273 : List U8 = CallByName Encode.24 Test.65 Test.274 Test.275;
ret Test.272; ret Test.273;
procedure Test.75 (Test.76): procedure Test.76 (Test.77):
ret Test.76; ret Test.77;
procedure Test.0 (): procedure Test.0 ():
let Test.261 : Str = "foo";
let Test.260 : Str = "foo"; let Test.260 : Str = "foo";
let Test.259 : Str = "foo"; let Test.210 : {Str, Str} = Struct {Test.260, Test.261};
let Test.209 : {Str, Str} = Struct {Test.259, Test.260}; let Test.258 : {} = CallByName Test.3;
let Test.257 : {} = CallByName Test.2; let Test.257 : List U8 = CallByName Encode.26 Test.210 Test.258;
let Test.256 : List U8 = CallByName Encode.26 Test.209 Test.257; let Test.211 : [C {U64, U8}, C Str] = CallByName Str.9 Test.257;
let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.256; let Test.254 : U8 = 1i64;
let Test.253 : U8 = 1i64; let Test.255 : U8 = GetTagId Test.211;
let Test.254 : U8 = GetTagId Test.210; let Test.256 : Int1 = lowlevel Eq Test.254 Test.255;
let Test.255 : Int1 = lowlevel Eq Test.253 Test.254; if Test.256 then
if Test.255 then let Test.213 : Str = UnionAtIndex (Id 1) (Index 0) Test.211;
let Test.212 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; ret Test.213;
ret Test.212;
else else
dec Test.210; dec Test.211;
let Test.252 : Str = "<bad>"; let Test.253 : Str = "<bad>";
ret Test.252; ret Test.253;

View file

@ -1,10 +1,10 @@
procedure Num.20 (#Attr.2, #Attr.3): procedure Num.20 (#Attr.2, #Attr.3):
let Num.280 : I64 = lowlevel NumSub #Attr.2 #Attr.3; let Num.282 : I64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.21 (#Attr.2, #Attr.3): procedure Num.21 (#Attr.2, #Attr.3):
let Num.279 : I64 = lowlevel NumMul #Attr.2 #Attr.3; let Num.281 : I64 = lowlevel NumMul #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.1 (#Derived_gen.0, #Derived_gen.1): procedure Test.1 (#Derived_gen.0, #Derived_gen.1):
joinpoint Test.7 Test.2 Test.3: joinpoint Test.7 Test.2 Test.3:

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.1 (Test.8): procedure Test.1 (Test.8):
let Test.3 : I64 = 10i64; let Test.3 : I64 = 10i64;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.280 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.282 : U8 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Test.1 (Test.9): procedure Test.1 (Test.9):
let Test.4 : U8 = 10i64; let Test.4 : U8 = 10i64;

View file

@ -3,8 +3,8 @@ procedure Bool.1 ():
ret Bool.23; ret Bool.23;
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Test.3 (Test.4): procedure Test.3 (Test.4):
ret Test.4; ret Test.4;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.283 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Test.2 (Test.3): procedure Test.2 (Test.3):
switch Test.3: switch Test.3:

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3): procedure Num.19 (#Attr.2, #Attr.3):
let Num.280 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; let Num.282 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Test.2 (Test.3, Test.1): procedure Test.2 (Test.3, Test.1):
let Test.18 : Int1 = false; let Test.18 : Int1 = false;

File diff suppressed because it is too large Load diff

View file

@ -3,13 +3,13 @@ procedure #Derived.0 (#Derived.1):
ret #Derived_gen.0; ret #Derived_gen.0;
procedure #Derived.3 (#Derived.2): procedure #Derived.3 (#Derived.2):
let #Derived_gen.7 : I64 = CallByName Inspect.53 #Derived.2; let #Derived_gen.7 : I64 = CallByName Inspect.57 #Derived.2;
ret #Derived_gen.7; ret #Derived_gen.7;
procedure #Derived.4 (#Derived.5, #Derived.1): procedure #Derived.4 (#Derived.5, #Derived.1):
let #Derived_gen.5 : {} = Struct {}; let #Derived_gen.5 : {} = Struct {};
let #Derived_gen.6 : {} = Struct {}; let #Derived_gen.6 : {} = Struct {};
let #Derived_gen.4 : {List I64, {}, {}} = CallByName Inspect.36 #Derived.1 #Derived_gen.5 #Derived_gen.6; let #Derived_gen.4 : {List I64, {}, {}} = CallByName Inspect.40 #Derived.1 #Derived_gen.5 #Derived_gen.6;
let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.5; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.5;
ret #Derived_gen.3; ret #Derived_gen.3;
@ -21,165 +21,165 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true; let Bool.23 : Int1 = true;
ret Bool.23; ret Bool.23;
procedure Inspect.152 (Inspect.153, #Attr.12): procedure Inspect.156 (Inspect.157, #Attr.12):
let Inspect.151 : {} = StructAtIndex 2 #Attr.12; let Inspect.155 : {} = StructAtIndex 2 #Attr.12;
let Inspect.150 : {} = StructAtIndex 1 #Attr.12; let Inspect.154 : {} = StructAtIndex 1 #Attr.12;
let Inspect.149 : List I64 = StructAtIndex 0 #Attr.12; let Inspect.153 : List I64 = StructAtIndex 0 #Attr.12;
let Inspect.343 : Str = "["; let Inspect.347 : Str = "[";
let Inspect.324 : Str = CallByName Inspect.59 Inspect.153 Inspect.343; let Inspect.328 : Str = CallByName Inspect.63 Inspect.157 Inspect.347;
dec Inspect.343; dec Inspect.347;
let Inspect.325 : {List I64, {}, {}} = Struct {Inspect.149, Inspect.150, Inspect.151}; let Inspect.329 : {List I64, {}, {}} = Struct {Inspect.153, Inspect.154, Inspect.155};
let Inspect.320 : {Str, Int1} = CallByName Inspect.154 Inspect.324 Inspect.325; let Inspect.324 : {Str, Int1} = CallByName Inspect.158 Inspect.328 Inspect.329;
dec Inspect.324; dec Inspect.328;
let Inspect.321 : {} = Struct {}; let Inspect.325 : {} = Struct {};
let Inspect.316 : Str = CallByName Inspect.163 Inspect.320; let Inspect.320 : Str = CallByName Inspect.167 Inspect.324;
let Inspect.317 : Str = "]"; let Inspect.321 : Str = "]";
let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321;
dec Inspect.317; dec Inspect.321;
ret Inspect.315;
procedure Inspect.154 (Inspect.155, #Attr.12):
let Inspect.151 : {} = StructAtIndex 2 #Attr.12;
let Inspect.150 : {} = StructAtIndex 1 #Attr.12;
let Inspect.149 : List I64 = StructAtIndex 0 #Attr.12;
let Inspect.342 : Int1 = CallByName Bool.1;
inc Inspect.155;
let Inspect.328 : {Str, Int1} = Struct {Inspect.155, Inspect.342};
let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.149 Inspect.328 Inspect.151;
dec Inspect.149;
ret Inspect.327;
procedure Inspect.156 (Inspect.330, Inspect.159, Inspect.151):
let Inspect.157 : Str = StructAtIndex 0 Inspect.330;
let Inspect.158 : Int1 = StructAtIndex 1 Inspect.330;
joinpoint Inspect.340 Inspect.160:
let Inspect.337 : I64 = CallByName #Derived.3 Inspect.159;
let Inspect.333 : Str = CallByName Inspect.31 Inspect.337 Inspect.160;
let Inspect.334 : {} = Struct {};
let Inspect.332 : {Str, Int1} = CallByName Inspect.161 Inspect.333;
dec Inspect.333;
ret Inspect.332;
in
if Inspect.158 then
let Inspect.341 : Str = ", ";
let Inspect.339 : Str = CallByName Inspect.59 Inspect.157 Inspect.341;
dec Inspect.341;
jump Inspect.340 Inspect.339;
else
jump Inspect.340 Inspect.157;
procedure Inspect.161 (Inspect.162):
let Inspect.336 : Int1 = CallByName Bool.2;
inc Inspect.162;
let Inspect.335 : {Str, Int1} = Struct {Inspect.162, Inspect.336};
ret Inspect.335;
procedure Inspect.163 (Inspect.322):
let Inspect.323 : Str = StructAtIndex 0 Inspect.322;
ret Inspect.323;
procedure Inspect.274 (Inspect.275, Inspect.273):
let Inspect.349 : Str = CallByName Num.96 Inspect.273;
let Inspect.348 : Str = CallByName Inspect.59 Inspect.275 Inspect.349;
dec Inspect.349;
ret Inspect.348;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.310 : Str = CallByName Inspect.152 Inspect.145 Inspect.299;
ret Inspect.310;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.338 : Str = CallByName Inspect.274 Inspect.145 Inspect.299;
ret Inspect.338;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.36 (Inspect.149, Inspect.150, Inspect.151):
inc Inspect.149;
let Inspect.312 : {List I64, {}, {}} = Struct {Inspect.149, Inspect.150, Inspect.151};
let Inspect.311 : {List I64, {}, {}} = CallByName Inspect.30 Inspect.312;
ret Inspect.311;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : List I64 = CallByName #Derived.0 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName #Derived.4 Inspect.304 Inspect.308;
dec Inspect.308;
ret Inspect.303;
procedure Inspect.53 (Inspect.273):
let Inspect.344 : I64 = CallByName Inspect.30 Inspect.273;
ret Inspect.344;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.319; ret Inspect.319;
procedure Inspect.60 (Inspect.298): procedure Inspect.158 (Inspect.159, #Attr.12):
ret Inspect.298; let Inspect.155 : {} = StructAtIndex 2 #Attr.12;
let Inspect.154 : {} = StructAtIndex 1 #Attr.12;
let Inspect.153 : List I64 = StructAtIndex 0 #Attr.12;
let Inspect.346 : Int1 = CallByName Bool.1;
inc Inspect.159;
let Inspect.332 : {Str, Int1} = Struct {Inspect.159, Inspect.346};
let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.153 Inspect.332 Inspect.155;
dec Inspect.153;
ret Inspect.331;
procedure List.18 (List.163, List.164, List.165): procedure Inspect.160 (Inspect.334, Inspect.163, Inspect.155):
let List.623 : U64 = 0i64; let Inspect.161 : Str = StructAtIndex 0 Inspect.334;
let List.624 : U64 = CallByName List.6 List.163; let Inspect.162 : Int1 = StructAtIndex 1 Inspect.334;
let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; joinpoint Inspect.344 Inspect.164:
ret List.622; let Inspect.341 : I64 = CallByName #Derived.3 Inspect.163;
let Inspect.337 : Str = CallByName Inspect.31 Inspect.341 Inspect.164;
let Inspect.338 : {} = Struct {};
let Inspect.336 : {Str, Int1} = CallByName Inspect.165 Inspect.337;
dec Inspect.337;
ret Inspect.336;
in
if Inspect.162 then
let Inspect.345 : Str = ", ";
let Inspect.343 : Str = CallByName Inspect.63 Inspect.161 Inspect.345;
dec Inspect.345;
jump Inspect.344 Inspect.343;
else
jump Inspect.344 Inspect.161;
procedure Inspect.165 (Inspect.166):
let Inspect.340 : Int1 = CallByName Bool.2;
inc Inspect.166;
let Inspect.339 : {Str, Int1} = Struct {Inspect.166, Inspect.340};
ret Inspect.339;
procedure Inspect.167 (Inspect.326):
let Inspect.327 : Str = StructAtIndex 0 Inspect.326;
ret Inspect.327;
procedure Inspect.278 (Inspect.279, Inspect.277):
let Inspect.353 : Str = CallByName Num.96 Inspect.277;
let Inspect.352 : Str = CallByName Inspect.63 Inspect.279 Inspect.353;
dec Inspect.353;
ret Inspect.352;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.314 : Str = CallByName Inspect.156 Inspect.149 Inspect.303;
ret Inspect.314;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.342 : Str = CallByName Inspect.278 Inspect.149 Inspect.303;
ret Inspect.342;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.40 (Inspect.153, Inspect.154, Inspect.155):
inc Inspect.153;
let Inspect.316 : {List I64, {}, {}} = Struct {Inspect.153, Inspect.154, Inspect.155};
let Inspect.315 : {List I64, {}, {}} = CallByName Inspect.30 Inspect.316;
ret Inspect.315;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : List I64 = CallByName #Derived.0 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName #Derived.4 Inspect.308 Inspect.312;
dec Inspect.312;
ret Inspect.307;
procedure Inspect.57 (Inspect.277):
let Inspect.348 : I64 = CallByName Inspect.30 Inspect.277;
ret Inspect.348;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.323;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2; let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633; ret List.636;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.92 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): procedure List.95 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : I64 = CallByName List.66 List.166 List.169; let List.634 : I64 = CallByName List.66 List.169 List.172;
let List.171 : {Str, Int1} = CallByName Inspect.156 List.167 List.631 List.168; let List.174 : {Str, Int1} = CallByName Inspect.160 List.170 List.634 List.171;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.19; inc #Derived_gen.19;
jump List.625 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; jump List.628 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.280 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.282 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.96 (#Attr.2): procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2; let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.279; ret Num.281;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232; ret Str.236;
procedure Test.0 (): procedure Test.0 ():
let Test.2 : List I64 = Array [1i64, 2i64, 3i64]; let Test.2 : List I64 = Array [1i64, 2i64, 3i64];

View file

@ -7,7 +7,7 @@ procedure #Derived.2 (#Derived.3, #Derived.1):
let #Derived_gen.8 : Str = CallByName #Derived.4 #Derived.1; let #Derived_gen.8 : Str = CallByName #Derived.4 #Derived.1;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6];
let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.41 #Derived_gen.5; let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.45 #Derived_gen.5;
let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3;
dec #Derived_gen.4; dec #Derived_gen.4;
ret #Derived_gen.3; ret #Derived_gen.3;
@ -18,10 +18,10 @@ procedure #Derived.4 (#Derived.5):
procedure #Derived.6 (#Derived.7, #Derived.5): procedure #Derived.6 (#Derived.7, #Derived.5):
let #Derived_gen.17 : Str = "b"; let #Derived_gen.17 : Str = "b";
let #Derived_gen.18 : Str = CallByName Inspect.43 #Derived.5; let #Derived_gen.18 : Str = CallByName Inspect.47 #Derived.5;
let #Derived_gen.16 : {Str, Str} = Struct {#Derived_gen.17, #Derived_gen.18}; let #Derived_gen.16 : {Str, Str} = Struct {#Derived_gen.17, #Derived_gen.18};
let #Derived_gen.15 : List {Str, Str} = Array [#Derived_gen.16]; let #Derived_gen.15 : List {Str, Str} = Array [#Derived_gen.16];
let #Derived_gen.14 : List {Str, Str} = CallByName Inspect.41 #Derived_gen.15; let #Derived_gen.14 : List {Str, Str} = CallByName Inspect.45 #Derived_gen.15;
let #Derived_gen.13 : Str = CallByName Inspect.31 #Derived_gen.14 #Derived.7; let #Derived_gen.13 : Str = CallByName Inspect.31 #Derived_gen.14 #Derived.7;
dec #Derived_gen.14; dec #Derived_gen.14;
ret #Derived_gen.13; ret #Derived_gen.13;
@ -34,266 +34,266 @@ procedure Bool.2 ():
let Bool.25 : Int1 = true; let Bool.25 : Int1 = true;
ret Bool.25; ret Bool.25;
procedure Inspect.225 (Inspect.226, Inspect.224): procedure Inspect.229 (Inspect.230, Inspect.228):
let Inspect.348 : Str = "{"; let Inspect.352 : Str = "{";
let Inspect.324 : Str = CallByName Inspect.59 Inspect.226 Inspect.348; let Inspect.328 : Str = CallByName Inspect.63 Inspect.230 Inspect.352;
dec Inspect.348; dec Inspect.352;
let Inspect.320 : {Str, Int1} = CallByName Inspect.227 Inspect.324 Inspect.224; let Inspect.324 : {Str, Int1} = CallByName Inspect.231 Inspect.328 Inspect.228;
dec Inspect.324; dec Inspect.328;
let Inspect.321 : {} = Struct {}; let Inspect.325 : {} = Struct {};
let Inspect.316 : Str = CallByName Inspect.239 Inspect.320; let Inspect.320 : Str = CallByName Inspect.243 Inspect.324;
let Inspect.317 : Str = "}"; let Inspect.321 : Str = "}";
let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321;
dec Inspect.317; dec Inspect.321;
ret Inspect.315; ret Inspect.319;
procedure Inspect.225 (Inspect.226, Inspect.224): procedure Inspect.229 (Inspect.230, Inspect.228):
let Inspect.388 : Str = "{"; let Inspect.392 : Str = "{";
let Inspect.364 : Str = CallByName Inspect.59 Inspect.226 Inspect.388; let Inspect.368 : Str = CallByName Inspect.63 Inspect.230 Inspect.392;
dec Inspect.388; dec Inspect.392;
let Inspect.360 : {Str, Int1} = CallByName Inspect.227 Inspect.364 Inspect.224; let Inspect.364 : {Str, Int1} = CallByName Inspect.231 Inspect.368 Inspect.228;
dec Inspect.364; dec Inspect.368;
let Inspect.361 : {} = Struct {}; let Inspect.365 : {} = Struct {};
let Inspect.356 : Str = CallByName Inspect.239 Inspect.360; let Inspect.360 : Str = CallByName Inspect.243 Inspect.364;
let Inspect.357 : Str = "}"; let Inspect.361 : Str = "}";
let Inspect.355 : Str = CallByName Inspect.59 Inspect.356 Inspect.357; let Inspect.359 : Str = CallByName Inspect.63 Inspect.360 Inspect.361;
dec Inspect.357; dec Inspect.361;
ret Inspect.355;
procedure Inspect.227 (Inspect.228, Inspect.224):
let Inspect.347 : Int1 = CallByName Bool.1;
inc Inspect.228;
let Inspect.328 : {Str, Int1} = Struct {Inspect.228, Inspect.347};
let Inspect.329 : {} = Struct {};
let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.328 Inspect.329;
ret Inspect.327;
procedure Inspect.227 (Inspect.228, Inspect.224):
let Inspect.387 : Int1 = CallByName Bool.1;
inc Inspect.228;
let Inspect.368 : {Str, Int1} = Struct {Inspect.228, Inspect.387};
let Inspect.369 : {} = Struct {};
let Inspect.367 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.368 Inspect.369;
ret Inspect.367;
procedure Inspect.229 (Inspect.330, Inspect.331):
let Inspect.232 : Str = StructAtIndex 0 Inspect.331;
let Inspect.233 : Str = StructAtIndex 1 Inspect.331;
let Inspect.230 : Str = StructAtIndex 0 Inspect.330;
let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330;
joinpoint Inspect.345 Inspect.234:
let Inspect.342 : Str = CallByName Inspect.59 Inspect.234 Inspect.232;
dec Inspect.232;
let Inspect.343 : Str = ": ";
let Inspect.337 : Str = CallByName Inspect.59 Inspect.342 Inspect.343;
dec Inspect.343;
let Inspect.333 : Str = CallByName Inspect.235 Inspect.337 Inspect.233;
let Inspect.334 : {} = Struct {};
let Inspect.332 : {Str, Int1} = CallByName Inspect.237 Inspect.333;
dec Inspect.333;
ret Inspect.332;
in
if Inspect.231 then
let Inspect.346 : Str = ", ";
let Inspect.344 : Str = CallByName Inspect.59 Inspect.230 Inspect.346;
dec Inspect.346;
jump Inspect.345 Inspect.344;
else
jump Inspect.345 Inspect.230;
procedure Inspect.229 (Inspect.330, Inspect.331):
let Inspect.232 : Str = StructAtIndex 0 Inspect.331;
let Inspect.233 : Str = StructAtIndex 1 Inspect.331;
let Inspect.230 : Str = StructAtIndex 0 Inspect.330;
let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330;
joinpoint Inspect.385 Inspect.234:
let Inspect.382 : Str = CallByName Inspect.59 Inspect.234 Inspect.232;
dec Inspect.232;
let Inspect.383 : Str = ": ";
let Inspect.377 : Str = CallByName Inspect.59 Inspect.382 Inspect.383;
dec Inspect.383;
let Inspect.373 : Str = CallByName Inspect.235 Inspect.377 Inspect.233;
dec Inspect.233;
let Inspect.374 : {} = Struct {};
let Inspect.372 : {Str, Int1} = CallByName Inspect.237 Inspect.373;
dec Inspect.373;
ret Inspect.372;
in
if Inspect.231 then
let Inspect.386 : Str = ", ";
let Inspect.384 : Str = CallByName Inspect.59 Inspect.230 Inspect.386;
dec Inspect.386;
jump Inspect.385 Inspect.384;
else
jump Inspect.385 Inspect.230;
procedure Inspect.235 (Inspect.236, Inspect.233):
let Inspect.340 : Str = CallByName Inspect.31 Inspect.233 Inspect.236;
ret Inspect.340;
procedure Inspect.235 (Inspect.236, Inspect.233):
let Inspect.380 : Str = CallByName Inspect.31 Inspect.233 Inspect.236;
ret Inspect.380;
procedure Inspect.237 (Inspect.238):
let Inspect.376 : Int1 = CallByName Bool.2;
inc Inspect.238;
let Inspect.375 : {Str, Int1} = Struct {Inspect.238, Inspect.376};
ret Inspect.375;
procedure Inspect.239 (Inspect.322):
let Inspect.363 : Str = StructAtIndex 0 Inspect.322;
ret Inspect.363;
procedure Inspect.246 (Inspect.247, Inspect.245):
let Inspect.397 : Str = "\"";
let Inspect.396 : Str = CallByName Inspect.59 Inspect.247 Inspect.397;
dec Inspect.397;
let Inspect.394 : Str = CallByName Inspect.59 Inspect.396 Inspect.245;
let Inspect.395 : Str = "\"";
let Inspect.393 : Str = CallByName Inspect.59 Inspect.394 Inspect.395;
dec Inspect.395;
ret Inspect.393;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.310 : Str = CallByName Inspect.225 Inspect.145 Inspect.299;
ret Inspect.310;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.341 : Str = CallByName #Derived.6 Inspect.145 Inspect.299;
ret Inspect.341;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.350 : Str = CallByName Inspect.225 Inspect.145 Inspect.299;
ret Inspect.350;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.381 : Str = CallByName Inspect.246 Inspect.145 Inspect.299;
ret Inspect.381;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.41 (Inspect.224):
let Inspect.311 : List {Str, Str} = CallByName Inspect.30 Inspect.224;
ret Inspect.311;
procedure Inspect.41 (Inspect.224):
let Inspect.351 : List {Str, Str} = CallByName Inspect.30 Inspect.224;
ret Inspect.351;
procedure Inspect.43 (Inspect.245):
let Inspect.389 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.389;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : Str = CallByName #Derived.0 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName #Derived.2 Inspect.304 Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.359 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.359; ret Inspect.359;
procedure Inspect.60 (Inspect.298): procedure Inspect.231 (Inspect.232, Inspect.228):
ret Inspect.298; let Inspect.351 : Int1 = CallByName Bool.1;
inc Inspect.232;
let Inspect.332 : {Str, Int1} = Struct {Inspect.232, Inspect.351};
let Inspect.333 : {} = Struct {};
let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.332 Inspect.333;
ret Inspect.331;
procedure List.18 (List.163, List.164, List.165): procedure Inspect.231 (Inspect.232, Inspect.228):
let List.623 : U64 = 0i64; let Inspect.391 : Int1 = CallByName Bool.1;
let List.624 : U64 = CallByName List.6 List.163; inc Inspect.232;
let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let Inspect.372 : {Str, Int1} = Struct {Inspect.232, Inspect.391};
ret List.622; let Inspect.373 : {} = Struct {};
let Inspect.371 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.372 Inspect.373;
ret Inspect.371;
procedure List.18 (List.163, List.164, List.165): procedure Inspect.233 (Inspect.334, Inspect.335):
let List.635 : U64 = 0i64; let Inspect.236 : Str = StructAtIndex 0 Inspect.335;
let List.636 : U64 = CallByName List.6 List.163; let Inspect.237 : Str = StructAtIndex 1 Inspect.335;
let List.634 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.635 List.636; let Inspect.234 : Str = StructAtIndex 0 Inspect.334;
ret List.634; let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334;
joinpoint Inspect.349 Inspect.238:
let Inspect.346 : Str = CallByName Inspect.63 Inspect.238 Inspect.236;
dec Inspect.236;
let Inspect.347 : Str = ": ";
let Inspect.341 : Str = CallByName Inspect.63 Inspect.346 Inspect.347;
dec Inspect.347;
let Inspect.337 : Str = CallByName Inspect.239 Inspect.341 Inspect.237;
let Inspect.338 : {} = Struct {};
let Inspect.336 : {Str, Int1} = CallByName Inspect.241 Inspect.337;
dec Inspect.337;
ret Inspect.336;
in
if Inspect.235 then
let Inspect.350 : Str = ", ";
let Inspect.348 : Str = CallByName Inspect.63 Inspect.234 Inspect.350;
dec Inspect.350;
jump Inspect.349 Inspect.348;
else
jump Inspect.349 Inspect.234;
procedure Inspect.233 (Inspect.334, Inspect.335):
let Inspect.236 : Str = StructAtIndex 0 Inspect.335;
let Inspect.237 : Str = StructAtIndex 1 Inspect.335;
let Inspect.234 : Str = StructAtIndex 0 Inspect.334;
let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334;
joinpoint Inspect.389 Inspect.238:
let Inspect.386 : Str = CallByName Inspect.63 Inspect.238 Inspect.236;
dec Inspect.236;
let Inspect.387 : Str = ": ";
let Inspect.381 : Str = CallByName Inspect.63 Inspect.386 Inspect.387;
dec Inspect.387;
let Inspect.377 : Str = CallByName Inspect.239 Inspect.381 Inspect.237;
dec Inspect.237;
let Inspect.378 : {} = Struct {};
let Inspect.376 : {Str, Int1} = CallByName Inspect.241 Inspect.377;
dec Inspect.377;
ret Inspect.376;
in
if Inspect.235 then
let Inspect.390 : Str = ", ";
let Inspect.388 : Str = CallByName Inspect.63 Inspect.234 Inspect.390;
dec Inspect.390;
jump Inspect.389 Inspect.388;
else
jump Inspect.389 Inspect.234;
procedure Inspect.239 (Inspect.240, Inspect.237):
let Inspect.344 : Str = CallByName Inspect.31 Inspect.237 Inspect.240;
ret Inspect.344;
procedure Inspect.239 (Inspect.240, Inspect.237):
let Inspect.384 : Str = CallByName Inspect.31 Inspect.237 Inspect.240;
ret Inspect.384;
procedure Inspect.241 (Inspect.242):
let Inspect.380 : Int1 = CallByName Bool.2;
inc Inspect.242;
let Inspect.379 : {Str, Int1} = Struct {Inspect.242, Inspect.380};
ret Inspect.379;
procedure Inspect.243 (Inspect.326):
let Inspect.367 : Str = StructAtIndex 0 Inspect.326;
ret Inspect.367;
procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.401 : Str = "\"";
let Inspect.400 : Str = CallByName Inspect.63 Inspect.251 Inspect.401;
dec Inspect.401;
let Inspect.398 : Str = CallByName Inspect.63 Inspect.400 Inspect.249;
let Inspect.399 : Str = "\"";
let Inspect.397 : Str = CallByName Inspect.63 Inspect.398 Inspect.399;
dec Inspect.399;
ret Inspect.397;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.314 : Str = CallByName Inspect.229 Inspect.149 Inspect.303;
ret Inspect.314;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.345 : Str = CallByName #Derived.6 Inspect.149 Inspect.303;
ret Inspect.345;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.354 : Str = CallByName Inspect.229 Inspect.149 Inspect.303;
ret Inspect.354;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.385 : Str = CallByName Inspect.250 Inspect.149 Inspect.303;
ret Inspect.385;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.45 (Inspect.228):
let Inspect.315 : List {Str, Str} = CallByName Inspect.30 Inspect.228;
ret Inspect.315;
procedure Inspect.45 (Inspect.228):
let Inspect.355 : List {Str, Str} = CallByName Inspect.30 Inspect.228;
ret Inspect.355;
procedure Inspect.47 (Inspect.249):
let Inspect.393 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.393;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : Str = CallByName #Derived.0 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName #Derived.2 Inspect.308 Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.363 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.363;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.18 (List.166, List.167, List.168):
let List.638 : U64 = 0i64;
let List.639 : U64 = CallByName List.6 List.166;
let List.637 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.638 List.639;
ret List.637;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2; let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633; ret List.636;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.645 : U64 = lowlevel ListLenU64 #Attr.2; let List.648 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.645; ret List.648;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.644 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.647 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.644; ret List.647;
procedure List.92 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): procedure List.95 (#Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26):
joinpoint List.637 List.166 List.167 List.168 List.169 List.170: joinpoint List.640 List.169 List.170 List.171 List.172 List.173:
let List.639 : Int1 = CallByName Num.22 List.169 List.170; let List.642 : Int1 = CallByName Num.22 List.172 List.173;
if List.639 then if List.642 then
let List.643 : {Str, Str} = CallByName List.66 List.166 List.169; let List.646 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.643; inc List.646;
let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.643; let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.646;
let List.642 : U64 = 1i64; let List.645 : U64 = 1i64;
let List.641 : U64 = CallByName Num.51 List.169 List.642; let List.644 : U64 = CallByName Num.51 List.172 List.645;
jump List.637 List.166 List.171 List.168 List.641 List.170; jump List.640 List.169 List.174 List.171 List.644 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.26; inc #Derived_gen.22;
jump List.637 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; jump List.640 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26;
procedure List.92 (#Derived_gen.39, #Derived_gen.40, #Derived_gen.41, #Derived_gen.42, #Derived_gen.43): procedure List.95 (#Derived_gen.43, #Derived_gen.44, #Derived_gen.45, #Derived_gen.46, #Derived_gen.47):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.631; let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.634;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.39; inc #Derived_gen.43;
jump List.625 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43; jump List.628 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46 #Derived_gen.47;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282; ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281; ret Num.283;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.233 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.237 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.233; ret Str.237;
procedure Test.0 (): procedure Test.0 ():
let Test.4 : Str = "bar"; let Test.4 : Str = "bar";

View file

@ -4,15 +4,15 @@ procedure #Derived.0 (#Derived.1):
procedure #Derived.2 (#Derived.3, #Derived.1): procedure #Derived.2 (#Derived.3, #Derived.1):
let #Derived_gen.13 : I64 = StructAtIndex 1 #Derived.1; let #Derived_gen.13 : I64 = StructAtIndex 1 #Derived.1;
let #Derived_gen.11 : [C I64, C Decimal] = CallByName Inspect.53 #Derived_gen.13; let #Derived_gen.11 : [C I64, C Decimal] = CallByName Inspect.57 #Derived_gen.13;
let #Derived_gen.12 : Str = "a"; let #Derived_gen.12 : Str = "a";
let #Derived_gen.6 : {[C I64, C Decimal], Str} = Struct {#Derived_gen.11, #Derived_gen.12}; let #Derived_gen.6 : {[C I64, C Decimal], Str} = Struct {#Derived_gen.11, #Derived_gen.12};
let #Derived_gen.10 : Decimal = StructAtIndex 0 #Derived.1; let #Derived_gen.10 : Decimal = StructAtIndex 0 #Derived.1;
let #Derived_gen.8 : [C I64, C Decimal] = CallByName Inspect.58 #Derived_gen.10; let #Derived_gen.8 : [C I64, C Decimal] = CallByName Inspect.62 #Derived_gen.10;
let #Derived_gen.9 : Str = "b"; let #Derived_gen.9 : Str = "b";
let #Derived_gen.7 : {[C I64, C Decimal], Str} = Struct {#Derived_gen.8, #Derived_gen.9}; let #Derived_gen.7 : {[C I64, C Decimal], Str} = Struct {#Derived_gen.8, #Derived_gen.9};
let #Derived_gen.5 : List {[C I64, C Decimal], Str} = Array [#Derived_gen.6, #Derived_gen.7]; let #Derived_gen.5 : List {[C I64, C Decimal], Str} = Array [#Derived_gen.6, #Derived_gen.7];
let #Derived_gen.4 : List {[C I64, C Decimal], Str} = CallByName Inspect.41 #Derived_gen.5; let #Derived_gen.4 : List {[C I64, C Decimal], Str} = CallByName Inspect.45 #Derived_gen.5;
let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3;
dec #Derived_gen.4; dec #Derived_gen.4;
ret #Derived_gen.3; ret #Derived_gen.3;
@ -25,192 +25,192 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true; let Bool.23 : Int1 = true;
ret Bool.23; ret Bool.23;
procedure Inspect.225 (Inspect.226, Inspect.224): procedure Inspect.229 (Inspect.230, Inspect.228):
let Inspect.349 : Str = "{"; let Inspect.353 : Str = "{";
let Inspect.324 : Str = CallByName Inspect.59 Inspect.226 Inspect.349; let Inspect.328 : Str = CallByName Inspect.63 Inspect.230 Inspect.353;
dec Inspect.349; dec Inspect.353;
let Inspect.320 : {Str, Int1} = CallByName Inspect.227 Inspect.324 Inspect.224; let Inspect.324 : {Str, Int1} = CallByName Inspect.231 Inspect.328 Inspect.228;
dec Inspect.324; dec Inspect.328;
let Inspect.321 : {} = Struct {}; let Inspect.325 : {} = Struct {};
let Inspect.316 : Str = CallByName Inspect.239 Inspect.320; let Inspect.320 : Str = CallByName Inspect.243 Inspect.324;
let Inspect.317 : Str = "}"; let Inspect.321 : Str = "}";
let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321;
dec Inspect.317; dec Inspect.321;
ret Inspect.315;
procedure Inspect.227 (Inspect.228, Inspect.224):
let Inspect.348 : Int1 = CallByName Bool.1;
inc Inspect.228;
let Inspect.328 : {Str, Int1} = Struct {Inspect.228, Inspect.348};
let Inspect.329 : {} = Struct {};
let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.328 Inspect.329;
ret Inspect.327;
procedure Inspect.229 (Inspect.330, Inspect.331):
let Inspect.233 : [C I64, C Decimal] = StructAtIndex 0 Inspect.331;
let Inspect.232 : Str = StructAtIndex 1 Inspect.331;
let Inspect.230 : Str = StructAtIndex 0 Inspect.330;
let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330;
joinpoint Inspect.346 Inspect.234:
let Inspect.343 : Str = CallByName Inspect.59 Inspect.234 Inspect.232;
dec Inspect.232;
let Inspect.344 : Str = ": ";
let Inspect.337 : Str = CallByName Inspect.59 Inspect.343 Inspect.344;
dec Inspect.344;
let Inspect.333 : Str = CallByName Inspect.235 Inspect.337 Inspect.233;
let Inspect.334 : {} = Struct {};
let Inspect.332 : {Str, Int1} = CallByName Inspect.237 Inspect.333;
dec Inspect.333;
ret Inspect.332;
in
if Inspect.231 then
let Inspect.347 : Str = ", ";
let Inspect.345 : Str = CallByName Inspect.59 Inspect.230 Inspect.347;
dec Inspect.347;
jump Inspect.346 Inspect.345;
else
jump Inspect.346 Inspect.230;
procedure Inspect.235 (Inspect.236, Inspect.233):
let Inspect.340 : Str = CallByName Inspect.31 Inspect.233 Inspect.236;
ret Inspect.340;
procedure Inspect.237 (Inspect.238):
let Inspect.336 : Int1 = CallByName Bool.2;
inc Inspect.238;
let Inspect.335 : {Str, Int1} = Struct {Inspect.238, Inspect.336};
ret Inspect.335;
procedure Inspect.239 (Inspect.322):
let Inspect.323 : Str = StructAtIndex 0 Inspect.322;
ret Inspect.323;
procedure Inspect.274 (Inspect.275, #Attr.12):
let Inspect.362 : I64 = UnionAtIndex (Id 0) (Index 0) #Attr.12;
let Inspect.361 : Str = CallByName Num.96 Inspect.362;
let Inspect.360 : Str = CallByName Inspect.59 Inspect.275 Inspect.361;
dec Inspect.361;
ret Inspect.360;
procedure Inspect.289 (Inspect.290, #Attr.12):
let Inspect.356 : Decimal = UnionAtIndex (Id 1) (Index 0) #Attr.12;
let Inspect.355 : Str = CallByName Num.96 Inspect.356;
let Inspect.354 : Str = CallByName Inspect.59 Inspect.290 Inspect.355;
dec Inspect.355;
ret Inspect.354;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.310 : Str = CallByName Inspect.225 Inspect.145 Inspect.299;
ret Inspect.310;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.342 : U8 = GetTagId Inspect.299;
switch Inspect.342:
case 0:
let Inspect.341 : Str = CallByName Inspect.274 Inspect.145 Inspect.299;
ret Inspect.341;
default:
let Inspect.341 : Str = CallByName Inspect.289 Inspect.145 Inspect.299;
ret Inspect.341;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.41 (Inspect.224):
let Inspect.311 : List {[C I64, C Decimal], Str} = CallByName Inspect.30 Inspect.224;
ret Inspect.311;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : {Decimal, I64} = CallByName #Derived.0 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName #Derived.2 Inspect.304 Inspect.308;
ret Inspect.303;
procedure Inspect.53 (Inspect.273):
let Inspect.358 : [C I64, C Decimal] = TagId(0) Inspect.273;
let Inspect.357 : [C I64, C Decimal] = CallByName Inspect.30 Inspect.358;
ret Inspect.357;
procedure Inspect.58 (Inspect.288):
let Inspect.351 : [C I64, C Decimal] = TagId(1) Inspect.288;
let Inspect.350 : [C I64, C Decimal] = CallByName Inspect.30 Inspect.351;
ret Inspect.350;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.319; ret Inspect.319;
procedure Inspect.60 (Inspect.298): procedure Inspect.231 (Inspect.232, Inspect.228):
ret Inspect.298; let Inspect.352 : Int1 = CallByName Bool.1;
inc Inspect.232;
let Inspect.332 : {Str, Int1} = Struct {Inspect.232, Inspect.352};
let Inspect.333 : {} = Struct {};
let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.332 Inspect.333;
ret Inspect.331;
procedure List.18 (List.163, List.164, List.165): procedure Inspect.233 (Inspect.334, Inspect.335):
let List.623 : U64 = 0i64; let Inspect.237 : [C I64, C Decimal] = StructAtIndex 0 Inspect.335;
let List.624 : U64 = CallByName List.6 List.163; let Inspect.236 : Str = StructAtIndex 1 Inspect.335;
let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let Inspect.234 : Str = StructAtIndex 0 Inspect.334;
ret List.622; let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334;
joinpoint Inspect.350 Inspect.238:
let Inspect.347 : Str = CallByName Inspect.63 Inspect.238 Inspect.236;
dec Inspect.236;
let Inspect.348 : Str = ": ";
let Inspect.341 : Str = CallByName Inspect.63 Inspect.347 Inspect.348;
dec Inspect.348;
let Inspect.337 : Str = CallByName Inspect.239 Inspect.341 Inspect.237;
let Inspect.338 : {} = Struct {};
let Inspect.336 : {Str, Int1} = CallByName Inspect.241 Inspect.337;
dec Inspect.337;
ret Inspect.336;
in
if Inspect.235 then
let Inspect.351 : Str = ", ";
let Inspect.349 : Str = CallByName Inspect.63 Inspect.234 Inspect.351;
dec Inspect.351;
jump Inspect.350 Inspect.349;
else
jump Inspect.350 Inspect.234;
procedure Inspect.239 (Inspect.240, Inspect.237):
let Inspect.344 : Str = CallByName Inspect.31 Inspect.237 Inspect.240;
ret Inspect.344;
procedure Inspect.241 (Inspect.242):
let Inspect.340 : Int1 = CallByName Bool.2;
inc Inspect.242;
let Inspect.339 : {Str, Int1} = Struct {Inspect.242, Inspect.340};
ret Inspect.339;
procedure Inspect.243 (Inspect.326):
let Inspect.327 : Str = StructAtIndex 0 Inspect.326;
ret Inspect.327;
procedure Inspect.278 (Inspect.279, #Attr.12):
let Inspect.366 : I64 = UnionAtIndex (Id 0) (Index 0) #Attr.12;
let Inspect.365 : Str = CallByName Num.96 Inspect.366;
let Inspect.364 : Str = CallByName Inspect.63 Inspect.279 Inspect.365;
dec Inspect.365;
ret Inspect.364;
procedure Inspect.293 (Inspect.294, #Attr.12):
let Inspect.360 : Decimal = UnionAtIndex (Id 1) (Index 0) #Attr.12;
let Inspect.359 : Str = CallByName Num.96 Inspect.360;
let Inspect.358 : Str = CallByName Inspect.63 Inspect.294 Inspect.359;
dec Inspect.359;
ret Inspect.358;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.314 : Str = CallByName Inspect.229 Inspect.149 Inspect.303;
ret Inspect.314;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.346 : U8 = GetTagId Inspect.303;
switch Inspect.346:
case 0:
let Inspect.345 : Str = CallByName Inspect.278 Inspect.149 Inspect.303;
ret Inspect.345;
default:
let Inspect.345 : Str = CallByName Inspect.293 Inspect.149 Inspect.303;
ret Inspect.345;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.45 (Inspect.228):
let Inspect.315 : List {[C I64, C Decimal], Str} = CallByName Inspect.30 Inspect.228;
ret Inspect.315;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : {Decimal, I64} = CallByName #Derived.0 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName #Derived.2 Inspect.308 Inspect.312;
ret Inspect.307;
procedure Inspect.57 (Inspect.277):
let Inspect.362 : [C I64, C Decimal] = TagId(0) Inspect.277;
let Inspect.361 : [C I64, C Decimal] = CallByName Inspect.30 Inspect.362;
ret Inspect.361;
procedure Inspect.62 (Inspect.292):
let Inspect.355 : [C I64, C Decimal] = TagId(1) Inspect.292;
let Inspect.354 : [C I64, C Decimal] = CallByName Inspect.30 Inspect.355;
ret Inspect.354;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.323;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2; let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633; ret List.636;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {[C I64, C Decimal], Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : {[C I64, C Decimal], Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.92 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): procedure List.95 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : {[C I64, C Decimal], Str} = CallByName List.66 List.166 List.169; let List.634 : {[C I64, C Decimal], Str} = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.631; let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.634;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.26; inc #Derived_gen.26;
jump List.625 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; jump List.628 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282; ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.283;
procedure Num.96 (#Attr.2):
let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.281; ret Num.281;
procedure Num.96 (#Attr.2): procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2; let Num.282 : Str = lowlevel NumToStr #Attr.2;
ret Num.279; ret Num.282;
procedure Num.96 (#Attr.2):
let Num.280 : Str = lowlevel NumToStr #Attr.2;
ret Num.280;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232; ret Str.236;
procedure Test.0 (): procedure Test.0 ():
let Test.3 : Decimal = 3dec; let Test.3 : Decimal = 3dec;

View file

@ -4,10 +4,10 @@ procedure #Derived.0 (#Derived.1):
procedure #Derived.2 (#Derived.3, #Derived.1): procedure #Derived.2 (#Derived.3, #Derived.1):
let #Derived_gen.7 : Str = "a"; let #Derived_gen.7 : Str = "a";
let #Derived_gen.8 : Str = CallByName Inspect.43 #Derived.1; let #Derived_gen.8 : Str = CallByName Inspect.47 #Derived.1;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6];
let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.41 #Derived_gen.5; let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.45 #Derived_gen.5;
let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3;
dec #Derived_gen.4; dec #Derived_gen.4;
ret #Derived_gen.3; ret #Derived_gen.3;
@ -20,167 +20,167 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true; let Bool.23 : Int1 = true;
ret Bool.23; ret Bool.23;
procedure Inspect.225 (Inspect.226, Inspect.224): procedure Inspect.229 (Inspect.230, Inspect.228):
let Inspect.348 : Str = "{"; let Inspect.352 : Str = "{";
let Inspect.324 : Str = CallByName Inspect.59 Inspect.226 Inspect.348; let Inspect.328 : Str = CallByName Inspect.63 Inspect.230 Inspect.352;
dec Inspect.348; dec Inspect.352;
let Inspect.320 : {Str, Int1} = CallByName Inspect.227 Inspect.324 Inspect.224; let Inspect.324 : {Str, Int1} = CallByName Inspect.231 Inspect.328 Inspect.228;
dec Inspect.324; dec Inspect.328;
let Inspect.321 : {} = Struct {}; let Inspect.325 : {} = Struct {};
let Inspect.316 : Str = CallByName Inspect.239 Inspect.320; let Inspect.320 : Str = CallByName Inspect.243 Inspect.324;
let Inspect.317 : Str = "}"; let Inspect.321 : Str = "}";
let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321;
dec Inspect.317; dec Inspect.321;
ret Inspect.315;
procedure Inspect.227 (Inspect.228, Inspect.224):
let Inspect.347 : Int1 = CallByName Bool.1;
inc Inspect.228;
let Inspect.328 : {Str, Int1} = Struct {Inspect.228, Inspect.347};
let Inspect.329 : {} = Struct {};
let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.328 Inspect.329;
ret Inspect.327;
procedure Inspect.229 (Inspect.330, Inspect.331):
let Inspect.232 : Str = StructAtIndex 0 Inspect.331;
let Inspect.233 : Str = StructAtIndex 1 Inspect.331;
let Inspect.230 : Str = StructAtIndex 0 Inspect.330;
let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330;
joinpoint Inspect.345 Inspect.234:
let Inspect.342 : Str = CallByName Inspect.59 Inspect.234 Inspect.232;
dec Inspect.232;
let Inspect.343 : Str = ": ";
let Inspect.337 : Str = CallByName Inspect.59 Inspect.342 Inspect.343;
dec Inspect.343;
let Inspect.333 : Str = CallByName Inspect.235 Inspect.337 Inspect.233;
dec Inspect.233;
let Inspect.334 : {} = Struct {};
let Inspect.332 : {Str, Int1} = CallByName Inspect.237 Inspect.333;
dec Inspect.333;
ret Inspect.332;
in
if Inspect.231 then
let Inspect.346 : Str = ", ";
let Inspect.344 : Str = CallByName Inspect.59 Inspect.230 Inspect.346;
dec Inspect.346;
jump Inspect.345 Inspect.344;
else
jump Inspect.345 Inspect.230;
procedure Inspect.235 (Inspect.236, Inspect.233):
let Inspect.340 : Str = CallByName Inspect.31 Inspect.233 Inspect.236;
ret Inspect.340;
procedure Inspect.237 (Inspect.238):
let Inspect.336 : Int1 = CallByName Bool.2;
inc Inspect.238;
let Inspect.335 : {Str, Int1} = Struct {Inspect.238, Inspect.336};
ret Inspect.335;
procedure Inspect.239 (Inspect.322):
let Inspect.323 : Str = StructAtIndex 0 Inspect.322;
ret Inspect.323;
procedure Inspect.246 (Inspect.247, Inspect.245):
let Inspect.357 : Str = "\"";
let Inspect.356 : Str = CallByName Inspect.59 Inspect.247 Inspect.357;
dec Inspect.357;
let Inspect.354 : Str = CallByName Inspect.59 Inspect.356 Inspect.245;
let Inspect.355 : Str = "\"";
let Inspect.353 : Str = CallByName Inspect.59 Inspect.354 Inspect.355;
dec Inspect.355;
ret Inspect.353;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.310 : Str = CallByName Inspect.225 Inspect.145 Inspect.299;
ret Inspect.310;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.341 : Str = CallByName Inspect.246 Inspect.145 Inspect.299;
ret Inspect.341;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.41 (Inspect.224):
let Inspect.311 : List {Str, Str} = CallByName Inspect.30 Inspect.224;
ret Inspect.311;
procedure Inspect.43 (Inspect.245):
let Inspect.349 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.349;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : Str = CallByName #Derived.0 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName #Derived.2 Inspect.304 Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.319; ret Inspect.319;
procedure Inspect.60 (Inspect.298): procedure Inspect.231 (Inspect.232, Inspect.228):
ret Inspect.298; let Inspect.351 : Int1 = CallByName Bool.1;
inc Inspect.232;
let Inspect.332 : {Str, Int1} = Struct {Inspect.232, Inspect.351};
let Inspect.333 : {} = Struct {};
let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.332 Inspect.333;
ret Inspect.331;
procedure List.18 (List.163, List.164, List.165): procedure Inspect.233 (Inspect.334, Inspect.335):
let List.623 : U64 = 0i64; let Inspect.236 : Str = StructAtIndex 0 Inspect.335;
let List.624 : U64 = CallByName List.6 List.163; let Inspect.237 : Str = StructAtIndex 1 Inspect.335;
let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let Inspect.234 : Str = StructAtIndex 0 Inspect.334;
ret List.622; let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334;
joinpoint Inspect.349 Inspect.238:
let Inspect.346 : Str = CallByName Inspect.63 Inspect.238 Inspect.236;
dec Inspect.236;
let Inspect.347 : Str = ": ";
let Inspect.341 : Str = CallByName Inspect.63 Inspect.346 Inspect.347;
dec Inspect.347;
let Inspect.337 : Str = CallByName Inspect.239 Inspect.341 Inspect.237;
dec Inspect.237;
let Inspect.338 : {} = Struct {};
let Inspect.336 : {Str, Int1} = CallByName Inspect.241 Inspect.337;
dec Inspect.337;
ret Inspect.336;
in
if Inspect.235 then
let Inspect.350 : Str = ", ";
let Inspect.348 : Str = CallByName Inspect.63 Inspect.234 Inspect.350;
dec Inspect.350;
jump Inspect.349 Inspect.348;
else
jump Inspect.349 Inspect.234;
procedure Inspect.239 (Inspect.240, Inspect.237):
let Inspect.344 : Str = CallByName Inspect.31 Inspect.237 Inspect.240;
ret Inspect.344;
procedure Inspect.241 (Inspect.242):
let Inspect.340 : Int1 = CallByName Bool.2;
inc Inspect.242;
let Inspect.339 : {Str, Int1} = Struct {Inspect.242, Inspect.340};
ret Inspect.339;
procedure Inspect.243 (Inspect.326):
let Inspect.327 : Str = StructAtIndex 0 Inspect.326;
ret Inspect.327;
procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.361 : Str = "\"";
let Inspect.360 : Str = CallByName Inspect.63 Inspect.251 Inspect.361;
dec Inspect.361;
let Inspect.358 : Str = CallByName Inspect.63 Inspect.360 Inspect.249;
let Inspect.359 : Str = "\"";
let Inspect.357 : Str = CallByName Inspect.63 Inspect.358 Inspect.359;
dec Inspect.359;
ret Inspect.357;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.314 : Str = CallByName Inspect.229 Inspect.149 Inspect.303;
ret Inspect.314;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.345 : Str = CallByName Inspect.250 Inspect.149 Inspect.303;
ret Inspect.345;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.45 (Inspect.228):
let Inspect.315 : List {Str, Str} = CallByName Inspect.30 Inspect.228;
ret Inspect.315;
procedure Inspect.47 (Inspect.249):
let Inspect.353 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.353;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : Str = CallByName #Derived.0 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName #Derived.2 Inspect.308 Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.323;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2; let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633; ret List.636;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.92 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): procedure List.95 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.631; let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.634;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.10; inc #Derived_gen.14;
jump List.625 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; jump List.628 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232; ret Str.236;
procedure Test.0 (): procedure Test.0 ():
let Test.3 : Str = "foo"; let Test.3 : Str = "foo";

View file

@ -6,15 +6,15 @@ procedure #Derived.2 (#Derived.3, #Derived.1):
let #Derived_gen.11 : Str = "a"; let #Derived_gen.11 : Str = "a";
let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1; let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1;
inc #Derived_gen.13; inc #Derived_gen.13;
let #Derived_gen.12 : Str = CallByName Inspect.43 #Derived_gen.13; let #Derived_gen.12 : Str = CallByName Inspect.47 #Derived_gen.13;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.11, #Derived_gen.12}; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.11, #Derived_gen.12};
let #Derived_gen.8 : Str = "b"; let #Derived_gen.8 : Str = "b";
let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1; let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1;
dec #Derived_gen.13; dec #Derived_gen.13;
let #Derived_gen.9 : Str = CallByName Inspect.43 #Derived_gen.10; let #Derived_gen.9 : Str = CallByName Inspect.47 #Derived_gen.10;
let #Derived_gen.7 : {Str, Str} = Struct {#Derived_gen.8, #Derived_gen.9}; let #Derived_gen.7 : {Str, Str} = Struct {#Derived_gen.8, #Derived_gen.9};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6, #Derived_gen.7]; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6, #Derived_gen.7];
let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.41 #Derived_gen.5; let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.45 #Derived_gen.5;
let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3;
dec #Derived_gen.4; dec #Derived_gen.4;
ret #Derived_gen.3; ret #Derived_gen.3;
@ -27,167 +27,167 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true; let Bool.23 : Int1 = true;
ret Bool.23; ret Bool.23;
procedure Inspect.225 (Inspect.226, Inspect.224): procedure Inspect.229 (Inspect.230, Inspect.228):
let Inspect.348 : Str = "{"; let Inspect.352 : Str = "{";
let Inspect.324 : Str = CallByName Inspect.59 Inspect.226 Inspect.348; let Inspect.328 : Str = CallByName Inspect.63 Inspect.230 Inspect.352;
dec Inspect.348; dec Inspect.352;
let Inspect.320 : {Str, Int1} = CallByName Inspect.227 Inspect.324 Inspect.224; let Inspect.324 : {Str, Int1} = CallByName Inspect.231 Inspect.328 Inspect.228;
dec Inspect.324; dec Inspect.328;
let Inspect.321 : {} = Struct {}; let Inspect.325 : {} = Struct {};
let Inspect.316 : Str = CallByName Inspect.239 Inspect.320; let Inspect.320 : Str = CallByName Inspect.243 Inspect.324;
let Inspect.317 : Str = "}"; let Inspect.321 : Str = "}";
let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321;
dec Inspect.317; dec Inspect.321;
ret Inspect.315;
procedure Inspect.227 (Inspect.228, Inspect.224):
let Inspect.347 : Int1 = CallByName Bool.1;
inc Inspect.228;
let Inspect.328 : {Str, Int1} = Struct {Inspect.228, Inspect.347};
let Inspect.329 : {} = Struct {};
let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.328 Inspect.329;
ret Inspect.327;
procedure Inspect.229 (Inspect.330, Inspect.331):
let Inspect.232 : Str = StructAtIndex 0 Inspect.331;
let Inspect.233 : Str = StructAtIndex 1 Inspect.331;
let Inspect.230 : Str = StructAtIndex 0 Inspect.330;
let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330;
joinpoint Inspect.345 Inspect.234:
let Inspect.342 : Str = CallByName Inspect.59 Inspect.234 Inspect.232;
dec Inspect.232;
let Inspect.343 : Str = ": ";
let Inspect.337 : Str = CallByName Inspect.59 Inspect.342 Inspect.343;
dec Inspect.343;
let Inspect.333 : Str = CallByName Inspect.235 Inspect.337 Inspect.233;
dec Inspect.233;
let Inspect.334 : {} = Struct {};
let Inspect.332 : {Str, Int1} = CallByName Inspect.237 Inspect.333;
dec Inspect.333;
ret Inspect.332;
in
if Inspect.231 then
let Inspect.346 : Str = ", ";
let Inspect.344 : Str = CallByName Inspect.59 Inspect.230 Inspect.346;
dec Inspect.346;
jump Inspect.345 Inspect.344;
else
jump Inspect.345 Inspect.230;
procedure Inspect.235 (Inspect.236, Inspect.233):
let Inspect.340 : Str = CallByName Inspect.31 Inspect.233 Inspect.236;
ret Inspect.340;
procedure Inspect.237 (Inspect.238):
let Inspect.336 : Int1 = CallByName Bool.2;
inc Inspect.238;
let Inspect.335 : {Str, Int1} = Struct {Inspect.238, Inspect.336};
ret Inspect.335;
procedure Inspect.239 (Inspect.322):
let Inspect.323 : Str = StructAtIndex 0 Inspect.322;
ret Inspect.323;
procedure Inspect.246 (Inspect.247, Inspect.245):
let Inspect.357 : Str = "\"";
let Inspect.356 : Str = CallByName Inspect.59 Inspect.247 Inspect.357;
dec Inspect.357;
let Inspect.354 : Str = CallByName Inspect.59 Inspect.356 Inspect.245;
let Inspect.355 : Str = "\"";
let Inspect.353 : Str = CallByName Inspect.59 Inspect.354 Inspect.355;
dec Inspect.355;
ret Inspect.353;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.310 : Str = CallByName Inspect.225 Inspect.145 Inspect.299;
ret Inspect.310;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.341 : Str = CallByName Inspect.246 Inspect.145 Inspect.299;
ret Inspect.341;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.41 (Inspect.224):
let Inspect.311 : List {Str, Str} = CallByName Inspect.30 Inspect.224;
ret Inspect.311;
procedure Inspect.43 (Inspect.245):
let Inspect.358 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.358;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : {Str, Str} = CallByName #Derived.0 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName #Derived.2 Inspect.304 Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.319; ret Inspect.319;
procedure Inspect.60 (Inspect.298): procedure Inspect.231 (Inspect.232, Inspect.228):
ret Inspect.298; let Inspect.351 : Int1 = CallByName Bool.1;
inc Inspect.232;
let Inspect.332 : {Str, Int1} = Struct {Inspect.232, Inspect.351};
let Inspect.333 : {} = Struct {};
let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.332 Inspect.333;
ret Inspect.331;
procedure List.18 (List.163, List.164, List.165): procedure Inspect.233 (Inspect.334, Inspect.335):
let List.623 : U64 = 0i64; let Inspect.236 : Str = StructAtIndex 0 Inspect.335;
let List.624 : U64 = CallByName List.6 List.163; let Inspect.237 : Str = StructAtIndex 1 Inspect.335;
let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; let Inspect.234 : Str = StructAtIndex 0 Inspect.334;
ret List.622; let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334;
joinpoint Inspect.349 Inspect.238:
let Inspect.346 : Str = CallByName Inspect.63 Inspect.238 Inspect.236;
dec Inspect.236;
let Inspect.347 : Str = ": ";
let Inspect.341 : Str = CallByName Inspect.63 Inspect.346 Inspect.347;
dec Inspect.347;
let Inspect.337 : Str = CallByName Inspect.239 Inspect.341 Inspect.237;
dec Inspect.237;
let Inspect.338 : {} = Struct {};
let Inspect.336 : {Str, Int1} = CallByName Inspect.241 Inspect.337;
dec Inspect.337;
ret Inspect.336;
in
if Inspect.235 then
let Inspect.350 : Str = ", ";
let Inspect.348 : Str = CallByName Inspect.63 Inspect.234 Inspect.350;
dec Inspect.350;
jump Inspect.349 Inspect.348;
else
jump Inspect.349 Inspect.234;
procedure Inspect.239 (Inspect.240, Inspect.237):
let Inspect.344 : Str = CallByName Inspect.31 Inspect.237 Inspect.240;
ret Inspect.344;
procedure Inspect.241 (Inspect.242):
let Inspect.340 : Int1 = CallByName Bool.2;
inc Inspect.242;
let Inspect.339 : {Str, Int1} = Struct {Inspect.242, Inspect.340};
ret Inspect.339;
procedure Inspect.243 (Inspect.326):
let Inspect.327 : Str = StructAtIndex 0 Inspect.326;
ret Inspect.327;
procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.361 : Str = "\"";
let Inspect.360 : Str = CallByName Inspect.63 Inspect.251 Inspect.361;
dec Inspect.361;
let Inspect.358 : Str = CallByName Inspect.63 Inspect.360 Inspect.249;
let Inspect.359 : Str = "\"";
let Inspect.357 : Str = CallByName Inspect.63 Inspect.358 Inspect.359;
dec Inspect.359;
ret Inspect.357;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.314 : Str = CallByName Inspect.229 Inspect.149 Inspect.303;
ret Inspect.314;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.345 : Str = CallByName Inspect.250 Inspect.149 Inspect.303;
ret Inspect.345;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.45 (Inspect.228):
let Inspect.315 : List {Str, Str} = CallByName Inspect.30 Inspect.228;
ret Inspect.315;
procedure Inspect.47 (Inspect.249):
let Inspect.362 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.362;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : {Str, Str} = CallByName #Derived.0 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName #Derived.2 Inspect.308 Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.323;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2; let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633; ret List.636;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): procedure List.95 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.631; let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.634;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.14; inc #Derived_gen.18;
jump List.625 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; jump List.628 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232; ret Str.236;
procedure Test.0 (): procedure Test.0 ():
let Test.3 : Str = "foo"; let Test.3 : Str = "foo";

View file

@ -1,47 +1,47 @@
procedure Inspect.246 (Inspect.247, Inspect.245): procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.323 : Str = "\"";
let Inspect.322 : Str = CallByName Inspect.63 Inspect.251 Inspect.323;
dec Inspect.323;
let Inspect.318 : Str = CallByName Inspect.63 Inspect.322 Inspect.249;
let Inspect.319 : Str = "\""; let Inspect.319 : Str = "\"";
let Inspect.318 : Str = CallByName Inspect.59 Inspect.247 Inspect.319; let Inspect.317 : Str = CallByName Inspect.63 Inspect.318 Inspect.319;
dec Inspect.319; dec Inspect.319;
let Inspect.314 : Str = CallByName Inspect.59 Inspect.318 Inspect.245;
let Inspect.315 : Str = "\"";
let Inspect.313 : Str = CallByName Inspect.59 Inspect.314 Inspect.315;
dec Inspect.315;
ret Inspect.313;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.43 (Inspect.245):
let Inspect.309 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.309;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : Str = CallByName Inspect.43 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName Inspect.246 Inspect.304 Inspect.308;
dec Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.317 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.317; ret Inspect.317;
procedure Inspect.60 (Inspect.298): procedure Inspect.30 (Inspect.147):
ret Inspect.298; ret Inspect.147;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.47 (Inspect.249):
let Inspect.313 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.313;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : Str = CallByName Inspect.47 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName Inspect.250 Inspect.308 Inspect.312;
dec Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.321 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.321;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232; ret Str.236;
procedure Test.0 (): procedure Test.0 ():
let Test.2 : Str = "abc"; let Test.2 : Str = "abc";

View file

@ -8,9 +8,9 @@ procedure #Derived.3 (#Derived.4, #Derived.1):
ret #Derived_gen.3; ret #Derived_gen.3;
in in
let #Derived_gen.7 : Str = "A"; let #Derived_gen.7 : Str = "A";
let #Derived_gen.9 : Str = CallByName Inspect.43 #Derived.1; let #Derived_gen.9 : Str = CallByName Inspect.47 #Derived.1;
let #Derived_gen.8 : List Str = Array [#Derived_gen.9]; let #Derived_gen.8 : List Str = Array [#Derived_gen.9];
let #Derived_gen.6 : [C Str, C Str List Str] = CallByName Inspect.39 #Derived_gen.7 #Derived_gen.8; let #Derived_gen.6 : [C Str, C Str List Str] = CallByName Inspect.43 #Derived_gen.7 #Derived_gen.8;
dec #Derived_gen.8; dec #Derived_gen.8;
dec #Derived_gen.7; dec #Derived_gen.7;
jump #Derived_gen.5 #Derived_gen.6; jump #Derived_gen.5 #Derived_gen.6;
@ -19,168 +19,168 @@ procedure Bool.11 (#Attr.2, #Attr.3):
let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3;
ret Bool.23; ret Bool.23;
procedure Inspect.200 (Inspect.201, #Attr.12): procedure Inspect.204 (Inspect.205, #Attr.12):
let Inspect.342 : Str = UnionAtIndex (Id 0) (Index 0) #Attr.12; let Inspect.346 : Str = UnionAtIndex (Id 0) (Index 0) #Attr.12;
let Inspect.341 : Str = CallByName Inspect.59 Inspect.201 Inspect.342; let Inspect.345 : Str = CallByName Inspect.63 Inspect.205 Inspect.346;
dec Inspect.342; dec Inspect.346;
ret Inspect.341; ret Inspect.345;
procedure Inspect.202 (Inspect.203, #Attr.12): procedure Inspect.206 (Inspect.207, #Attr.12):
let Inspect.336 : List Str = UnionAtIndex (Id 1) (Index 1) #Attr.12; let Inspect.340 : List Str = UnionAtIndex (Id 1) (Index 1) #Attr.12;
let Inspect.335 : Str = UnionAtIndex (Id 1) (Index 0) #Attr.12; let Inspect.339 : Str = UnionAtIndex (Id 1) (Index 0) #Attr.12;
let Inspect.334 : Str = "("; let Inspect.338 : Str = "(";
let Inspect.333 : Str = CallByName Inspect.59 Inspect.203 Inspect.334; let Inspect.337 : Str = CallByName Inspect.63 Inspect.207 Inspect.338;
dec Inspect.334; dec Inspect.338;
let Inspect.321 : Str = CallByName Inspect.59 Inspect.333 Inspect.335; let Inspect.325 : Str = CallByName Inspect.63 Inspect.337 Inspect.339;
dec Inspect.335; dec Inspect.339;
let Inspect.317 : Str = CallByName Inspect.204 Inspect.321 Inspect.336; let Inspect.321 : Str = CallByName Inspect.208 Inspect.325 Inspect.340;
dec Inspect.336; dec Inspect.340;
let Inspect.318 : Str = ")"; let Inspect.322 : Str = ")";
let Inspect.316 : Str = CallByName Inspect.59 Inspect.317 Inspect.318; let Inspect.320 : Str = CallByName Inspect.63 Inspect.321 Inspect.322;
dec Inspect.318; dec Inspect.322;
ret Inspect.316;
procedure Inspect.204 (Inspect.205, Inspect.199):
let Inspect.325 : {} = Struct {};
let Inspect.324 : Str = CallByName List.18 Inspect.199 Inspect.205 Inspect.325;
ret Inspect.324;
procedure Inspect.206 (Inspect.207, Inspect.208):
let Inspect.332 : Str = " ";
let Inspect.327 : Str = CallByName Inspect.59 Inspect.207 Inspect.332;
dec Inspect.332;
let Inspect.326 : Str = CallByName Inspect.209 Inspect.327 Inspect.208;
ret Inspect.326;
procedure Inspect.209 (Inspect.210, Inspect.208):
let Inspect.330 : Str = CallByName Inspect.31 Inspect.208 Inspect.210;
ret Inspect.330;
procedure Inspect.246 (Inspect.247, Inspect.245):
let Inspect.351 : Str = "\"";
let Inspect.350 : Str = CallByName Inspect.59 Inspect.247 Inspect.351;
dec Inspect.351;
let Inspect.348 : Str = CallByName Inspect.59 Inspect.350 Inspect.245;
let Inspect.349 : Str = "\"";
let Inspect.347 : Str = CallByName Inspect.59 Inspect.348 Inspect.349;
dec Inspect.349;
ret Inspect.347;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.311 : U8 = GetTagId Inspect.299;
switch Inspect.311:
case 0:
let Inspect.310 : Str = CallByName Inspect.200 Inspect.145 Inspect.299;
ret Inspect.310;
default:
let Inspect.310 : Str = CallByName Inspect.202 Inspect.145 Inspect.299;
ret Inspect.310;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.331 : Str = CallByName Inspect.246 Inspect.145 Inspect.299;
ret Inspect.331;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.39 (Inspect.198, Inspect.199):
let Inspect.337 : Int1 = CallByName List.1 Inspect.199;
if Inspect.337 then
inc Inspect.198;
let Inspect.339 : [C Str, C Str List Str] = TagId(0) Inspect.198;
let Inspect.338 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.339;
ret Inspect.338;
else
inc Inspect.199;
inc Inspect.198;
let Inspect.313 : [C Str, C Str List Str] = TagId(1) Inspect.198 Inspect.199;
let Inspect.312 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.313;
ret Inspect.312;
procedure Inspect.43 (Inspect.245):
let Inspect.343 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.343;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : Str = CallByName #Derived.0 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName #Derived.3 Inspect.304 Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.320 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.320; ret Inspect.320;
procedure Inspect.60 (Inspect.298): procedure Inspect.208 (Inspect.209, Inspect.203):
ret Inspect.298; let Inspect.329 : {} = Struct {};
let Inspect.328 : Str = CallByName List.18 Inspect.203 Inspect.209 Inspect.329;
ret Inspect.328;
procedure List.1 (List.110): procedure Inspect.210 (Inspect.211, Inspect.212):
let List.635 : U64 = CallByName List.6 List.110; let Inspect.336 : Str = " ";
let List.636 : U64 = 0i64; let Inspect.331 : Str = CallByName Inspect.63 Inspect.211 Inspect.336;
let List.634 : Int1 = CallByName Bool.11 List.635 List.636; dec Inspect.336;
ret List.634; let Inspect.330 : Str = CallByName Inspect.213 Inspect.331 Inspect.212;
ret Inspect.330;
procedure List.18 (List.163, List.164, List.165): procedure Inspect.213 (Inspect.214, Inspect.212):
let List.623 : U64 = 0i64; let Inspect.334 : Str = CallByName Inspect.31 Inspect.212 Inspect.214;
let List.624 : U64 = CallByName List.6 List.163; ret Inspect.334;
let List.622 : Str = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622; procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.355 : Str = "\"";
let Inspect.354 : Str = CallByName Inspect.63 Inspect.251 Inspect.355;
dec Inspect.355;
let Inspect.352 : Str = CallByName Inspect.63 Inspect.354 Inspect.249;
let Inspect.353 : Str = "\"";
let Inspect.351 : Str = CallByName Inspect.63 Inspect.352 Inspect.353;
dec Inspect.353;
ret Inspect.351;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.315 : U8 = GetTagId Inspect.303;
switch Inspect.315:
case 0:
let Inspect.314 : Str = CallByName Inspect.204 Inspect.149 Inspect.303;
ret Inspect.314;
default:
let Inspect.314 : Str = CallByName Inspect.206 Inspect.149 Inspect.303;
ret Inspect.314;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.335 : Str = CallByName Inspect.250 Inspect.149 Inspect.303;
ret Inspect.335;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.43 (Inspect.202, Inspect.203):
let Inspect.341 : Int1 = CallByName List.1 Inspect.203;
if Inspect.341 then
inc Inspect.202;
let Inspect.343 : [C Str, C Str List Str] = TagId(0) Inspect.202;
let Inspect.342 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.343;
ret Inspect.342;
else
inc Inspect.203;
inc Inspect.202;
let Inspect.317 : [C Str, C Str List Str] = TagId(1) Inspect.202 Inspect.203;
let Inspect.316 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.317;
ret Inspect.316;
procedure Inspect.47 (Inspect.249):
let Inspect.347 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.347;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : Str = CallByName #Derived.0 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName #Derived.3 Inspect.308 Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.324 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.324;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure List.1 (List.113):
let List.638 : U64 = CallByName List.6 List.113;
let List.639 : U64 = 0i64;
let List.637 : Int1 = CallByName Bool.11 List.638 List.639;
ret List.637;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : Str = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.6 (#Attr.2): procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2; let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633; ret List.636;
procedure List.66 (#Attr.2, #Attr.3): procedure List.66 (#Attr.2, #Attr.3):
let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632; ret List.635;
procedure List.92 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): procedure List.95 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170: joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.627 : Int1 = CallByName Num.22 List.169 List.170; let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.627 then if List.630 then
let List.631 : Str = CallByName List.66 List.166 List.169; let List.634 : Str = CallByName List.66 List.169 List.172;
inc List.631; inc List.634;
let List.171 : Str = CallByName Inspect.206 List.167 List.631; let List.174 : Str = CallByName Inspect.210 List.170 List.634;
dec List.631; dec List.634;
let List.630 : U64 = 1i64; let List.633 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630; let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.625 List.166 List.171 List.168 List.629 List.170; jump List.628 List.169 List.174 List.171 List.632 List.173;
else else
dec List.166; dec List.169;
ret List.167; ret List.170;
in in
inc #Derived_gen.10; inc #Derived_gen.14;
jump List.625 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; jump List.628 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18;
procedure Num.22 (#Attr.2, #Attr.3): procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280; ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3): procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279; ret Num.281;
procedure Str.3 (#Attr.2, #Attr.3): procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232; ret Str.236;
procedure Test.0 (): procedure Test.0 ():
let Test.4 : Str = "foo"; let Test.4 : Str = "foo";

Some files were not shown because too many files have changed in this diff Show more