Merge remote-tracking branch 'origin/trunk' into bindgen-duplicates

This commit is contained in:
Richard Feldman 2022-07-17 13:23:51 -04:00
commit 7b102958e5
No known key found for this signature in database
GPG Key ID: 7E4127D1E4241798
71 changed files with 3550 additions and 2021 deletions

63
Cargo.lock generated
View File

@ -2105,6 +2105,22 @@ dependencies = [
"libc",
]
[[package]]
name = "mach_object"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6f2d7176b94027af58085a2c9d27c4e416586caba409c314569213901d6068"
dependencies = [
"bitflags",
"byteorder",
"lazy_static",
"libc",
"log",
"thiserror",
"time 0.3.11",
"uuid",
]
[[package]]
name = "malloc_buf"
version = "0.0.6"
@ -2460,6 +2476,15 @@ dependencies = [
"syn",
]
[[package]]
name = "num_threads"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
dependencies = [
"libc",
]
[[package]]
name = "objc"
version = "0.2.7"
@ -2499,6 +2524,18 @@ dependencies = [
"objc",
]
[[package]]
name = "object"
version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2"
dependencies = [
"crc32fast",
"flate2",
"indexmap",
"memchr",
]
[[package]]
name = "object"
version = "0.28.4"
@ -3734,10 +3771,12 @@ dependencies = [
"bumpalo",
"clap 3.2.8",
"iced-x86",
"mach_object",
"memmap2 0.5.4",
"object 0.29.0",
"object 0.26.2",
"roc_build",
"roc_collections",
"roc_error_macros",
"roc_mono",
"serde",
"target-lexicon",
@ -4853,11 +4892,23 @@ dependencies = [
"libc",
"standback",
"stdweb 0.4.20",
"time-macros",
"time-macros 0.1.1",
"version_check",
"winapi",
]
[[package]]
name = "time"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72c91f41dcb2f096c05f0873d667dceec1087ce5bcf984ec8ffb19acddbb3217"
dependencies = [
"itoa 1.0.2",
"libc",
"num_threads",
"time-macros 0.2.4",
]
[[package]]
name = "time-macros"
version = "0.1.1"
@ -4868,6 +4919,12 @@ dependencies = [
"time-macros-impl",
]
[[package]]
name = "time-macros"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792"
[[package]]
name = "time-macros-impl"
version = "0.1.2"
@ -5479,7 +5536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22dc83aadbdf97388de3211cb6f105374f245a3cf2a5c65a16776e7a087a8468"
dependencies = [
"byteorder",
"time",
"time 0.2.27",
"wasmer-types",
]

View File

@ -1268,7 +1268,7 @@ fn add_struct<S: Display>(
fn type_name(id: TypeId, types: &Types) -> String {
match types.get_type(id) {
RocType::Unit => "()".to_string(),
RocType::EmptyTagUnion => "()".to_string(), // In the future, this can be `!` - https://doc.rust-lang.org/std/primitive.never.html
RocType::EmptyTagUnion => "std::convert::Infallible".to_string(),
RocType::RocStr => "roc_std::RocStr".to_string(),
RocType::Bool => "bool".to_string(),
RocType::Num(RocNum::U8) => "u8".to_string(),

View File

@ -788,10 +788,6 @@ fn add_type_help<'a>(
// Result should always have exactly two tags: Ok and Err
debug_assert_eq!(tags.len(), 2);
// Both tags should have exactly 1 payload
debug_assert_eq!(tags[0].len(), 1);
debug_assert_eq!(tags[1].len(), 1);
let type_vars =
env.subs.get_subs_slice(alias_vars.type_variables());

View File

@ -287,13 +287,7 @@ pub fn build_file<'a>(
let link_start = SystemTime::now();
let problems = match (linking_strategy, link_type) {
(LinkingStrategy::Surgical, _) => {
roc_linker::link_preprocessed_host(target, &host_input_path, app_o_file, &binary_path)
.map_err(|err| {
todo!(
"gracefully handle failing to surgically link with error: {:?}",
err
);
})?;
roc_linker::link_preprocessed_host(target, &host_input_path, app_o_file, &binary_path);
problems
}
(LinkingStrategy::Additive, _) | (LinkingStrategy::Legacy, LinkType::None) => {
@ -399,8 +393,7 @@ fn spawn_rebuild_thread(
exported_symbols,
exported_closure_types,
target_valgrind,
)
.unwrap();
);
}
LinkingStrategy::Legacy => {
rebuild_host(

View File

@ -488,7 +488,7 @@ pub fn build(
let linking_strategy = if wasm_dev_backend {
LinkingStrategy::Additive
} else if !roc_linker::supported(&link_type, &triple)
} else if !roc_linker::supported(link_type, &triple)
|| matches.value_of(FLAG_LINKER) == Some("legacy")
{
LinkingStrategy::Legacy

View File

@ -34,11 +34,11 @@ interface Dict
##
## populationByCity =
## Dict.empty
## |> Dict.insert "London" 8_961_989
## |> Dict.insert "Philadelphia" 1_603_797
## |> Dict.insert "Shanghai" 24_870_895
## |> Dict.insert "Delhi" 16_787_941
## |> Dict.insert "Amsterdam" 872_680
## |> Dict.insert "London" 8_961_989
## |> Dict.insert "Philadelphia" 1_603_797
## |> Dict.insert "Shanghai" 24_870_895
## |> Dict.insert "Delhi" 16_787_941
## |> Dict.insert "Amsterdam" 872_680
##
## ### Accessing keys or values
##
@ -100,8 +100,8 @@ insert = \@Dict list, k, v ->
Ok index ->
list
|> List.set index (Pair k v)
|> @Dict
|> List.set index (Pair k v)
|> @Dict
len : Dict k v -> Nat
len = \@Dict list ->
@ -117,9 +117,9 @@ remove = \@Dict list, key ->
lastIndex = List.len list - 1
list
|> List.swap index lastIndex
|> List.dropLast
|> @Dict
|> List.swap index lastIndex
|> List.dropLast
|> @Dict
contains : Dict k v, k -> Bool
contains = \@Dict list, needle ->
@ -156,7 +156,7 @@ insertAll = \xs, @Dict ys ->
keepShared : Dict k v, Dict k v -> Dict k v
keepShared = \@Dict xs, ys ->
List.keepIf xs (\Pair k _ -> Dict.contains ys k)
|> @Dict
|> @Dict
# difference : Dict k v, Dict k v -> Dict k v
removeAll : Dict k v, Dict k v -> Dict k v
@ -169,8 +169,8 @@ removeAll = \xs, @Dict ys ->
insertFresh : Dict k v, k, v -> Dict k v
insertFresh = \@Dict list, k, v ->
list
|> List.append (Pair k v)
|> @Dict
|> List.append (Pair k v)
|> @Dict
insertIfVacant : Dict k v, k, v -> Dict k v
insertIfVacant = \dict, key, value ->

View File

@ -75,8 +75,8 @@ bool = \b -> custom \bytes, @Json {} ->
string = \s -> custom \bytes, @Json {} ->
List.append bytes (Num.toU8 '"')
|> List.concat (Str.toUtf8 s)
|> List.append (Num.toU8 '"')
|> List.concat (Str.toUtf8 s)
|> List.append (Num.toU8 '"')
list = \lst, encodeElem ->
custom \bytes, @Json {} ->
@ -90,10 +90,10 @@ record = \fields ->
writeRecord = \{ buffer, fieldsLeft }, { key, value } ->
bufferWithKeyValue =
List.append buffer (Num.toU8 '"')
|> List.concat (Str.toUtf8 key)
|> List.append (Num.toU8 '"')
|> List.append (Num.toU8 ':')
|> appendWith value (@Json {})
|> List.concat (Str.toUtf8 key)
|> List.append (Num.toU8 '"')
|> List.append (Num.toU8 ':')
|> appendWith value (@Json {})
bufferWithSuffix =
if fieldsLeft > 0 then
@ -123,13 +123,13 @@ tag = \name, payload ->
bytesHead =
List.append bytes (Num.toU8 '{')
|> List.append (Num.toU8 '"')
|> List.concat (Str.toUtf8 name)
|> List.append (Num.toU8 '"')
|> List.append (Num.toU8 ':')
|> List.append (Num.toU8 '[')
|> List.append (Num.toU8 '"')
|> List.concat (Str.toUtf8 name)
|> List.append (Num.toU8 '"')
|> List.append (Num.toU8 ':')
|> List.append (Num.toU8 '[')
{ buffer: bytesWithPayload } = List.walk payload { buffer: bytesHead, itemsLeft: List.len payload } writePayload
List.append bytesWithPayload (Num.toU8 ']')
|> List.append (Num.toU8 '}')
|> List.append (Num.toU8 '}')

View File

@ -246,8 +246,8 @@ set = \list, index, value ->
append : List a, a -> List a
append = \list, element ->
list
|> List.reserve 1
|> List.appendUnsafe element
|> List.reserve 1
|> List.appendUnsafe element
## Writes the element after the current last element unconditionally.
## In other words, it is assumed that
@ -837,8 +837,8 @@ intersperse = \list, sep ->
newList =
List.walk list init \acc, elem ->
acc
|> List.appendUnsafe elem
|> List.appendUnsafe sep
|> List.appendUnsafe elem
|> List.appendUnsafe sep
List.dropLast newList

View File

@ -38,8 +38,8 @@ single = \key ->
insert : Set k, k -> Set k
insert = \@Set dict, key ->
dict
|> Dict.insert key {}
|> @Set
|> Dict.insert key {}
|> @Set
len : Set k -> Nat
len = \@Set dict ->
@ -53,8 +53,8 @@ remove = \@Set dict, key ->
contains : Set k, k -> Bool
contains = \set, key ->
set
|> Set.toDict
|> Dict.contains key
|> Set.toDict
|> Dict.contains key
toList : Set k -> List k
toList = \@Set dict ->

View File

@ -172,11 +172,11 @@ countGraphemes : Str -> Nat
## **Performance Note:** This runs slightly faster than [Str.startsWith], so
## if you want to check whether a string begins with something that's representable
## in a single code point, you can use (for example) `Str.startsWithScalar '鹏'`
## instead of `Str.startsWithScalar "鹏"`. ('鹏' evaluates to the [U32]
## value `40527`.) This will not work for graphemes which take up multiple code
## points, however; `Str.startsWithScalar '👩‍👩‍👦‍👦'` would be a compiler error
## because 👩‍👩‍👦‍👦 takes up multiple code points and cannot be represented as a
## single [U32]. You'd need to use `Str.startsWithScalar "🕊"` instead.
## instead of `Str.startsWith "鹏"`. ('鹏' evaluates to the [U32] value `40527`.)
## This will not work for graphemes which take up multiple code points, however;
## `Str.startsWithScalar '👩‍👩‍👦‍👦'` would be a compiler error because 👩‍👩‍👦‍👦 takes up
## multiple code points and cannot be represented as a single [U32].
## You'd need to use `Str.startsWithScalar "🕊"` instead.
startsWithScalar : Str, U32 -> Bool
## Return a [List] of the [unicode scalar values](https://unicode.org/glossary/#unicode_scalar_value)

View File

@ -219,7 +219,6 @@ pub(crate) fn derive_to_encoder(
def_symbol: Symbol,
) -> DerivedBody {
let (body, body_type) = match key {
FlatEncodableKey::String => to_encoder_string(env, def_symbol),
FlatEncodableKey::List() => todo!(),
FlatEncodableKey::Set() => todo!(),
FlatEncodableKey::Dict() => todo!(),
@ -277,97 +276,6 @@ pub(crate) fn derive_to_encoder(
}
}
fn to_encoder_string(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
// Build \s -> Encode.string s
use Expr::*;
let s_sym = env.new_symbol("s");
// build `Encode.string s` type
// Str -[uls]-> Encoder fmt | fmt has EncoderFormatting
let encode_string_fn_var = env.import_encode_symbol(Symbol::ENCODE_STRING);
// Str -[clos]-> t1
let string_var_slice = VariableSubsSlice::insert_into_subs(env.subs, once(Variable::STR)); // TODO: consider caching this singleton slice
let encode_string_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let encoder_var = env.subs.fresh_unnamed_flex_var(); // t1
let this_encode_string_fn_var = synth_var(
env.subs,
Content::Structure(FlatType::Func(
string_var_slice,
encode_string_clos_var,
encoder_var,
)),
);
// Str -[uls]-> Encoder fmt | fmt has EncoderFormatting
// ~ Str -[clos]-> t1
env.unify(encode_string_fn_var, this_encode_string_fn_var);
// Encode.string : Str -[clos]-> Encoder fmt | fmt has EncoderFormatting
let encode_string_var = AbilityMember(Symbol::ENCODE_STRING, None, encode_string_fn_var);
let encode_record_fn = Box::new((
encode_string_fn_var,
Loc::at_zero(encode_string_var),
encode_string_clos_var,
encoder_var,
));
// Encode.string s
let encode_string_call = Call(
encode_record_fn,
vec![(Variable::STR, Loc::at_zero(Var(s_sym)))],
CalledVia::Space,
);
// Encode.custom \bytes, fmt -> Encode.appendWith bytes (Encode.string s) fmt
let (body, this_encoder_var) =
wrap_in_encode_custom(env, encode_string_call, encoder_var, s_sym, Variable::STR);
// Create fn_var for ambient capture; we fix it up below.
let fn_var = synth_var(env.subs, Content::Error);
// -[fn_name]->
let fn_name_labels = UnionLambdas::insert_into_subs(env.subs, once((fn_name, vec![])));
let fn_clos_var = synth_var(
env.subs,
Content::LambdaSet(LambdaSet {
solved: fn_name_labels,
recursion_var: OptVariable::NONE,
unspecialized: SubsSlice::default(),
ambient_function: fn_var,
}),
);
// Str -[fn_name]-> (typeof Encode.record [ .. ] = Encoder fmt)
env.subs.set_content(
fn_var,
Content::Structure(FlatType::Func(
string_var_slice,
fn_clos_var,
this_encoder_var,
)),
);
// \rcd -[fn_name]-> Encode.record [ { key: .., value: .. }, .. ]
let clos = Closure(ClosureData {
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_encoder_var,
name: fn_name,
captured_symbols: vec![],
recursive: Recursive::NotRecursive,
arguments: vec![(
Variable::STR,
AnnotatedMark::known_exhaustive(),
Loc::at_zero(Pattern::Identifier(s_sym)),
)],
loc_body: Box::new(Loc::at_zero(body)),
});
(clos, fn_var)
}
fn to_encoder_record(
env: &mut Env<'_>,
record_var: Variable,

View File

@ -14,7 +14,6 @@ pub enum FlatEncodable {
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
pub enum FlatEncodableKey {
String,
List(/* takes one variable */),
Set(/* takes one variable */),
Dict(/* takes two variables */),
@ -26,7 +25,6 @@ pub enum FlatEncodableKey {
impl FlatEncodableKey {
pub(crate) fn debug_name(&self) -> String {
match self {
FlatEncodableKey::String => "string".to_string(),
FlatEncodableKey::List() => "list".to_string(),
FlatEncodableKey::Set() => "set".to_string(),
FlatEncodableKey::Dict() => "dict".to_string(),
@ -84,7 +82,7 @@ impl FlatEncodable {
Symbol::LIST_LIST => Ok(Key(FlatEncodableKey::List())),
Symbol::SET_SET => Ok(Key(FlatEncodableKey::Set())),
Symbol::DICT_DICT => Ok(Key(FlatEncodableKey::Dict())),
Symbol::STR_STR => Ok(Key(FlatEncodableKey::String)),
Symbol::STR_STR => Ok(Immediate(Symbol::ENCODE_STRING)),
_ => Err(Underivable),
},
FlatType::Record(fields, ext) => {
@ -134,19 +132,19 @@ impl FlatEncodable {
FlatType::Func(..) => Err(Underivable),
},
Content::Alias(sym, _, real_var, _) => match sym {
Symbol::NUM_U8 => Ok(Immediate(Symbol::ENCODE_U8)),
Symbol::NUM_U16 => Ok(Immediate(Symbol::ENCODE_U16)),
Symbol::NUM_U32 => Ok(Immediate(Symbol::ENCODE_U32)),
Symbol::NUM_U64 => Ok(Immediate(Symbol::ENCODE_U64)),
Symbol::NUM_U128 => Ok(Immediate(Symbol::ENCODE_U128)),
Symbol::NUM_I8 => Ok(Immediate(Symbol::ENCODE_I8)),
Symbol::NUM_I16 => Ok(Immediate(Symbol::ENCODE_I16)),
Symbol::NUM_I32 => Ok(Immediate(Symbol::ENCODE_I32)),
Symbol::NUM_I64 => Ok(Immediate(Symbol::ENCODE_I64)),
Symbol::NUM_I128 => Ok(Immediate(Symbol::ENCODE_I128)),
Symbol::NUM_DEC => Ok(Immediate(Symbol::ENCODE_DEC)),
Symbol::NUM_F32 => Ok(Immediate(Symbol::ENCODE_F32)),
Symbol::NUM_F64 => Ok(Immediate(Symbol::ENCODE_F64)),
Symbol::NUM_U8 | Symbol::NUM_UNSIGNED8 => Ok(Immediate(Symbol::ENCODE_U8)),
Symbol::NUM_U16 | Symbol::NUM_UNSIGNED16 => Ok(Immediate(Symbol::ENCODE_U16)),
Symbol::NUM_U32 | Symbol::NUM_UNSIGNED32 => Ok(Immediate(Symbol::ENCODE_U32)),
Symbol::NUM_U64 | Symbol::NUM_UNSIGNED64 => Ok(Immediate(Symbol::ENCODE_U64)),
Symbol::NUM_U128 | Symbol::NUM_UNSIGNED128 => Ok(Immediate(Symbol::ENCODE_U128)),
Symbol::NUM_I8 | Symbol::NUM_SIGNED8 => Ok(Immediate(Symbol::ENCODE_I8)),
Symbol::NUM_I16 | Symbol::NUM_SIGNED16 => Ok(Immediate(Symbol::ENCODE_I16)),
Symbol::NUM_I32 | Symbol::NUM_SIGNED32 => Ok(Immediate(Symbol::ENCODE_I32)),
Symbol::NUM_I64 | Symbol::NUM_SIGNED64 => Ok(Immediate(Symbol::ENCODE_I64)),
Symbol::NUM_I128 | Symbol::NUM_SIGNED128 => Ok(Immediate(Symbol::ENCODE_I128)),
Symbol::NUM_DEC | Symbol::NUM_DECIMAL => Ok(Immediate(Symbol::ENCODE_DEC)),
Symbol::NUM_F32 | Symbol::NUM_BINARY32 => Ok(Immediate(Symbol::ENCODE_F32)),
Symbol::NUM_F64 | Symbol::NUM_BINARY64 => Ok(Immediate(Symbol::ENCODE_F64)),
// TODO: I believe it is okay to unwrap opaques here because derivers are only used
// by the backend, and the backend treats opaques like structural aliases.
_ => Self::from_var(subs, real_var),

View File

@ -322,6 +322,7 @@ pub fn fmt_body<'a, 'buf>(
) {
pattern.format_with_options(buf, Parens::InApply, Newlines::No, indent);
buf.push_str(" =");
if body.is_multiline() {
match body {
Expr::SpaceBefore(sub_def, spaces) => {
@ -345,6 +346,22 @@ pub fn fmt_body<'a, 'buf>(
);
}
}
Expr::BinOps(_, _) => {
// Binop chains always get a newline. Otherwise you can have things like:
//
// something = foo
// |> bar baz
//
// By always inserting a newline, this becomes:
//
// something =
// foo
// |> bar baz
//
// This makes it clear what the binop is applying to!
buf.newline();
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent + INDENT);
}
_ => {
buf.spaces(1);
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent);

View File

@ -532,17 +532,14 @@ fn fmt_binops<'a, 'buf>(
|| (&loc_right_side.value).is_multiline()
|| lefts.iter().any(|(expr, _)| expr.value.is_multiline());
let mut curr_indent = indent;
for (loc_left_side, loc_binop) in lefts {
let binop = loc_binop.value;
loc_left_side.format_with_options(buf, apply_needs_parens, Newlines::No, curr_indent);
loc_left_side.format_with_options(buf, apply_needs_parens, Newlines::No, indent);
if is_multiline {
buf.ensure_ends_with_newline();
curr_indent = indent + INDENT;
buf.indent(curr_indent);
buf.indent(indent);
} else {
buf.spaces(1);
}
@ -552,13 +549,7 @@ fn fmt_binops<'a, 'buf>(
buf.spaces(1);
}
let next_indent = if is_multiline {
indent + INDENT
} else {
indent
};
loc_right_side.format_with_options(buf, apply_needs_parens, Newlines::Yes, next_indent);
loc_right_side.format_with_options(buf, apply_needs_parens, Newlines::Yes, indent);
}
fn format_spaces<'a, 'buf>(
@ -760,10 +751,7 @@ fn fmt_when<'a, 'buf>(
} else {
if is_multiline_patterns {
buf.ensure_ends_with_newline();
// Indent an extra level for the `|`;
// otherwise it'll be at the start of the line,
// and will be incorrectly parsed as a pattern
buf.indent(indent + INDENT + INDENT);
buf.indent(indent + INDENT);
buf.push('|');
} else {
buf.push_str(" |");

View File

@ -3108,7 +3108,7 @@ mod test_fmt {
r#"
if
1
== 2
== 2
then
"yes"
else
@ -3385,8 +3385,7 @@ mod test_fmt {
r#"
when b is
# look at cases
1 ->
# when 1
1 -> # when 1
1
# important
@ -3406,7 +3405,7 @@ mod test_fmt {
r#"
when 0 is
1 # comment
| 2 -> "a"
| 2 -> "a"
_ -> "b"
"#
@ -3506,21 +3505,21 @@ mod test_fmt {
r#"
when b is
1
| 2
| 3 ->
| 2
| 3 ->
4
5 | 6 | 7 ->
8
9
| 10 -> 11
| 10 -> 11
12 | 13 ->
when c is
14 | 15 -> 16
17
| 18 -> 19
| 18 -> 19
20 -> 21
"#
@ -3543,7 +3542,7 @@ mod test_fmt {
when b is
3 -> 4
9
| 8 -> 9
| 8 -> 9
"#
),
);
@ -3607,7 +3606,7 @@ mod test_fmt {
when
1
+ 1
+ 1
is
2 ->
x
@ -3644,7 +3643,7 @@ mod test_fmt {
when
2
+ 2
+ 2
is
4 ->
x
@ -3656,6 +3655,31 @@ mod test_fmt {
);
}
#[test]
fn multi_line_when_branch() {
expr_formats_to(
indoc!(
r#"
when x is
Foo -> bar
"arg1" "arg2"
Bar -> 2
"#
),
indoc!(
r#"
when x is
Foo ->
bar
"arg1"
"arg2"
Bar -> 2
"#
),
);
}
#[test]
fn single_line_when_patterns() {
expr_formats_same(indoc!(
@ -3874,8 +3898,8 @@ mod test_fmt {
r#"
if
True
== False
== True
== False
== True
then
False
else
@ -3901,8 +3925,8 @@ mod test_fmt {
r#"
if
False
== False
== False
== False
== False
then
"true"
else
@ -3960,8 +3984,8 @@ mod test_fmt {
r#"
if
(1 == 1)
&& (2 == 1)
&& (3 == 2)
&& (2 == 1)
&& (3 == 2)
then
"true"
else
@ -3973,8 +3997,9 @@ mod test_fmt {
#[test]
fn multiline_binop_with_comments() {
expr_formats_same(indoc!(
r#"
expr_formats_to(
indoc!(
r#"
x = 1
+ 1 # comment 1
- 1 # comment 2
@ -3982,39 +4007,87 @@ mod test_fmt {
x
"#
));
),
indoc!(
r#"
x =
1
+ 1 # comment 1
- 1 # comment 2
* 1 # comment 3
expr_formats_same(indoc!(
r#"
x
"#
),
);
expr_formats_to(
indoc!(
r#"
x = 1
+ 1 # comment 1
* 1 # comment 2
x
"#
));
),
indoc!(
r#"
x =
1
+ 1 # comment 1
* 1 # comment 2
expr_formats_same(indoc!(
r#"
x
"#
),
);
expr_formats_to(
indoc!(
r#"
x = 1
+ 1 # comment
x
"#
));
),
indoc!(
r#"
x =
1
+ 1 # comment
expr_formats_same(indoc!(
r#"
x
"#
),
);
expr_formats_to(
indoc!(
r#"
x = 1
* 1
+ 1 # comment
x
"#
));
),
indoc!(
r#"
x =
1
* 1
+ 1 # comment
expr_formats_same(indoc!(
r#"
x
"#
),
);
expr_formats_to(
indoc!(
r#"
x = 1
- 1
* 1
@ -4022,7 +4095,19 @@ mod test_fmt {
x
"#
));
),
indoc!(
r#"
x =
1
- 1
* 1
+ 1
x
"#
),
);
}
#[test]
@ -4031,12 +4116,12 @@ mod test_fmt {
r#"
if
x
+ 1 # comment 1
> 0 # comment 2
+ 1 # comment 1
> 0 # comment 2
then
y
* 2 # comment 3
< 1 # comment 4
* 2 # comment 3
< 1 # comment 4
else
42
"#
@ -4045,35 +4130,66 @@ mod test_fmt {
#[test]
fn multiline_binop_when_with_comments() {
expr_formats_same(indoc!(
r#"
expr_formats_to(
indoc!(
r#"
when
x
+ 1 # comment 1
> 0 # comment 2
+ 1 # comment 1
> 0 # comment 2
is
y ->
3
* 2 # comment 3
< 1 # comment 4
* 2 # comment 3
< 1 # comment 4
z ->
4
/ 5 # comment 5
< 1 # comment 6
/ 5 # comment 5
< 1 # comment 6
46 # first pattern comment
| 95 # alternative comment 1
| 126 # alternative comment 2
| 150 -> # This comment goes after the ->
| 95 # alternative comment 1
| 126 # alternative comment 2
| 150 -> # This comment came after the ->
# This comment is for the expr
foo bar
|> Result.withDefault "" # one last comment
foo bar
|> Result.withDefault "" # one last comment
_ ->
42
"#
));
),
indoc!(
r#"
when
x
+ 1 # comment 1
> 0 # comment 2
is
y ->
3
* 2 # comment 3
< 1 # comment 4
z ->
4
/ 5 # comment 5
< 1 # comment 6
46 # first pattern comment
| 95 # alternative comment 1
| 126 # alternative comment 2
| 150 -> # This comment came after the ->
# This comment is for the expr
foo bar
|> Result.withDefault "" # one last comment
_ ->
42
"#
),
);
}
#[test]
@ -4167,22 +4283,33 @@ mod test_fmt {
expr_formats_same(indoc!(
r#"
isLast
&& isEmpty
&& isLoaded
&& isEmpty
&& isLoaded
"#
));
}
#[test]
fn multi_line_binary_op_2() {
expr_formats_same(indoc!(
r#"
expr_formats_to(
indoc!(
r#"
x = 1
< 2
f x
"#
));
),
indoc!(
r#"
x =
1
< 2
f x
"#
),
);
}
#[test]
@ -4199,9 +4326,9 @@ mod test_fmt {
indoc!(
r#"
1
* 2
/ 3
// 4
* 2
/ 3
// 4
"#
),
);
@ -4220,9 +4347,9 @@ mod test_fmt {
indoc!(
r#"
2
% 3
// 5
+ 7
% 3
// 5
+ 7
"#
),
);
@ -4240,8 +4367,8 @@ mod test_fmt {
indoc!(
r#"
isGreenLight
&& isRedLight
&& isYellowLight
&& isRedLight
&& isYellowLight
"#
),
);
@ -4252,8 +4379,8 @@ mod test_fmt {
expr_formats_same(indoc!(
r#"
output
|> List.set (offset + 0) b
|> List.set (offset + 1) a
|> List.set (offset + 0) b
|> List.set (offset + 1) a
"#
));
}
@ -4275,9 +4402,9 @@ mod test_fmt {
expr_formats_same(indoc!(
r#"
shout
|> List.map
xs
(\i -> i)
|> List.map
xs
(\i -> i)
"#
));
}
@ -4287,10 +4414,10 @@ mod test_fmt {
expr_formats_same(indoc!(
r#"
shout
|> List.map
xs
(\i -> i)
|> List.join
|> List.map
xs
(\i -> i)
|> List.join
"#
));
}
@ -4316,15 +4443,15 @@ mod test_fmt {
r#"
example = \model ->
model
|> withModel
(\result ->
when result is
Err _ ->
Err {}
|> withModel
(\result ->
when result is
Err _ ->
Err {}
Ok val ->
Ok {}
)
Ok val ->
Ok {}
)
example
"#
@ -4352,15 +4479,15 @@ mod test_fmt {
r#"
example = \model ->
model
|> withModel
(\result ->
when result is
Err _ ->
Err {}
|> withModel
(\result ->
when result is
Err _ ->
Err {}
Ok val ->
Ok {}
)
Ok val ->
Ok {}
)
example
"#

View File

@ -11,7 +11,7 @@ use roc_derive::SharedDerivedModule;
use roc_error_macros::internal_error;
use roc_module::symbol::ModuleId;
use roc_solve::solve::{compact_lambda_sets_of_vars, Phase, Pools};
use roc_types::subs::{Content, FlatType, LambdaSet};
use roc_types::subs::{get_member_lambda_sets_at_region, Content, FlatType, LambdaSet};
use roc_types::subs::{ExposedTypesStorageSubs, Subs, Variable};
use roc_unify::unify::{unify as unify_unify, Mode, Unified};
@ -160,6 +160,86 @@ impl Phase for LatePhase<'_> {
}
}
}
#[inline(always)]
fn get_and_copy_ability_member_ambient_function(
&self,
ability_member: roc_module::symbol::Symbol,
region: u8,
target_subs: &mut Subs,
) -> Variable {
match self.abilities {
AbilitiesView::Module(abilities_store) => {
// No option other than that the var must be in our module store.
// Even if the specialization lambda set comes from another module,
// we should have taken care to import it before starting solving in this module.
let member_def = abilities_store
.member_def(ability_member)
.unwrap_or_else(|| {
internal_error!(
"{:?} is not resolved, or not an ability member!",
ability_member
)
});
let member_var = member_def.signature_var();
let region_lset = get_member_lambda_sets_at_region(target_subs, member_var, region);
let LambdaSet {
ambient_function, ..
} = target_subs.get_lambda_set(region_lset);
ambient_function
}
AbilitiesView::World(wa) => {
let member_home = ability_member.module_id();
let mut world = wa.world.write().unwrap();
let (module_store, module_types) = world.get_mut(&member_home).unwrap();
let member_def = module_store.member_def(ability_member).unwrap_or_else(|| {
internal_error!(
"{:?} is not resolved, or not an ability member!",
ability_member
)
});
let member_var = member_def.signature_var();
let storage_member_var = module_types
.stored_ability_member_vars
.get(&member_var)
.unwrap();
let storage_lambda_set_var = get_member_lambda_sets_at_region(
module_types.storage_subs.as_inner(),
*storage_member_var,
region,
);
let LambdaSet {
ambient_function, ..
} = module_types
.storage_subs
.as_inner()
.get_lambda_set(storage_lambda_set_var);
let copied = module_types
.storage_subs
// TODO: I think this is always okay, but revisit later when we're in a more
// stable position to see if we can get rid of the bookkeeping done as a result
// of this.
.export_variable_to_directly_to_use_site(target_subs, ambient_function);
let our_ambient_function_var = copied.variable;
instantiate_rigids(target_subs, our_ambient_function_var);
debug_assert!(matches!(
target_subs.get_content_without_compacting(our_ambient_function_var),
Content::Structure(FlatType::Func(..))
));
our_ambient_function_var
}
}
}
}
/// Unifies two variables and performs lambda set compaction.

View File

@ -4260,9 +4260,11 @@ fn run_solve<'a>(
let mut solved_subs = solved_subs;
let exposed_types = roc_solve::module::exposed_types_storage_subs(
module_id,
&mut solved_subs,
&exposed_vars_by_symbol,
&solved_specializations,
&abilities_store,
);
let solved_module = SolvedModule {

View File

@ -5,8 +5,8 @@ quicksort = \list, low, high ->
when partition low high list is
Pair partitionIndex partitioned ->
partitioned
|> quicksort low (partitionIndex - 1)
|> quicksort (partitionIndex + 1) high
|> quicksort low (partitionIndex - 1)
|> quicksort (partitionIndex + 1) high
swap : Nat, Nat, List a -> List a
@ -14,8 +14,8 @@ swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
list
|> List.set i atJ
|> List.set j atI
|> List.set i atJ
|> List.set j atI
_ ->
[]

View File

@ -7,8 +7,8 @@ quicksort = \originalList ->
when partition low high list is
Pair partitionIndex partitioned ->
partitioned
|> quicksortHelp low (partitionIndex - 1)
|> quicksortHelp (partitionIndex + 1) high
|> quicksortHelp low (partitionIndex - 1)
|> quicksortHelp (partitionIndex + 1) high
else
list
@ -18,8 +18,8 @@ quicksort = \originalList ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
list
|> List.set i atJ
|> List.set j atI
|> List.set i atJ
|> List.set j atI
_ ->
[]

View File

@ -2085,7 +2085,7 @@ mod when {
}
}
/// Parsing alternative patterns in when branches.
/// Parsing alternative patterns in `when` branches.
fn branch_alternatives<'a>(
min_indent: u32,
options: ExprParseOptions,
@ -2180,7 +2180,7 @@ mod when {
let parser = sep_by1(
word1(b'|', EWhen::Bar),
branch_single_alternative(pattern_indent + 1),
branch_single_alternative(pattern_indent),
);
match parser.parse(arena, state) {

View File

@ -40,9 +40,37 @@ When(
],
),
@43-48 SpaceBefore(
SpaceAfter(
StrLiteral(
PlainLine(
"bar",
),
),
[
Newline,
],
),
[
Newline,
],
),
@51-56 StrLiteral(
PlainLine(
"baz",
),
),
],
value: @60-61 Num(
"2",
),
guard: None,
},
WhenBranch {
patterns: [
@63-70 SpaceBefore(
StrLiteral(
PlainLine(
"bar",
"stuff",
),
),
[
@ -50,8 +78,8 @@ When(
],
),
],
value: @52-53 Num(
"2",
value: @74-75 Num(
"4",
),
guard: None,
},

View File

@ -1,4 +1,6 @@
when x is
"blah" | "blop" -> 1
"foo" |
"bar" -> 2
"bar"
|"baz" -> 2
"stuff" -> 4

View File

@ -553,6 +553,34 @@ impl ObligationCache<'_> {
}
Erroneous(_) => return Err(var),
},
#[rustfmt::skip]
Alias(
Symbol::NUM_U8 | Symbol::NUM_UNSIGNED8
| Symbol::NUM_U16 | Symbol::NUM_UNSIGNED16
| Symbol::NUM_U32 | Symbol::NUM_UNSIGNED32
| Symbol::NUM_U64 | Symbol::NUM_UNSIGNED64
| Symbol::NUM_U128 | Symbol::NUM_UNSIGNED128
| Symbol::NUM_I8 | Symbol::NUM_SIGNED8
| Symbol::NUM_I16 | Symbol::NUM_SIGNED16
| Symbol::NUM_I32 | Symbol::NUM_SIGNED32
| Symbol::NUM_I64 | Symbol::NUM_SIGNED64
| Symbol::NUM_I128 | Symbol::NUM_SIGNED128
| Symbol::NUM_NAT | Symbol::NUM_NATURAL
| Symbol::NUM_F32 | Symbol::NUM_BINARY32
| Symbol::NUM_F64 | Symbol::NUM_BINARY64
| Symbol::NUM_DEC | Symbol::NUM_DECIMAL,
_,
_,
_,
) => {
// yes
}
Alias(
Symbol::NUM_NUM | Symbol::NUM_INTEGER | Symbol::NUM_FLOATINGPOINT,
_,
real_var,
_,
) => stack.push(*real_var),
Alias(name, _, _, AliasKind::Opaque) => {
let opaque = *name;
if self
@ -562,27 +590,6 @@ impl ObligationCache<'_> {
return Err(var);
}
}
Alias(
Symbol::NUM_U8
| Symbol::NUM_U16
| Symbol::NUM_U32
| Symbol::NUM_U64
| Symbol::NUM_U128
| Symbol::NUM_I8
| Symbol::NUM_I16
| Symbol::NUM_I32
| Symbol::NUM_I64
| Symbol::NUM_I128
| Symbol::NUM_NAT
| Symbol::NUM_F32
| Symbol::NUM_F64
| Symbol::NUM_DEC,
_,
_,
_,
) => {
// yes
}
Alias(_, arguments, real_type_var, _) => {
push_var_slice!(arguments.all_variables());
stack.push(*real_type_var);

View File

@ -105,27 +105,28 @@ pub fn run_solve(
/// Copies exposed types and all ability specializations, which may be implicitly exposed.
pub fn exposed_types_storage_subs(
home: ModuleId,
solved_subs: &mut Solved<Subs>,
exposed_vars_by_symbol: &[(Symbol, Variable)],
solved_specializations: &ResolvedSpecializations,
abilities_store: &AbilitiesStore,
) -> ExposedTypesStorageSubs {
let subs = solved_subs.inner_mut();
let mut storage_subs = StorageSubs::new(Subs::new());
let mut stored_vars_by_symbol = VecMap::with_capacity(exposed_vars_by_symbol.len());
let mut stored_specialization_lambda_set_vars =
VecMap::with_capacity(solved_specializations.len());
for (symbol, var) in exposed_vars_by_symbol.iter() {
let new_var = storage_subs.import_variable_from(subs, *var).variable;
stored_vars_by_symbol.insert(*symbol, new_var);
}
let mut stored_specialization_lambda_set_vars =
VecMap::with_capacity(solved_specializations.len());
for (_, member_specialization) in solved_specializations.iter() {
for (_, &specialization_lset_var) in member_specialization.specialization_lambda_sets.iter()
{
let specialization_lset_ambient_function_var = subs
.get_lambda_set(specialization_lset_var)
.ambient_function;
for (_, &lset_var) in member_specialization.specialization_lambda_sets.iter() {
let specialization_lset_ambient_function_var =
subs.get_lambda_set(lset_var).ambient_function;
// Import the ambient function of this specialization lambda set; that will import the
// lambda set as well. The ambient function is needed for the lambda set compaction
@ -144,14 +145,29 @@ pub fn exposed_types_storage_subs(
roc_types::subs::SubsFmtContent(content, storage_subs.as_inner())
),
};
stored_specialization_lambda_set_vars
.insert(specialization_lset_var, imported_lset_var);
stored_specialization_lambda_set_vars.insert(lset_var, imported_lset_var);
}
}
// Store the regioned lambda sets of the ability members defined in this module.
let stored_ability_member_vars = abilities_store
.root_ability_members()
.iter()
.filter_map(|(member, data)| {
if member.module_id() == home {
let var = data.signature_var();
let imported_var = storage_subs.import_variable_from(subs, var).variable;
Some((var, imported_var))
} else {
None
}
})
.collect();
ExposedTypesStorageSubs {
storage_subs,
stored_vars_by_symbol,
stored_specialization_lambda_set_vars,
stored_ability_member_vars,
}
}

View File

@ -22,9 +22,9 @@ use roc_module::symbol::{ModuleId, Symbol};
use roc_problem::can::CycleEntry;
use roc_region::all::{Loc, Region};
use roc_types::subs::{
self, AliasVariables, Content, Descriptor, FlatType, GetSubsSlice, LambdaSet, Mark,
OptVariable, Rank, RecordFields, Subs, SubsIndex, SubsSlice, UlsOfVar, UnionLabels,
UnionLambdas, UnionTags, Variable, VariableSubsSlice,
self, get_member_lambda_sets_at_region, AliasVariables, Content, Descriptor, FlatType,
GetSubsSlice, LambdaSet, Mark, OptVariable, Rank, RecordFields, Subs, SubsIndex, SubsSlice,
UlsOfVar, UnionLabels, UnionLambdas, UnionTags, Variable, VariableSubsSlice,
};
use roc_types::types::Type::{self, *};
use roc_types::types::{
@ -526,6 +526,8 @@ impl Pools {
/// What phase in the compiler is reaching out to solve types.
/// This is important to distinguish subtle differences in the behavior of the solving algorithm.
//
// TODO the APIs of this trait suck, this needs a nice cleanup.
pub trait Phase {
/// The regular type-solving phase, or during some later phase of compilation.
/// During the solving phase we must anticipate that some information is still unknown and react to
@ -536,12 +538,23 @@ pub trait Phase {
where
F: FnMut(&AbilitiesStore) -> T;
/// Given a known lambda set's ambient function in an external module, copy that ambient
/// function into the given subs.
fn copy_lambda_set_ambient_function_to_home_subs(
&self,
external_lambda_set_var: Variable,
external_module_id: ModuleId,
home_subs: &mut Subs,
) -> Variable;
/// Find the ambient function var at a given region for an ability member definition (not a
/// specialization!), and copy that into the given subs.
fn get_and_copy_ability_member_ambient_function(
&self,
ability_member: Symbol,
region: u8,
home_subs: &mut Subs,
) -> Variable;
}
struct SolvePhase<'a> {
@ -572,6 +585,35 @@ impl Phase for SolvePhase<'_> {
} = home_subs.get_lambda_set(external_lambda_set_var);
ambient_function
}
fn get_and_copy_ability_member_ambient_function(
&self,
ability_member: Symbol,
region: u8,
home_subs: &mut Subs,
) -> Variable {
// During solving we're only aware of our module's abilities store, the var must
// be in our module store. Even if the specialization lambda set comes from another
// module, we should have taken care to import it before starting solving in this module.
let member_def = self
.abilities_store
.member_def(ability_member)
.unwrap_or_else(|| {
internal_error!(
"{:?} is not resolved, or not an ability member!",
ability_member
)
});
let member_var = member_def.signature_var();
let region_lset = get_member_lambda_sets_at_region(home_subs, member_var, region);
let LambdaSet {
ambient_function, ..
} = home_subs.get_lambda_set(region_lset);
ambient_function
}
}
#[derive(Clone)]
@ -2179,6 +2221,7 @@ fn compact_lambda_set<P: Phase>(
enum SpecializationTypeKey {
Opaque(Symbol),
Derived(DeriveKey),
Immediate(Symbol),
}
enum SpecializeDecision {
@ -2190,13 +2233,17 @@ fn make_specialization_decision(subs: &Subs, var: Variable) -> SpecializeDecisio
use Content::*;
use SpecializationTypeKey::*;
match subs.get_content_without_compacting(var) {
Structure(_) | Alias(_, _, _, AliasKind::Structural) => {
Alias(opaque, _, _, AliasKind::Opaque) if opaque.module_id() != ModuleId::NUM => {
SpecializeDecision::Specialize(Opaque(*opaque))
}
Structure(_) | Alias(_, _, _, _) => {
// This is a structural type, find the name of the derived ability function it
// should use.
match roc_derive_key::Derived::encoding(subs, var) {
Ok(derived) => match derived {
roc_derive_key::Derived::Immediate(_) => {
todo!("deal with lambda set extraction from immediates")
roc_derive_key::Derived::Immediate(imm) => {
SpecializeDecision::Specialize(Immediate(imm))
// todo!("deal with lambda set extraction from immediates")
}
roc_derive_key::Derived::Key(derive_key) => {
SpecializeDecision::Specialize(Derived(derive_key))
@ -2214,7 +2261,6 @@ fn make_specialization_decision(subs: &Subs, var: Variable) -> SpecializeDecisio
}
}
}
Alias(opaque, _, _, AliasKind::Opaque) => SpecializeDecision::Specialize(Opaque(*opaque)),
Error => SpecializeDecision::Drop,
FlexAbleVar(_, _)
| RigidAbleVar(..)
@ -2295,6 +2341,18 @@ fn get_specialization_lambda_set_ambient_function<P: Phase>(
Ok(specialized_ambient)
}
SpecializationTypeKey::Immediate(imm) => {
// Immediates are like opaques in that we can simply look up their type definition in
// the ability store, there is nothing new to synthesize.
//
// THEORY: if something can become an immediate, it will always be available in the
// local ability store, because the transformation is local (?)
let immediate_lambda_set_at_region =
phase.get_and_copy_ability_member_ambient_function(imm, lset_region, subs);
Ok(immediate_lambda_set_at_region)
}
}
}

View File

@ -515,25 +515,7 @@ fn immediates() {
check_immediate(v!(DEC), Symbol::ENCODE_DEC);
check_immediate(v!(F32), Symbol::ENCODE_F32);
check_immediate(v!(F64), Symbol::ENCODE_F64);
}
#[test]
fn string() {
derive_test(v!(STR), |golden| {
assert_snapshot!(golden, @r###"
# derived for Str
# Str -[[toEncoder_string(0)]]-> Encoder fmt | fmt has EncoderFormatting
# Str -[[toEncoder_string(0)]]-> (List U8, fmt -[[custom(2) Str]]-> List U8) | fmt has EncoderFormatting
# Specialization lambda sets:
# @<1>: [[toEncoder_string(0)]]
# @<2>: [[custom(2) Str]]
#Derived.toEncoder_string =
\#Derived.s ->
Encode.custom \#Derived.bytes, #Derived.fmt ->
Encode.appendWith #Derived.bytes (Encode.string #Derived.s) #Derived.fmt
"###
)
})
check_immediate(v!(STR), Symbol::ENCODE_STRING);
}
#[test]

View File

@ -25,8 +25,8 @@ const ROC_LIST_MAP: &str = indoc::indoc!(
r#"
app "bench" provides [main] to "./platform"
main : List I64 -> Nat
main = \list ->
main : List I64 -> Nat
main = \list ->
list
|> List.map (\x -> x + 2)
|> List.len
@ -37,11 +37,11 @@ const ROC_LIST_MAP_WITH_INDEX: &str = indoc::indoc!(
r#"
app "bench" provides [main] to "./platform"
main : List I64 -> Nat
main = \list ->
main : List I64 -> Nat
main = \list ->
list
|> List.mapWithIndex (\x, _ -> x + 2)
|> List.len
|> List.mapWithIndex (\x, _ -> x + 2)
|> List.len
"#
);

View File

@ -404,26 +404,73 @@ fn to_encoder_encode_custom_has_capture() {
)
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn encode_derived_string() {
assert_evals_to!(
indoc!(
r#"
app "test"
imports [Encode.{ toEncoder }, Json]
provides [main] to "./platform"
mod encode_immediate {
#[cfg(feature = "gen-llvm")]
use crate::helpers::llvm::assert_evals_to;
main =
result = Str.fromUtf8 (Encode.toBytes "foo" Json.format)
when result is
Ok s -> s
_ -> "<bad>"
"#
),
RocStr::from("\"foo\""),
RocStr
)
#[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))]
use indoc::indoc;
#[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))]
use roc_std::RocStr;
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn string() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode.{ toEncoder }, Json] provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes "foo" Json.format) is
Ok s -> s
_ -> "<bad>"
"#
),
RocStr::from("\"foo\""),
RocStr
)
}
macro_rules! num_immediate {
($($num:expr, $typ:ident)*) => {$(
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn $typ() {
assert_evals_to!(
&format!(indoc!(
r#"
app "test" imports [Encode.{{ toEncoder }}, Json] provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes {}{} Json.format) is
Ok s -> s
_ -> "<bad>"
"#
), $num, stringify!($typ)),
RocStr::from(format!(r#"{}"#, $num).as_str()),
RocStr
)
}
)*}
}
num_immediate! {
17, i8
17, i16
17, i32
17, i64
17, i128
17, u8
17, u16
17, u32
17, u64
17, u128
// 17.23, f32 TODO https://github.com/rtfeldman/roc/issues/3522
17.23, f64
// 17.23, dec TODO https://github.com/rtfeldman/roc/issues/3522
}
}
#[test]

View File

@ -3,19 +3,6 @@ procedure #Derived.0 (#Derived.1):
let #Derived_gen.0 : {Str} = CallByName Encode.22 #Derived_gen.1;
ret #Derived_gen.0;
procedure #Derived.10 (#Derived.11):
let #Derived_gen.29 : {Str} = Struct {#Derived.11};
let #Derived_gen.28 : {Str} = CallByName Encode.22 #Derived_gen.29;
ret #Derived_gen.28;
procedure #Derived.12 (#Derived.13, #Derived.14, #Attr.12):
let #Derived.11 : Str = StructAtIndex 0 #Attr.12;
inc #Derived.11;
dec #Attr.12;
let #Derived_gen.32 : {Str} = CallByName Json.17 #Derived.11;
let #Derived_gen.31 : List U8 = CallByName Encode.23 #Derived.13 #Derived_gen.32 #Derived.14;
ret #Derived_gen.31;
procedure #Derived.2 (#Derived.3, #Derived.4, #Attr.12):
let #Derived.1 : Str = StructAtIndex 0 #Attr.12;
inc #Derived.1;
@ -38,7 +25,7 @@ procedure #Derived.7 (#Derived.8, #Derived.9, #Attr.12):
inc #Derived.6;
dec #Attr.12;
let #Derived_gen.21 : Str = "b";
let #Derived_gen.22 : {Str} = CallByName #Derived.10 #Derived.6;
let #Derived_gen.22 : {Str} = CallByName Json.17 #Derived.6;
let #Derived_gen.20 : {Str, {Str}} = Struct {#Derived_gen.21, #Derived_gen.22};
let #Derived_gen.19 : List {Str, {Str}} = Array [#Derived_gen.20];
let #Derived_gen.18 : {List {Str, {Str}}} = CallByName Json.19 #Derived_gen.19;
@ -60,9 +47,6 @@ procedure Encode.22 (Encode.93):
procedure Encode.22 (Encode.93):
ret Encode.93;
procedure Encode.22 (Encode.93):
ret Encode.93;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.106 : List U8 = CallByName #Derived.2 Encode.94 Encode.96 Encode.102;
ret Encode.106;
@ -80,12 +64,8 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96):
ret Encode.125;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.127 : List U8 = CallByName #Derived.12 Encode.94 Encode.96 Encode.102;
ret Encode.127;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.137 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.137;
let Encode.128 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.128;
procedure Encode.25 (Encode.100, Encode.101):
let Encode.104 : List U8 = Array [];
@ -98,9 +78,9 @@ procedure Json.1 ():
ret Json.102;
procedure Json.17 (Json.64):
let Json.186 : {Str} = Struct {Json.64};
let Json.185 : {Str} = CallByName Encode.22 Json.186;
ret Json.185;
let Json.149 : {Str} = Struct {Json.64};
let Json.148 : {Str} = CallByName Encode.22 Json.149;
ret Json.148;
procedure Json.19 (Json.76):
let Json.104 : {List {Str, {Str}}} = Struct {Json.76};
@ -112,19 +92,19 @@ procedure Json.19 (Json.76):
let Json.145 : {List {Str, {Str}}} = CallByName Encode.22 Json.146;
ret Json.145;
procedure Json.65 (Json.66, Json.187, #Attr.12):
procedure Json.65 (Json.66, Json.150, #Attr.12):
let Json.64 : Str = StructAtIndex 0 #Attr.12;
inc Json.64;
dec #Attr.12;
let Json.196 : I32 = 34i64;
let Json.195 : U8 = CallByName Num.123 Json.196;
let Json.193 : List U8 = CallByName List.4 Json.66 Json.195;
let Json.194 : List U8 = CallByName Str.12 Json.64;
let Json.190 : List U8 = CallByName List.8 Json.193 Json.194;
let Json.192 : I32 = 34i64;
let Json.191 : U8 = CallByName Num.123 Json.192;
let Json.189 : List U8 = CallByName List.4 Json.190 Json.191;
ret Json.189;
let Json.190 : I32 = 34i64;
let Json.189 : U8 = CallByName Num.123 Json.190;
let Json.187 : List U8 = CallByName List.4 Json.66 Json.189;
let Json.188 : List U8 = CallByName Str.12 Json.64;
let Json.184 : List U8 = CallByName List.8 Json.187 Json.188;
let Json.186 : I32 = 34i64;
let Json.185 : U8 = CallByName Num.123 Json.186;
let Json.183 : List U8 = CallByName List.4 Json.184 Json.185;
ret Json.183;
procedure Json.77 (Json.78, Json.105, #Attr.12):
let Json.76 : List {Str, {Str}} = StructAtIndex 0 #Attr.12;
@ -150,21 +130,21 @@ procedure Json.77 (Json.78, Json.105, #Attr.12):
let Json.76 : List {Str, {Str}} = StructAtIndex 0 #Attr.12;
inc Json.76;
dec #Attr.12;
let Json.178 : I32 = 123i64;
let Json.177 : U8 = CallByName Num.123 Json.178;
let Json.80 : List U8 = CallByName List.4 Json.78 Json.177;
let Json.176 : U64 = CallByName List.6 Json.76;
let Json.153 : {List U8, U64} = Struct {Json.80, Json.176};
let Json.154 : {} = Struct {};
let Json.152 : {List U8, U64} = CallByName List.18 Json.76 Json.153 Json.154;
let Json.181 : I32 = 123i64;
let Json.180 : U8 = CallByName Num.123 Json.181;
let Json.80 : List U8 = CallByName List.4 Json.78 Json.180;
let Json.179 : U64 = CallByName List.6 Json.76;
let Json.156 : {List U8, U64} = Struct {Json.80, Json.179};
let Json.157 : {} = Struct {};
let Json.155 : {List U8, U64} = CallByName List.18 Json.76 Json.156 Json.157;
dec Json.76;
let Json.82 : List U8 = StructAtIndex 0 Json.152;
let Json.82 : List U8 = StructAtIndex 0 Json.155;
inc Json.82;
dec Json.152;
let Json.151 : I32 = 125i64;
let Json.150 : U8 = CallByName Num.123 Json.151;
let Json.149 : List U8 = CallByName List.4 Json.82 Json.150;
ret Json.149;
dec Json.155;
let Json.154 : I32 = 125i64;
let Json.153 : U8 = CallByName Num.123 Json.154;
let Json.152 : List U8 = CallByName List.4 Json.82 Json.153;
ret Json.152;
procedure Json.79 (Json.107, Json.108):
let Json.85 : Str = StructAtIndex 0 Json.108;
@ -215,34 +195,34 @@ procedure Json.79 (Json.107, Json.108):
inc Json.83;
let Json.84 : U64 = StructAtIndex 1 Json.107;
dec Json.107;
let Json.175 : I32 = 34i64;
let Json.174 : U8 = CallByName Num.123 Json.175;
let Json.172 : List U8 = CallByName List.4 Json.83 Json.174;
let Json.173 : List U8 = CallByName Str.12 Json.85;
let Json.169 : List U8 = CallByName List.8 Json.172 Json.173;
let Json.171 : I32 = 34i64;
let Json.178 : I32 = 34i64;
let Json.177 : U8 = CallByName Num.123 Json.178;
let Json.175 : List U8 = CallByName List.4 Json.83 Json.177;
let Json.176 : List U8 = CallByName Str.12 Json.85;
let Json.172 : List U8 = CallByName List.8 Json.175 Json.176;
let Json.174 : I32 = 34i64;
let Json.173 : U8 = CallByName Num.123 Json.174;
let Json.169 : List U8 = CallByName List.4 Json.172 Json.173;
let Json.171 : I32 = 58i64;
let Json.170 : U8 = CallByName Num.123 Json.171;
let Json.166 : List U8 = CallByName List.4 Json.169 Json.170;
let Json.168 : I32 = 58i64;
let Json.167 : U8 = CallByName Num.123 Json.168;
let Json.164 : List U8 = CallByName List.4 Json.166 Json.167;
let Json.165 : {} = Struct {};
let Json.87 : List U8 = CallByName Encode.23 Json.164 Json.86 Json.165;
joinpoint Json.159 Json.88:
let Json.157 : U64 = 1i64;
let Json.156 : U64 = CallByName Num.20 Json.84 Json.157;
let Json.155 : {List U8, U64} = Struct {Json.88, Json.156};
ret Json.155;
let Json.167 : List U8 = CallByName List.4 Json.169 Json.170;
let Json.168 : {} = Struct {};
let Json.87 : List U8 = CallByName Encode.23 Json.167 Json.86 Json.168;
joinpoint Json.162 Json.88:
let Json.160 : U64 = 1i64;
let Json.159 : U64 = CallByName Num.20 Json.84 Json.160;
let Json.158 : {List U8, U64} = Struct {Json.88, Json.159};
ret Json.158;
in
let Json.163 : U64 = 0i64;
let Json.160 : Int1 = CallByName Num.24 Json.84 Json.163;
if Json.160 then
let Json.162 : I32 = 44i64;
let Json.161 : U8 = CallByName Num.123 Json.162;
let Json.158 : List U8 = CallByName List.4 Json.87 Json.161;
jump Json.159 Json.158;
let Json.166 : U64 = 0i64;
let Json.163 : Int1 = CallByName Num.24 Json.84 Json.166;
if Json.163 then
let Json.165 : I32 = 44i64;
let Json.164 : U8 = CallByName Num.123 Json.165;
let Json.161 : List U8 = CallByName List.4 Json.87 Json.164;
jump Json.162 Json.161;
else
jump Json.159 Json.87;
jump Json.162 Json.87;
procedure List.122 (List.123, List.124, #Attr.12):
let List.121 : {} = StructAtIndex 0 #Attr.12;
@ -252,9 +232,9 @@ procedure List.122 (List.123, List.124, #Attr.12):
procedure List.122 (List.123, List.124, #Attr.12):
let List.121 : {} = StructAtIndex 0 #Attr.12;
let List.418 : {List U8, U64} = CallByName Json.79 List.123 List.124;
let List.417 : [C [], C {List U8, U64}] = TagId(1) List.418;
ret List.417;
let List.425 : {List U8, U64} = CallByName Json.79 List.123 List.124;
let List.424 : [C [], C {List U8, U64}] = TagId(1) List.425;
ret List.424;
procedure List.18 (List.119, List.120, List.121):
let List.321 : {{}} = Struct {List.121};
@ -274,27 +254,27 @@ procedure List.18 (List.119, List.120, List.121):
ret List.317;
procedure List.18 (List.119, List.120, List.121):
let List.395 : {{}} = Struct {List.121};
let List.389 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.395;
let List.392 : U8 = 1i64;
let List.393 : U8 = GetTagId List.389;
let List.394 : Int1 = lowlevel Eq List.392 List.393;
if List.394 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.389;
let List.401 : {{}} = Struct {List.121};
let List.395 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.401;
let List.398 : U8 = 1i64;
let List.399 : U8 = GetTagId List.395;
let List.400 : Int1 = lowlevel Eq List.398 List.399;
if List.400 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.395;
inc List.126;
dec List.389;
dec List.395;
ret List.126;
else
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.389;
dec List.389;
let List.391 : {List U8, U64} = CallByName List.64 List.127;
ret List.391;
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.395;
dec List.395;
let List.397 : {List U8, U64} = CallByName List.64 List.127;
ret List.397;
procedure List.4 (List.90, List.91):
let List.450 : U64 = 1i64;
let List.449 : List U8 = CallByName List.65 List.90 List.450;
let List.448 : List U8 = CallByName List.66 List.449 List.91;
ret List.448;
let List.394 : U64 = 1i64;
let List.393 : List U8 = CallByName List.65 List.90 List.394;
let List.392 : List U8 = CallByName List.66 List.393 List.91;
ret List.392;
procedure List.6 (#Attr.2):
let List.295 : U64 = lowlevel ListLen #Attr.2;
@ -305,16 +285,16 @@ procedure List.6 (#Attr.2):
ret List.323;
procedure List.6 (#Attr.2):
let List.397 : U64 = lowlevel ListLen #Attr.2;
ret List.397;
let List.404 : U64 = lowlevel ListLen #Attr.2;
ret List.404;
procedure List.60 (#Attr.2, #Attr.3):
let List.342 : {Str, {Str}} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.342;
procedure List.60 (#Attr.2, #Attr.3):
let List.416 : {Str, {Str}} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.416;
let List.423 : {Str, {Str}} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.423;
procedure List.63 (List.283, List.284, List.285):
let List.328 : U64 = 0i64;
@ -323,22 +303,22 @@ procedure List.63 (List.283, List.284, List.285):
ret List.327;
procedure List.63 (List.283, List.284, List.285):
let List.402 : U64 = 0i64;
let List.403 : U64 = CallByName List.6 List.283;
let List.401 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.402 List.403;
ret List.401;
let List.409 : U64 = 0i64;
let List.410 : U64 = CallByName List.6 List.283;
let List.408 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.409 List.410;
ret List.408;
procedure List.64 (#Attr.2):
let List.400 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.400;
let List.407 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.407;
procedure List.65 (#Attr.2, #Attr.3):
let List.453 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.453;
let List.406 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.406;
procedure List.66 (#Attr.2, #Attr.3):
let List.452 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.452;
let List.405 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.405;
procedure List.77 (List.361, List.362, List.363, List.364, List.365):
joinpoint List.330 List.286 List.287 List.288 List.289 List.290:
@ -367,60 +347,60 @@ procedure List.77 (List.361, List.362, List.363, List.364, List.365):
in
jump List.330 List.361 List.362 List.363 List.364 List.365;
procedure List.77 (List.435, List.436, List.437, List.438, List.439):
joinpoint List.404 List.286 List.287 List.288 List.289 List.290:
let List.406 : Int1 = CallByName Num.22 List.289 List.290;
if List.406 then
let List.415 : {Str, {Str}} = CallByName List.60 List.286 List.289;
let List.407 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.415 List.288;
let List.412 : U8 = 1i64;
let List.413 : U8 = GetTagId List.407;
let List.414 : Int1 = lowlevel Eq List.412 List.413;
if List.414 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.407;
procedure List.77 (List.442, List.443, List.444, List.445, List.446):
joinpoint List.411 List.286 List.287 List.288 List.289 List.290:
let List.413 : Int1 = CallByName Num.22 List.289 List.290;
if List.413 then
let List.422 : {Str, {Str}} = CallByName List.60 List.286 List.289;
let List.414 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.422 List.288;
let List.419 : U8 = 1i64;
let List.420 : U8 = GetTagId List.414;
let List.421 : Int1 = lowlevel Eq List.419 List.420;
if List.421 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.414;
inc List.291;
dec List.407;
let List.410 : U64 = 1i64;
let List.409 : U64 = CallByName Num.19 List.289 List.410;
jump List.404 List.286 List.291 List.288 List.409 List.290;
dec List.414;
let List.417 : U64 = 1i64;
let List.416 : U64 = CallByName Num.19 List.289 List.417;
jump List.411 List.286 List.291 List.288 List.416 List.290;
else
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.407;
dec List.407;
let List.411 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.411;
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.414;
dec List.414;
let List.418 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.418;
else
let List.405 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.405;
let List.412 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.412;
in
jump List.404 List.435 List.436 List.437 List.438 List.439;
jump List.411 List.442 List.443 List.444 List.445 List.446;
procedure List.8 (#Attr.2, #Attr.3):
let List.451 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.451;
let List.403 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.403;
procedure Num.123 (#Attr.2):
let Num.296 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.296;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.284 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.284;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.282 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.285 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.285;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.283 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
let Num.283 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.283;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.286 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.286;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.284 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.284;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.287 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.287;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.285 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
ret Num.285;
procedure Str.12 (#Attr.2):
let Str.213 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.213;
let Str.212 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.212;
procedure Str.48 (#Attr.2, #Attr.3, #Attr.4):
let Str.204 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4;

View File

@ -8,29 +8,13 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Attr.12):
inc #Derived.1;
dec #Attr.12;
let #Derived_gen.7 : Str = "a";
let #Derived_gen.8 : {Str} = CallByName #Derived.5 #Derived.1;
let #Derived_gen.8 : {Str} = CallByName Json.17 #Derived.1;
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.4 : {List {Str, {Str}}} = CallByName Json.19 #Derived_gen.5;
let #Derived_gen.3 : List U8 = CallByName Encode.23 #Derived.3 #Derived_gen.4 #Derived.4;
ret #Derived_gen.3;
procedure #Derived.5 (#Derived.6):
let #Derived_gen.15 : {Str} = Struct {#Derived.6};
let #Derived_gen.14 : {Str} = CallByName Encode.22 #Derived_gen.15;
ret #Derived_gen.14;
procedure #Derived.7 (#Derived.8, #Derived.9, #Attr.12):
let #Derived.6 : Str = StructAtIndex 0 #Attr.12;
inc #Derived.6;
dec #Attr.12;
let #Derived_gen.18 : {Str} = CallByName Json.17 #Derived.6;
let #Derived_gen.17 : List U8 = CallByName Encode.23 #Derived.8 #Derived_gen.18 #Derived.9;
ret #Derived_gen.17;
procedure Encode.22 (Encode.93):
ret Encode.93;
procedure Encode.22 (Encode.93):
ret Encode.93;
@ -49,12 +33,8 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96):
ret Encode.113;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.115 : List U8 = CallByName #Derived.7 Encode.94 Encode.96 Encode.102;
ret Encode.115;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.125 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.125;
let Encode.116 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.116;
procedure Encode.25 (Encode.100, Encode.101):
let Encode.104 : List U8 = Array [];
@ -67,201 +47,201 @@ procedure Json.1 ():
ret Json.102;
procedure Json.17 (Json.64):
let Json.146 : {Str} = Struct {Json.64};
let Json.145 : {Str} = CallByName Encode.22 Json.146;
ret Json.145;
let Json.107 : {Str} = Struct {Json.64};
let Json.106 : {Str} = CallByName Encode.22 Json.107;
ret Json.106;
procedure Json.19 (Json.76):
let Json.104 : {List {Str, {Str}}} = Struct {Json.76};
let Json.103 : {List {Str, {Str}}} = CallByName Encode.22 Json.104;
ret Json.103;
procedure Json.65 (Json.66, Json.147, #Attr.12):
procedure Json.65 (Json.66, Json.108, #Attr.12):
let Json.64 : Str = StructAtIndex 0 #Attr.12;
inc Json.64;
dec #Attr.12;
let Json.156 : I32 = 34i64;
let Json.155 : U8 = CallByName Num.123 Json.156;
let Json.153 : List U8 = CallByName List.4 Json.66 Json.155;
let Json.154 : List U8 = CallByName Str.12 Json.64;
let Json.150 : List U8 = CallByName List.8 Json.153 Json.154;
let Json.152 : I32 = 34i64;
let Json.151 : U8 = CallByName Num.123 Json.152;
let Json.149 : List U8 = CallByName List.4 Json.150 Json.151;
ret Json.149;
let Json.150 : I32 = 34i64;
let Json.149 : U8 = CallByName Num.123 Json.150;
let Json.147 : List U8 = CallByName List.4 Json.66 Json.149;
let Json.148 : List U8 = CallByName Str.12 Json.64;
let Json.144 : List U8 = CallByName List.8 Json.147 Json.148;
let Json.146 : I32 = 34i64;
let Json.145 : U8 = CallByName Num.123 Json.146;
let Json.143 : List U8 = CallByName List.4 Json.144 Json.145;
ret Json.143;
procedure Json.77 (Json.78, Json.105, #Attr.12):
let Json.76 : List {Str, {Str}} = StructAtIndex 0 #Attr.12;
inc Json.76;
dec #Attr.12;
let Json.138 : I32 = 123i64;
let Json.137 : U8 = CallByName Num.123 Json.138;
let Json.80 : List U8 = CallByName List.4 Json.78 Json.137;
let Json.136 : U64 = CallByName List.6 Json.76;
let Json.113 : {List U8, U64} = Struct {Json.80, Json.136};
let Json.114 : {} = Struct {};
let Json.112 : {List U8, U64} = CallByName List.18 Json.76 Json.113 Json.114;
let Json.141 : I32 = 123i64;
let Json.140 : U8 = CallByName Num.123 Json.141;
let Json.80 : List U8 = CallByName List.4 Json.78 Json.140;
let Json.139 : U64 = CallByName List.6 Json.76;
let Json.116 : {List U8, U64} = Struct {Json.80, Json.139};
let Json.117 : {} = Struct {};
let Json.115 : {List U8, U64} = CallByName List.18 Json.76 Json.116 Json.117;
dec Json.76;
let Json.82 : List U8 = StructAtIndex 0 Json.112;
let Json.82 : List U8 = StructAtIndex 0 Json.115;
inc Json.82;
dec Json.112;
let Json.111 : I32 = 125i64;
let Json.110 : U8 = CallByName Num.123 Json.111;
let Json.109 : List U8 = CallByName List.4 Json.82 Json.110;
ret Json.109;
dec Json.115;
let Json.114 : I32 = 125i64;
let Json.113 : U8 = CallByName Num.123 Json.114;
let Json.112 : List U8 = CallByName List.4 Json.82 Json.113;
ret Json.112;
procedure Json.79 (Json.107, Json.108):
let Json.85 : Str = StructAtIndex 0 Json.108;
procedure Json.79 (Json.110, Json.111):
let Json.85 : Str = StructAtIndex 0 Json.111;
inc Json.85;
let Json.86 : {Str} = StructAtIndex 1 Json.108;
let Json.86 : {Str} = StructAtIndex 1 Json.111;
inc Json.86;
dec Json.108;
let Json.83 : List U8 = StructAtIndex 0 Json.107;
dec Json.111;
let Json.83 : List U8 = StructAtIndex 0 Json.110;
inc Json.83;
let Json.84 : U64 = StructAtIndex 1 Json.107;
dec Json.107;
let Json.135 : I32 = 34i64;
let Json.134 : U8 = CallByName Num.123 Json.135;
let Json.132 : List U8 = CallByName List.4 Json.83 Json.134;
let Json.133 : List U8 = CallByName Str.12 Json.85;
let Json.129 : List U8 = CallByName List.8 Json.132 Json.133;
let Json.131 : I32 = 34i64;
let Json.84 : U64 = StructAtIndex 1 Json.110;
dec Json.110;
let Json.138 : I32 = 34i64;
let Json.137 : U8 = CallByName Num.123 Json.138;
let Json.135 : List U8 = CallByName List.4 Json.83 Json.137;
let Json.136 : List U8 = CallByName Str.12 Json.85;
let Json.132 : List U8 = CallByName List.8 Json.135 Json.136;
let Json.134 : I32 = 34i64;
let Json.133 : U8 = CallByName Num.123 Json.134;
let Json.129 : List U8 = CallByName List.4 Json.132 Json.133;
let Json.131 : I32 = 58i64;
let Json.130 : U8 = CallByName Num.123 Json.131;
let Json.126 : List U8 = CallByName List.4 Json.129 Json.130;
let Json.128 : I32 = 58i64;
let Json.127 : U8 = CallByName Num.123 Json.128;
let Json.124 : List U8 = CallByName List.4 Json.126 Json.127;
let Json.125 : {} = Struct {};
let Json.87 : List U8 = CallByName Encode.23 Json.124 Json.86 Json.125;
joinpoint Json.119 Json.88:
let Json.117 : U64 = 1i64;
let Json.116 : U64 = CallByName Num.20 Json.84 Json.117;
let Json.115 : {List U8, U64} = Struct {Json.88, Json.116};
ret Json.115;
let Json.127 : List U8 = CallByName List.4 Json.129 Json.130;
let Json.128 : {} = Struct {};
let Json.87 : List U8 = CallByName Encode.23 Json.127 Json.86 Json.128;
joinpoint Json.122 Json.88:
let Json.120 : U64 = 1i64;
let Json.119 : U64 = CallByName Num.20 Json.84 Json.120;
let Json.118 : {List U8, U64} = Struct {Json.88, Json.119};
ret Json.118;
in
let Json.123 : U64 = 0i64;
let Json.120 : Int1 = CallByName Num.24 Json.84 Json.123;
if Json.120 then
let Json.122 : I32 = 44i64;
let Json.121 : U8 = CallByName Num.123 Json.122;
let Json.118 : List U8 = CallByName List.4 Json.87 Json.121;
jump Json.119 Json.118;
let Json.126 : U64 = 0i64;
let Json.123 : Int1 = CallByName Num.24 Json.84 Json.126;
if Json.123 then
let Json.125 : I32 = 44i64;
let Json.124 : U8 = CallByName Num.123 Json.125;
let Json.121 : List U8 = CallByName List.4 Json.87 Json.124;
jump Json.122 Json.121;
else
jump Json.119 Json.87;
jump Json.122 Json.87;
procedure List.122 (List.123, List.124, #Attr.12):
let List.121 : {} = StructAtIndex 0 #Attr.12;
let List.344 : {List U8, U64} = CallByName Json.79 List.123 List.124;
let List.343 : [C [], C {List U8, U64}] = TagId(1) List.344;
ret List.343;
let List.351 : {List U8, U64} = CallByName Json.79 List.123 List.124;
let List.350 : [C [], C {List U8, U64}] = TagId(1) List.351;
ret List.350;
procedure List.18 (List.119, List.120, List.121):
let List.321 : {{}} = Struct {List.121};
let List.315 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.321;
let List.318 : U8 = 1i64;
let List.319 : U8 = GetTagId List.315;
let List.320 : Int1 = lowlevel Eq List.318 List.319;
if List.320 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.315;
let List.327 : {{}} = Struct {List.121};
let List.321 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.327;
let List.324 : U8 = 1i64;
let List.325 : U8 = GetTagId List.321;
let List.326 : Int1 = lowlevel Eq List.324 List.325;
if List.326 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.321;
inc List.126;
dec List.315;
dec List.321;
ret List.126;
else
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.315;
dec List.315;
let List.317 : {List U8, U64} = CallByName List.64 List.127;
ret List.317;
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.321;
dec List.321;
let List.323 : {List U8, U64} = CallByName List.64 List.127;
ret List.323;
procedure List.4 (List.90, List.91):
let List.376 : U64 = 1i64;
let List.375 : List U8 = CallByName List.65 List.90 List.376;
let List.374 : List U8 = CallByName List.66 List.375 List.91;
ret List.374;
let List.320 : U64 = 1i64;
let List.319 : List U8 = CallByName List.65 List.90 List.320;
let List.318 : List U8 = CallByName List.66 List.319 List.91;
ret List.318;
procedure List.6 (#Attr.2):
let List.295 : U64 = lowlevel ListLen #Attr.2;
ret List.295;
procedure List.6 (#Attr.2):
let List.323 : U64 = lowlevel ListLen #Attr.2;
ret List.323;
let List.330 : U64 = lowlevel ListLen #Attr.2;
ret List.330;
procedure List.60 (#Attr.2, #Attr.3):
let List.342 : {Str, {Str}} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.342;
let List.349 : {Str, {Str}} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.349;
procedure List.63 (List.283, List.284, List.285):
let List.328 : U64 = 0i64;
let List.329 : U64 = CallByName List.6 List.283;
let List.327 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.328 List.329;
ret List.327;
let List.335 : U64 = 0i64;
let List.336 : U64 = CallByName List.6 List.283;
let List.334 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.335 List.336;
ret List.334;
procedure List.64 (#Attr.2):
let List.326 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.326;
let List.333 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.333;
procedure List.65 (#Attr.2, #Attr.3):
let List.379 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.379;
let List.332 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.332;
procedure List.66 (#Attr.2, #Attr.3):
let List.378 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.378;
let List.331 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.331;
procedure List.77 (List.361, List.362, List.363, List.364, List.365):
joinpoint List.330 List.286 List.287 List.288 List.289 List.290:
let List.332 : Int1 = CallByName Num.22 List.289 List.290;
if List.332 then
let List.341 : {Str, {Str}} = CallByName List.60 List.286 List.289;
let List.333 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.341 List.288;
let List.338 : U8 = 1i64;
let List.339 : U8 = GetTagId List.333;
let List.340 : Int1 = lowlevel Eq List.338 List.339;
if List.340 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.333;
procedure List.77 (List.368, List.369, List.370, List.371, List.372):
joinpoint List.337 List.286 List.287 List.288 List.289 List.290:
let List.339 : Int1 = CallByName Num.22 List.289 List.290;
if List.339 then
let List.348 : {Str, {Str}} = CallByName List.60 List.286 List.289;
let List.340 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.348 List.288;
let List.345 : U8 = 1i64;
let List.346 : U8 = GetTagId List.340;
let List.347 : Int1 = lowlevel Eq List.345 List.346;
if List.347 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.340;
inc List.291;
dec List.333;
let List.336 : U64 = 1i64;
let List.335 : U64 = CallByName Num.19 List.289 List.336;
jump List.330 List.286 List.291 List.288 List.335 List.290;
dec List.340;
let List.343 : U64 = 1i64;
let List.342 : U64 = CallByName Num.19 List.289 List.343;
jump List.337 List.286 List.291 List.288 List.342 List.290;
else
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.333;
dec List.333;
let List.337 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.337;
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.340;
dec List.340;
let List.344 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.344;
else
let List.331 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.331;
let List.338 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.338;
in
jump List.330 List.361 List.362 List.363 List.364 List.365;
jump List.337 List.368 List.369 List.370 List.371 List.372;
procedure List.8 (#Attr.2, #Attr.3):
let List.377 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.377;
let List.329 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.329;
procedure Num.123 (#Attr.2):
let Num.277 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.277;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.265 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.265;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.263 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.263;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.266 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.266;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.264 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
let Num.264 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.264;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.267 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.267;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.265 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.265;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.268 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.268;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.266 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
ret Num.266;
procedure Str.12 (#Attr.2):
let Str.211 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.211;
let Str.210 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.210;
procedure Str.48 (#Attr.2, #Attr.3, #Attr.4):
let Str.204 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4;

View File

@ -10,35 +10,19 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Attr.12):
let #Derived_gen.11 : Str = "a";
let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1;
inc #Derived_gen.13;
let #Derived_gen.12 : {Str} = CallByName #Derived.5 #Derived_gen.13;
let #Derived_gen.12 : {Str} = CallByName Json.17 #Derived_gen.13;
let #Derived_gen.6 : {Str, {Str}} = Struct {#Derived_gen.11, #Derived_gen.12};
let #Derived_gen.8 : Str = "b";
let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1;
inc #Derived_gen.10;
dec #Derived.1;
let #Derived_gen.9 : {Str} = CallByName #Derived.5 #Derived_gen.10;
let #Derived_gen.9 : {Str} = CallByName Json.17 #Derived_gen.10;
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.4 : {List {Str, {Str}}} = CallByName Json.19 #Derived_gen.5;
let #Derived_gen.3 : List U8 = CallByName Encode.23 #Derived.3 #Derived_gen.4 #Derived.4;
ret #Derived_gen.3;
procedure #Derived.5 (#Derived.6):
let #Derived_gen.21 : {Str} = Struct {#Derived.6};
let #Derived_gen.20 : {Str} = CallByName Encode.22 #Derived_gen.21;
ret #Derived_gen.20;
procedure #Derived.7 (#Derived.8, #Derived.9, #Attr.12):
let #Derived.6 : Str = StructAtIndex 0 #Attr.12;
inc #Derived.6;
dec #Attr.12;
let #Derived_gen.24 : {Str} = CallByName Json.17 #Derived.6;
let #Derived_gen.23 : List U8 = CallByName Encode.23 #Derived.8 #Derived_gen.24 #Derived.9;
ret #Derived_gen.23;
procedure Encode.22 (Encode.93):
ret Encode.93;
procedure Encode.22 (Encode.93):
ret Encode.93;
@ -57,12 +41,8 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96):
ret Encode.113;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.115 : List U8 = CallByName #Derived.7 Encode.94 Encode.96 Encode.102;
ret Encode.115;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.126 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.126;
let Encode.117 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.117;
procedure Encode.25 (Encode.100, Encode.101):
let Encode.104 : List U8 = Array [];
@ -75,201 +55,201 @@ procedure Json.1 ():
ret Json.102;
procedure Json.17 (Json.64):
let Json.146 : {Str} = Struct {Json.64};
let Json.145 : {Str} = CallByName Encode.22 Json.146;
ret Json.145;
let Json.110 : {Str} = Struct {Json.64};
let Json.109 : {Str} = CallByName Encode.22 Json.110;
ret Json.109;
procedure Json.19 (Json.76):
let Json.104 : {List {Str, {Str}}} = Struct {Json.76};
let Json.103 : {List {Str, {Str}}} = CallByName Encode.22 Json.104;
ret Json.103;
procedure Json.65 (Json.66, Json.147, #Attr.12):
procedure Json.65 (Json.66, Json.108, #Attr.12):
let Json.64 : Str = StructAtIndex 0 #Attr.12;
inc Json.64;
dec #Attr.12;
let Json.156 : I32 = 34i64;
let Json.155 : U8 = CallByName Num.123 Json.156;
let Json.153 : List U8 = CallByName List.4 Json.66 Json.155;
let Json.154 : List U8 = CallByName Str.12 Json.64;
let Json.150 : List U8 = CallByName List.8 Json.153 Json.154;
let Json.152 : I32 = 34i64;
let Json.151 : U8 = CallByName Num.123 Json.152;
let Json.149 : List U8 = CallByName List.4 Json.150 Json.151;
ret Json.149;
let Json.153 : I32 = 34i64;
let Json.152 : U8 = CallByName Num.123 Json.153;
let Json.150 : List U8 = CallByName List.4 Json.66 Json.152;
let Json.151 : List U8 = CallByName Str.12 Json.64;
let Json.147 : List U8 = CallByName List.8 Json.150 Json.151;
let Json.149 : I32 = 34i64;
let Json.148 : U8 = CallByName Num.123 Json.149;
let Json.146 : List U8 = CallByName List.4 Json.147 Json.148;
ret Json.146;
procedure Json.77 (Json.78, Json.105, #Attr.12):
let Json.76 : List {Str, {Str}} = StructAtIndex 0 #Attr.12;
inc Json.76;
dec #Attr.12;
let Json.138 : I32 = 123i64;
let Json.137 : U8 = CallByName Num.123 Json.138;
let Json.80 : List U8 = CallByName List.4 Json.78 Json.137;
let Json.136 : U64 = CallByName List.6 Json.76;
let Json.113 : {List U8, U64} = Struct {Json.80, Json.136};
let Json.114 : {} = Struct {};
let Json.112 : {List U8, U64} = CallByName List.18 Json.76 Json.113 Json.114;
let Json.144 : I32 = 123i64;
let Json.143 : U8 = CallByName Num.123 Json.144;
let Json.80 : List U8 = CallByName List.4 Json.78 Json.143;
let Json.142 : U64 = CallByName List.6 Json.76;
let Json.119 : {List U8, U64} = Struct {Json.80, Json.142};
let Json.120 : {} = Struct {};
let Json.118 : {List U8, U64} = CallByName List.18 Json.76 Json.119 Json.120;
dec Json.76;
let Json.82 : List U8 = StructAtIndex 0 Json.112;
let Json.82 : List U8 = StructAtIndex 0 Json.118;
inc Json.82;
dec Json.112;
let Json.111 : I32 = 125i64;
let Json.110 : U8 = CallByName Num.123 Json.111;
let Json.109 : List U8 = CallByName List.4 Json.82 Json.110;
ret Json.109;
dec Json.118;
let Json.117 : I32 = 125i64;
let Json.116 : U8 = CallByName Num.123 Json.117;
let Json.115 : List U8 = CallByName List.4 Json.82 Json.116;
ret Json.115;
procedure Json.79 (Json.107, Json.108):
let Json.85 : Str = StructAtIndex 0 Json.108;
procedure Json.79 (Json.113, Json.114):
let Json.85 : Str = StructAtIndex 0 Json.114;
inc Json.85;
let Json.86 : {Str} = StructAtIndex 1 Json.108;
let Json.86 : {Str} = StructAtIndex 1 Json.114;
inc Json.86;
dec Json.108;
let Json.83 : List U8 = StructAtIndex 0 Json.107;
dec Json.114;
let Json.83 : List U8 = StructAtIndex 0 Json.113;
inc Json.83;
let Json.84 : U64 = StructAtIndex 1 Json.107;
dec Json.107;
let Json.135 : I32 = 34i64;
let Json.134 : U8 = CallByName Num.123 Json.135;
let Json.132 : List U8 = CallByName List.4 Json.83 Json.134;
let Json.133 : List U8 = CallByName Str.12 Json.85;
let Json.129 : List U8 = CallByName List.8 Json.132 Json.133;
let Json.131 : I32 = 34i64;
let Json.130 : U8 = CallByName Num.123 Json.131;
let Json.126 : List U8 = CallByName List.4 Json.129 Json.130;
let Json.128 : I32 = 58i64;
let Json.127 : U8 = CallByName Num.123 Json.128;
let Json.124 : List U8 = CallByName List.4 Json.126 Json.127;
let Json.125 : {} = Struct {};
let Json.87 : List U8 = CallByName Encode.23 Json.124 Json.86 Json.125;
joinpoint Json.119 Json.88:
let Json.117 : U64 = 1i64;
let Json.116 : U64 = CallByName Num.20 Json.84 Json.117;
let Json.115 : {List U8, U64} = Struct {Json.88, Json.116};
ret Json.115;
let Json.84 : U64 = StructAtIndex 1 Json.113;
dec Json.113;
let Json.141 : I32 = 34i64;
let Json.140 : U8 = CallByName Num.123 Json.141;
let Json.138 : List U8 = CallByName List.4 Json.83 Json.140;
let Json.139 : List U8 = CallByName Str.12 Json.85;
let Json.135 : List U8 = CallByName List.8 Json.138 Json.139;
let Json.137 : I32 = 34i64;
let Json.136 : U8 = CallByName Num.123 Json.137;
let Json.132 : List U8 = CallByName List.4 Json.135 Json.136;
let Json.134 : I32 = 58i64;
let Json.133 : U8 = CallByName Num.123 Json.134;
let Json.130 : List U8 = CallByName List.4 Json.132 Json.133;
let Json.131 : {} = Struct {};
let Json.87 : List U8 = CallByName Encode.23 Json.130 Json.86 Json.131;
joinpoint Json.125 Json.88:
let Json.123 : U64 = 1i64;
let Json.122 : U64 = CallByName Num.20 Json.84 Json.123;
let Json.121 : {List U8, U64} = Struct {Json.88, Json.122};
ret Json.121;
in
let Json.123 : U64 = 0i64;
let Json.120 : Int1 = CallByName Num.24 Json.84 Json.123;
if Json.120 then
let Json.122 : I32 = 44i64;
let Json.121 : U8 = CallByName Num.123 Json.122;
let Json.118 : List U8 = CallByName List.4 Json.87 Json.121;
jump Json.119 Json.118;
let Json.129 : U64 = 0i64;
let Json.126 : Int1 = CallByName Num.24 Json.84 Json.129;
if Json.126 then
let Json.128 : I32 = 44i64;
let Json.127 : U8 = CallByName Num.123 Json.128;
let Json.124 : List U8 = CallByName List.4 Json.87 Json.127;
jump Json.125 Json.124;
else
jump Json.119 Json.87;
jump Json.125 Json.87;
procedure List.122 (List.123, List.124, #Attr.12):
let List.121 : {} = StructAtIndex 0 #Attr.12;
let List.344 : {List U8, U64} = CallByName Json.79 List.123 List.124;
let List.343 : [C [], C {List U8, U64}] = TagId(1) List.344;
ret List.343;
let List.351 : {List U8, U64} = CallByName Json.79 List.123 List.124;
let List.350 : [C [], C {List U8, U64}] = TagId(1) List.351;
ret List.350;
procedure List.18 (List.119, List.120, List.121):
let List.321 : {{}} = Struct {List.121};
let List.315 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.321;
let List.318 : U8 = 1i64;
let List.319 : U8 = GetTagId List.315;
let List.320 : Int1 = lowlevel Eq List.318 List.319;
if List.320 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.315;
let List.327 : {{}} = Struct {List.121};
let List.321 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.327;
let List.324 : U8 = 1i64;
let List.325 : U8 = GetTagId List.321;
let List.326 : Int1 = lowlevel Eq List.324 List.325;
if List.326 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.321;
inc List.126;
dec List.315;
dec List.321;
ret List.126;
else
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.315;
dec List.315;
let List.317 : {List U8, U64} = CallByName List.64 List.127;
ret List.317;
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.321;
dec List.321;
let List.323 : {List U8, U64} = CallByName List.64 List.127;
ret List.323;
procedure List.4 (List.90, List.91):
let List.376 : U64 = 1i64;
let List.375 : List U8 = CallByName List.65 List.90 List.376;
let List.374 : List U8 = CallByName List.66 List.375 List.91;
ret List.374;
let List.320 : U64 = 1i64;
let List.319 : List U8 = CallByName List.65 List.90 List.320;
let List.318 : List U8 = CallByName List.66 List.319 List.91;
ret List.318;
procedure List.6 (#Attr.2):
let List.295 : U64 = lowlevel ListLen #Attr.2;
ret List.295;
procedure List.6 (#Attr.2):
let List.323 : U64 = lowlevel ListLen #Attr.2;
ret List.323;
let List.330 : U64 = lowlevel ListLen #Attr.2;
ret List.330;
procedure List.60 (#Attr.2, #Attr.3):
let List.342 : {Str, {Str}} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.342;
let List.349 : {Str, {Str}} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.349;
procedure List.63 (List.283, List.284, List.285):
let List.328 : U64 = 0i64;
let List.329 : U64 = CallByName List.6 List.283;
let List.327 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.328 List.329;
ret List.327;
let List.335 : U64 = 0i64;
let List.336 : U64 = CallByName List.6 List.283;
let List.334 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.335 List.336;
ret List.334;
procedure List.64 (#Attr.2):
let List.326 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.326;
let List.333 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.333;
procedure List.65 (#Attr.2, #Attr.3):
let List.379 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.379;
let List.332 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.332;
procedure List.66 (#Attr.2, #Attr.3):
let List.378 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.378;
let List.331 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.331;
procedure List.77 (List.361, List.362, List.363, List.364, List.365):
joinpoint List.330 List.286 List.287 List.288 List.289 List.290:
let List.332 : Int1 = CallByName Num.22 List.289 List.290;
if List.332 then
let List.341 : {Str, {Str}} = CallByName List.60 List.286 List.289;
let List.333 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.341 List.288;
let List.338 : U8 = 1i64;
let List.339 : U8 = GetTagId List.333;
let List.340 : Int1 = lowlevel Eq List.338 List.339;
if List.340 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.333;
procedure List.77 (List.368, List.369, List.370, List.371, List.372):
joinpoint List.337 List.286 List.287 List.288 List.289 List.290:
let List.339 : Int1 = CallByName Num.22 List.289 List.290;
if List.339 then
let List.348 : {Str, {Str}} = CallByName List.60 List.286 List.289;
let List.340 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.348 List.288;
let List.345 : U8 = 1i64;
let List.346 : U8 = GetTagId List.340;
let List.347 : Int1 = lowlevel Eq List.345 List.346;
if List.347 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.340;
inc List.291;
dec List.333;
let List.336 : U64 = 1i64;
let List.335 : U64 = CallByName Num.19 List.289 List.336;
jump List.330 List.286 List.291 List.288 List.335 List.290;
dec List.340;
let List.343 : U64 = 1i64;
let List.342 : U64 = CallByName Num.19 List.289 List.343;
jump List.337 List.286 List.291 List.288 List.342 List.290;
else
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.333;
dec List.333;
let List.337 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.337;
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.340;
dec List.340;
let List.344 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.344;
else
let List.331 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.331;
let List.338 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.338;
in
jump List.330 List.361 List.362 List.363 List.364 List.365;
jump List.337 List.368 List.369 List.370 List.371 List.372;
procedure List.8 (#Attr.2, #Attr.3):
let List.377 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.377;
let List.329 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.329;
procedure Num.123 (#Attr.2):
let Num.277 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.277;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.265 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.265;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.263 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.263;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.266 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.266;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.264 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
let Num.264 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.264;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.267 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.267;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.265 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.265;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.268 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.268;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.266 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
ret Num.266;
procedure Str.12 (#Attr.2):
let Str.211 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.211;
let Str.210 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.210;
procedure Str.48 (#Attr.2, #Attr.3, #Attr.4):
let Str.204 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4;

View File

@ -1,33 +1,13 @@
procedure #Derived.0 (#Derived.1):
let #Derived_gen.1 : {Str} = Struct {#Derived.1};
let #Derived_gen.0 : {Str} = CallByName Encode.22 #Derived_gen.1;
ret #Derived_gen.0;
procedure #Derived.2 (#Derived.3, #Derived.4, #Attr.12):
let #Derived.1 : Str = StructAtIndex 0 #Attr.12;
inc #Derived.1;
dec #Attr.12;
let #Derived_gen.4 : {Str} = CallByName Json.17 #Derived.1;
let #Derived_gen.3 : List U8 = CallByName Encode.23 #Derived.3 #Derived_gen.4 #Derived.4;
ret #Derived_gen.3;
procedure Encode.22 (Encode.93):
ret Encode.93;
procedure Encode.22 (Encode.93):
ret Encode.93;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.106 : List U8 = CallByName #Derived.2 Encode.94 Encode.96 Encode.102;
let Encode.106 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.106;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.113 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.113;
procedure Encode.25 (Encode.100, Encode.101):
let Encode.104 : List U8 = Array [];
let Encode.105 : {Str} = CallByName #Derived.0 Encode.100;
let Encode.105 : {Str} = CallByName Json.17 Encode.100;
let Encode.103 : List U8 = CallByName Encode.23 Encode.104 Encode.105 Encode.101;
ret Encode.103;

View File

@ -12,27 +12,11 @@ procedure #Derived.3 (#Derived.4, #Derived.5, #Attr.12):
ret #Derived_gen.3;
in
let #Derived_gen.7 : Str = "A";
let #Derived_gen.9 : {Str} = CallByName #Derived.6 #Derived.1;
let #Derived_gen.9 : {Str} = CallByName Json.17 #Derived.1;
let #Derived_gen.8 : List {Str} = Array [#Derived_gen.9];
let #Derived_gen.6 : {Str, List {Str}} = CallByName Json.20 #Derived_gen.7 #Derived_gen.8;
jump #Derived_gen.5 #Derived_gen.6;
procedure #Derived.6 (#Derived.7):
let #Derived_gen.15 : {Str} = Struct {#Derived.7};
let #Derived_gen.14 : {Str} = CallByName Encode.22 #Derived_gen.15;
ret #Derived_gen.14;
procedure #Derived.8 (#Derived.9, #Derived.10, #Attr.12):
let #Derived.7 : Str = StructAtIndex 0 #Attr.12;
inc #Derived.7;
dec #Attr.12;
let #Derived_gen.18 : {Str} = CallByName Json.17 #Derived.7;
let #Derived_gen.17 : List U8 = CallByName Encode.23 #Derived.9 #Derived_gen.18 #Derived.10;
ret #Derived_gen.17;
procedure Encode.22 (Encode.93):
ret Encode.93;
procedure Encode.22 (Encode.93):
ret Encode.93;
@ -51,12 +35,8 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96):
ret Encode.113;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.115 : List U8 = CallByName #Derived.8 Encode.94 Encode.96 Encode.102;
ret Encode.115;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.125 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.125;
let Encode.116 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.116;
procedure Encode.25 (Encode.100, Encode.101):
let Encode.104 : List U8 = Array [];
@ -69,28 +49,28 @@ procedure Json.1 ():
ret Json.102;
procedure Json.17 (Json.64):
let Json.152 : {Str} = Struct {Json.64};
let Json.151 : {Str} = CallByName Encode.22 Json.152;
ret Json.151;
let Json.107 : {Str} = Struct {Json.64};
let Json.106 : {Str} = CallByName Encode.22 Json.107;
ret Json.106;
procedure Json.20 (Json.89, Json.90):
let Json.104 : {Str, List {Str}} = Struct {Json.89, Json.90};
let Json.103 : {Str, List {Str}} = CallByName Encode.22 Json.104;
ret Json.103;
procedure Json.65 (Json.66, Json.153, #Attr.12):
procedure Json.65 (Json.66, Json.108, #Attr.12):
let Json.64 : Str = StructAtIndex 0 #Attr.12;
inc Json.64;
dec #Attr.12;
let Json.162 : I32 = 34i64;
let Json.161 : U8 = CallByName Num.123 Json.162;
let Json.159 : List U8 = CallByName List.4 Json.66 Json.161;
let Json.160 : List U8 = CallByName Str.12 Json.64;
let Json.156 : List U8 = CallByName List.8 Json.159 Json.160;
let Json.158 : I32 = 34i64;
let Json.157 : U8 = CallByName Num.123 Json.158;
let Json.155 : List U8 = CallByName List.4 Json.156 Json.157;
ret Json.155;
let Json.155 : I32 = 34i64;
let Json.154 : U8 = CallByName Num.123 Json.155;
let Json.152 : List U8 = CallByName List.4 Json.66 Json.154;
let Json.153 : List U8 = CallByName Str.12 Json.64;
let Json.149 : List U8 = CallByName List.8 Json.152 Json.153;
let Json.151 : I32 = 34i64;
let Json.150 : U8 = CallByName Num.123 Json.151;
let Json.148 : List U8 = CallByName List.4 Json.149 Json.150;
ret Json.148;
procedure Json.91 (Json.92, Json.105, #Attr.12):
let Json.90 : List {Str} = StructAtIndex 1 #Attr.12;
@ -98,175 +78,175 @@ procedure Json.91 (Json.92, Json.105, #Attr.12):
let Json.89 : Str = StructAtIndex 0 #Attr.12;
inc Json.89;
dec #Attr.12;
let Json.143 : I32 = 123i64;
let Json.142 : U8 = CallByName Num.123 Json.143;
let Json.139 : List U8 = CallByName List.4 Json.92 Json.142;
let Json.141 : I32 = 34i64;
let Json.140 : U8 = CallByName Num.123 Json.141;
let Json.137 : List U8 = CallByName List.4 Json.139 Json.140;
let Json.138 : List U8 = CallByName Str.12 Json.89;
let Json.134 : List U8 = CallByName List.8 Json.137 Json.138;
let Json.136 : I32 = 34i64;
let Json.146 : I32 = 123i64;
let Json.145 : U8 = CallByName Num.123 Json.146;
let Json.142 : List U8 = CallByName List.4 Json.92 Json.145;
let Json.144 : I32 = 34i64;
let Json.143 : U8 = CallByName Num.123 Json.144;
let Json.140 : List U8 = CallByName List.4 Json.142 Json.143;
let Json.141 : List U8 = CallByName Str.12 Json.89;
let Json.137 : List U8 = CallByName List.8 Json.140 Json.141;
let Json.139 : I32 = 34i64;
let Json.138 : U8 = CallByName Num.123 Json.139;
let Json.134 : List U8 = CallByName List.4 Json.137 Json.138;
let Json.136 : I32 = 58i64;
let Json.135 : U8 = CallByName Num.123 Json.136;
let Json.131 : List U8 = CallByName List.4 Json.134 Json.135;
let Json.133 : I32 = 58i64;
let Json.133 : I32 = 91i64;
let Json.132 : U8 = CallByName Num.123 Json.133;
let Json.128 : List U8 = CallByName List.4 Json.131 Json.132;
let Json.130 : I32 = 91i64;
let Json.129 : U8 = CallByName Num.123 Json.130;
let Json.94 : List U8 = CallByName List.4 Json.128 Json.129;
let Json.127 : U64 = CallByName List.6 Json.90;
let Json.115 : {List U8, U64} = Struct {Json.94, Json.127};
let Json.116 : {} = Struct {};
let Json.114 : {List U8, U64} = CallByName List.18 Json.90 Json.115 Json.116;
let Json.94 : List U8 = CallByName List.4 Json.131 Json.132;
let Json.130 : U64 = CallByName List.6 Json.90;
let Json.118 : {List U8, U64} = Struct {Json.94, Json.130};
let Json.119 : {} = Struct {};
let Json.117 : {List U8, U64} = CallByName List.18 Json.90 Json.118 Json.119;
dec Json.90;
let Json.96 : List U8 = StructAtIndex 0 Json.114;
let Json.96 : List U8 = StructAtIndex 0 Json.117;
inc Json.96;
dec Json.114;
let Json.113 : I32 = 93i64;
let Json.112 : U8 = CallByName Num.123 Json.113;
let Json.109 : List U8 = CallByName List.4 Json.96 Json.112;
let Json.111 : I32 = 125i64;
let Json.110 : U8 = CallByName Num.123 Json.111;
let Json.108 : List U8 = CallByName List.4 Json.109 Json.110;
ret Json.108;
dec Json.117;
let Json.116 : I32 = 93i64;
let Json.115 : U8 = CallByName Num.123 Json.116;
let Json.112 : List U8 = CallByName List.4 Json.96 Json.115;
let Json.114 : I32 = 125i64;
let Json.113 : U8 = CallByName Num.123 Json.114;
let Json.111 : List U8 = CallByName List.4 Json.112 Json.113;
ret Json.111;
procedure Json.93 (Json.107, Json.99):
let Json.97 : List U8 = StructAtIndex 0 Json.107;
procedure Json.93 (Json.110, Json.99):
let Json.97 : List U8 = StructAtIndex 0 Json.110;
inc Json.97;
let Json.98 : U64 = StructAtIndex 1 Json.107;
dec Json.107;
let Json.126 : {} = Struct {};
let Json.100 : List U8 = CallByName Encode.23 Json.97 Json.99 Json.126;
joinpoint Json.121 Json.101:
let Json.119 : U64 = 1i64;
let Json.118 : U64 = CallByName Num.20 Json.98 Json.119;
let Json.117 : {List U8, U64} = Struct {Json.101, Json.118};
ret Json.117;
let Json.98 : U64 = StructAtIndex 1 Json.110;
dec Json.110;
let Json.129 : {} = Struct {};
let Json.100 : List U8 = CallByName Encode.23 Json.97 Json.99 Json.129;
joinpoint Json.124 Json.101:
let Json.122 : U64 = 1i64;
let Json.121 : U64 = CallByName Num.20 Json.98 Json.122;
let Json.120 : {List U8, U64} = Struct {Json.101, Json.121};
ret Json.120;
in
let Json.125 : U64 = 0i64;
let Json.122 : Int1 = CallByName Num.24 Json.98 Json.125;
if Json.122 then
let Json.124 : I32 = 44i64;
let Json.123 : U8 = CallByName Num.123 Json.124;
let Json.120 : List U8 = CallByName List.4 Json.100 Json.123;
jump Json.121 Json.120;
let Json.128 : U64 = 0i64;
let Json.125 : Int1 = CallByName Num.24 Json.98 Json.128;
if Json.125 then
let Json.127 : I32 = 44i64;
let Json.126 : U8 = CallByName Num.123 Json.127;
let Json.123 : List U8 = CallByName List.4 Json.100 Json.126;
jump Json.124 Json.123;
else
jump Json.121 Json.100;
jump Json.124 Json.100;
procedure List.122 (List.123, List.124, #Attr.12):
let List.121 : {} = StructAtIndex 0 #Attr.12;
let List.350 : {List U8, U64} = CallByName Json.93 List.123 List.124;
let List.349 : [C [], C {List U8, U64}] = TagId(1) List.350;
ret List.349;
let List.357 : {List U8, U64} = CallByName Json.93 List.123 List.124;
let List.356 : [C [], C {List U8, U64}] = TagId(1) List.357;
ret List.356;
procedure List.18 (List.119, List.120, List.121):
let List.327 : {{}} = Struct {List.121};
let List.321 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.327;
let List.324 : U8 = 1i64;
let List.325 : U8 = GetTagId List.321;
let List.326 : Int1 = lowlevel Eq List.324 List.325;
if List.326 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.321;
let List.333 : {{}} = Struct {List.121};
let List.327 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.333;
let List.330 : U8 = 1i64;
let List.331 : U8 = GetTagId List.327;
let List.332 : Int1 = lowlevel Eq List.330 List.331;
if List.332 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.327;
inc List.126;
dec List.321;
dec List.327;
ret List.126;
else
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.321;
dec List.321;
let List.323 : {List U8, U64} = CallByName List.64 List.127;
ret List.323;
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.327;
dec List.327;
let List.329 : {List U8, U64} = CallByName List.64 List.127;
ret List.329;
procedure List.4 (List.90, List.91):
let List.382 : U64 = 1i64;
let List.381 : List U8 = CallByName List.65 List.90 List.382;
let List.380 : List U8 = CallByName List.66 List.381 List.91;
ret List.380;
let List.326 : U64 = 1i64;
let List.325 : List U8 = CallByName List.65 List.90 List.326;
let List.324 : List U8 = CallByName List.66 List.325 List.91;
ret List.324;
procedure List.6 (#Attr.2):
let List.295 : U64 = lowlevel ListLen #Attr.2;
ret List.295;
procedure List.6 (#Attr.2):
let List.328 : U64 = lowlevel ListLen #Attr.2;
ret List.328;
let List.334 : U64 = lowlevel ListLen #Attr.2;
ret List.334;
procedure List.60 (#Attr.2, #Attr.3):
let List.348 : {Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.348;
let List.355 : {Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.355;
procedure List.63 (List.283, List.284, List.285):
let List.334 : U64 = 0i64;
let List.335 : U64 = CallByName List.6 List.283;
let List.333 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.334 List.335;
ret List.333;
let List.341 : U64 = 0i64;
let List.342 : U64 = CallByName List.6 List.283;
let List.340 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.341 List.342;
ret List.340;
procedure List.64 (#Attr.2):
let List.332 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.332;
let List.339 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.339;
procedure List.65 (#Attr.2, #Attr.3):
let List.385 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.385;
let List.338 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.338;
procedure List.66 (#Attr.2, #Attr.3):
let List.384 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.384;
let List.337 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.337;
procedure List.77 (List.367, List.368, List.369, List.370, List.371):
joinpoint List.336 List.286 List.287 List.288 List.289 List.290:
let List.338 : Int1 = CallByName Num.22 List.289 List.290;
if List.338 then
let List.347 : {Str} = CallByName List.60 List.286 List.289;
let List.339 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.347 List.288;
let List.344 : U8 = 1i64;
let List.345 : U8 = GetTagId List.339;
let List.346 : Int1 = lowlevel Eq List.344 List.345;
if List.346 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.339;
procedure List.77 (List.374, List.375, List.376, List.377, List.378):
joinpoint List.343 List.286 List.287 List.288 List.289 List.290:
let List.345 : Int1 = CallByName Num.22 List.289 List.290;
if List.345 then
let List.354 : {Str} = CallByName List.60 List.286 List.289;
let List.346 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.354 List.288;
let List.351 : U8 = 1i64;
let List.352 : U8 = GetTagId List.346;
let List.353 : Int1 = lowlevel Eq List.351 List.352;
if List.353 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.346;
inc List.291;
dec List.339;
let List.342 : U64 = 1i64;
let List.341 : U64 = CallByName Num.19 List.289 List.342;
jump List.336 List.286 List.291 List.288 List.341 List.290;
dec List.346;
let List.349 : U64 = 1i64;
let List.348 : U64 = CallByName Num.19 List.289 List.349;
jump List.343 List.286 List.291 List.288 List.348 List.290;
else
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.339;
dec List.339;
let List.343 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.343;
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.346;
dec List.346;
let List.350 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.350;
else
let List.337 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.337;
let List.344 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.344;
in
jump List.336 List.367 List.368 List.369 List.370 List.371;
jump List.343 List.374 List.375 List.376 List.377 List.378;
procedure List.8 (#Attr.2, #Attr.3):
let List.383 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.383;
let List.336 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.336;
procedure Num.123 (#Attr.2):
let Num.279 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.279;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.267 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.267;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.265 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.265;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.268 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.268;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.266 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
let Num.266 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.266;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.269 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.269;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.267 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.267;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.270 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.270;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.268 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
ret Num.268;
procedure Str.12 (#Attr.2):
let Str.211 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.211;
let Str.210 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.210;
procedure Str.48 (#Attr.2, #Attr.3, #Attr.4):
let Str.204 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4;

View File

@ -17,28 +17,12 @@ procedure #Derived.4 (#Derived.5, #Derived.6, #Attr.12):
inc #Derived.3;
dec #Derived.1;
let #Derived_gen.7 : Str = "A";
let #Derived_gen.9 : {Str} = CallByName #Derived.7 #Derived.2;
let #Derived_gen.10 : {Str} = CallByName #Derived.7 #Derived.3;
let #Derived_gen.9 : {Str} = CallByName Json.17 #Derived.2;
let #Derived_gen.10 : {Str} = CallByName Json.17 #Derived.3;
let #Derived_gen.8 : List {Str} = Array [#Derived_gen.9, #Derived_gen.10];
let #Derived_gen.6 : {Str, List {Str}} = CallByName Json.20 #Derived_gen.7 #Derived_gen.8;
jump #Derived_gen.5 #Derived_gen.6;
procedure #Derived.7 (#Derived.8):
let #Derived_gen.18 : {Str} = Struct {#Derived.8};
let #Derived_gen.17 : {Str} = CallByName Encode.22 #Derived_gen.18;
ret #Derived_gen.17;
procedure #Derived.9 (#Derived.10, #Derived.11, #Attr.12):
let #Derived.8 : Str = StructAtIndex 0 #Attr.12;
inc #Derived.8;
dec #Attr.12;
let #Derived_gen.21 : {Str} = CallByName Json.17 #Derived.8;
let #Derived_gen.20 : List U8 = CallByName Encode.23 #Derived.10 #Derived_gen.21 #Derived.11;
ret #Derived_gen.20;
procedure Encode.22 (Encode.93):
ret Encode.93;
procedure Encode.22 (Encode.93):
ret Encode.93;
@ -57,12 +41,8 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96):
ret Encode.113;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.115 : List U8 = CallByName #Derived.9 Encode.94 Encode.96 Encode.102;
ret Encode.115;
procedure Encode.23 (Encode.94, Encode.102, Encode.96):
let Encode.126 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.126;
let Encode.117 : List U8 = CallByName Json.65 Encode.94 Encode.96 Encode.102;
ret Encode.117;
procedure Encode.25 (Encode.100, Encode.101):
let Encode.104 : List U8 = Array [];
@ -75,28 +55,28 @@ procedure Json.1 ():
ret Json.102;
procedure Json.17 (Json.64):
let Json.152 : {Str} = Struct {Json.64};
let Json.151 : {Str} = CallByName Encode.22 Json.152;
ret Json.151;
let Json.110 : {Str} = Struct {Json.64};
let Json.109 : {Str} = CallByName Encode.22 Json.110;
ret Json.109;
procedure Json.20 (Json.89, Json.90):
let Json.104 : {Str, List {Str}} = Struct {Json.89, Json.90};
let Json.103 : {Str, List {Str}} = CallByName Encode.22 Json.104;
ret Json.103;
procedure Json.65 (Json.66, Json.153, #Attr.12):
procedure Json.65 (Json.66, Json.108, #Attr.12):
let Json.64 : Str = StructAtIndex 0 #Attr.12;
inc Json.64;
dec #Attr.12;
let Json.162 : I32 = 34i64;
let Json.161 : U8 = CallByName Num.123 Json.162;
let Json.159 : List U8 = CallByName List.4 Json.66 Json.161;
let Json.160 : List U8 = CallByName Str.12 Json.64;
let Json.156 : List U8 = CallByName List.8 Json.159 Json.160;
let Json.158 : I32 = 34i64;
let Json.157 : U8 = CallByName Num.123 Json.158;
let Json.155 : List U8 = CallByName List.4 Json.156 Json.157;
ret Json.155;
let Json.155 : List U8 = CallByName List.4 Json.66 Json.157;
let Json.156 : List U8 = CallByName Str.12 Json.64;
let Json.152 : List U8 = CallByName List.8 Json.155 Json.156;
let Json.154 : I32 = 34i64;
let Json.153 : U8 = CallByName Num.123 Json.154;
let Json.151 : List U8 = CallByName List.4 Json.152 Json.153;
ret Json.151;
procedure Json.91 (Json.92, Json.105, #Attr.12):
let Json.90 : List {Str} = StructAtIndex 1 #Attr.12;
@ -104,175 +84,175 @@ procedure Json.91 (Json.92, Json.105, #Attr.12):
let Json.89 : Str = StructAtIndex 0 #Attr.12;
inc Json.89;
dec #Attr.12;
let Json.143 : I32 = 123i64;
let Json.142 : U8 = CallByName Num.123 Json.143;
let Json.139 : List U8 = CallByName List.4 Json.92 Json.142;
let Json.141 : I32 = 34i64;
let Json.140 : U8 = CallByName Num.123 Json.141;
let Json.137 : List U8 = CallByName List.4 Json.139 Json.140;
let Json.138 : List U8 = CallByName Str.12 Json.89;
let Json.134 : List U8 = CallByName List.8 Json.137 Json.138;
let Json.136 : I32 = 34i64;
let Json.149 : I32 = 123i64;
let Json.148 : U8 = CallByName Num.123 Json.149;
let Json.145 : List U8 = CallByName List.4 Json.92 Json.148;
let Json.147 : I32 = 34i64;
let Json.146 : U8 = CallByName Num.123 Json.147;
let Json.143 : List U8 = CallByName List.4 Json.145 Json.146;
let Json.144 : List U8 = CallByName Str.12 Json.89;
let Json.140 : List U8 = CallByName List.8 Json.143 Json.144;
let Json.142 : I32 = 34i64;
let Json.141 : U8 = CallByName Num.123 Json.142;
let Json.137 : List U8 = CallByName List.4 Json.140 Json.141;
let Json.139 : I32 = 58i64;
let Json.138 : U8 = CallByName Num.123 Json.139;
let Json.134 : List U8 = CallByName List.4 Json.137 Json.138;
let Json.136 : I32 = 91i64;
let Json.135 : U8 = CallByName Num.123 Json.136;
let Json.131 : List U8 = CallByName List.4 Json.134 Json.135;
let Json.133 : I32 = 58i64;
let Json.132 : U8 = CallByName Num.123 Json.133;
let Json.128 : List U8 = CallByName List.4 Json.131 Json.132;
let Json.130 : I32 = 91i64;
let Json.129 : U8 = CallByName Num.123 Json.130;
let Json.94 : List U8 = CallByName List.4 Json.128 Json.129;
let Json.127 : U64 = CallByName List.6 Json.90;
let Json.115 : {List U8, U64} = Struct {Json.94, Json.127};
let Json.116 : {} = Struct {};
let Json.114 : {List U8, U64} = CallByName List.18 Json.90 Json.115 Json.116;
let Json.94 : List U8 = CallByName List.4 Json.134 Json.135;
let Json.133 : U64 = CallByName List.6 Json.90;
let Json.121 : {List U8, U64} = Struct {Json.94, Json.133};
let Json.122 : {} = Struct {};
let Json.120 : {List U8, U64} = CallByName List.18 Json.90 Json.121 Json.122;
dec Json.90;
let Json.96 : List U8 = StructAtIndex 0 Json.114;
let Json.96 : List U8 = StructAtIndex 0 Json.120;
inc Json.96;
dec Json.114;
let Json.113 : I32 = 93i64;
let Json.112 : U8 = CallByName Num.123 Json.113;
let Json.109 : List U8 = CallByName List.4 Json.96 Json.112;
let Json.111 : I32 = 125i64;
let Json.110 : U8 = CallByName Num.123 Json.111;
let Json.108 : List U8 = CallByName List.4 Json.109 Json.110;
ret Json.108;
dec Json.120;
let Json.119 : I32 = 93i64;
let Json.118 : U8 = CallByName Num.123 Json.119;
let Json.115 : List U8 = CallByName List.4 Json.96 Json.118;
let Json.117 : I32 = 125i64;
let Json.116 : U8 = CallByName Num.123 Json.117;
let Json.114 : List U8 = CallByName List.4 Json.115 Json.116;
ret Json.114;
procedure Json.93 (Json.107, Json.99):
let Json.97 : List U8 = StructAtIndex 0 Json.107;
procedure Json.93 (Json.113, Json.99):
let Json.97 : List U8 = StructAtIndex 0 Json.113;
inc Json.97;
let Json.98 : U64 = StructAtIndex 1 Json.107;
dec Json.107;
let Json.126 : {} = Struct {};
let Json.100 : List U8 = CallByName Encode.23 Json.97 Json.99 Json.126;
joinpoint Json.121 Json.101:
let Json.119 : U64 = 1i64;
let Json.118 : U64 = CallByName Num.20 Json.98 Json.119;
let Json.117 : {List U8, U64} = Struct {Json.101, Json.118};
ret Json.117;
let Json.98 : U64 = StructAtIndex 1 Json.113;
dec Json.113;
let Json.132 : {} = Struct {};
let Json.100 : List U8 = CallByName Encode.23 Json.97 Json.99 Json.132;
joinpoint Json.127 Json.101:
let Json.125 : U64 = 1i64;
let Json.124 : U64 = CallByName Num.20 Json.98 Json.125;
let Json.123 : {List U8, U64} = Struct {Json.101, Json.124};
ret Json.123;
in
let Json.125 : U64 = 0i64;
let Json.122 : Int1 = CallByName Num.24 Json.98 Json.125;
if Json.122 then
let Json.124 : I32 = 44i64;
let Json.123 : U8 = CallByName Num.123 Json.124;
let Json.120 : List U8 = CallByName List.4 Json.100 Json.123;
jump Json.121 Json.120;
let Json.131 : U64 = 0i64;
let Json.128 : Int1 = CallByName Num.24 Json.98 Json.131;
if Json.128 then
let Json.130 : I32 = 44i64;
let Json.129 : U8 = CallByName Num.123 Json.130;
let Json.126 : List U8 = CallByName List.4 Json.100 Json.129;
jump Json.127 Json.126;
else
jump Json.121 Json.100;
jump Json.127 Json.100;
procedure List.122 (List.123, List.124, #Attr.12):
let List.121 : {} = StructAtIndex 0 #Attr.12;
let List.350 : {List U8, U64} = CallByName Json.93 List.123 List.124;
let List.349 : [C [], C {List U8, U64}] = TagId(1) List.350;
ret List.349;
let List.357 : {List U8, U64} = CallByName Json.93 List.123 List.124;
let List.356 : [C [], C {List U8, U64}] = TagId(1) List.357;
ret List.356;
procedure List.18 (List.119, List.120, List.121):
let List.327 : {{}} = Struct {List.121};
let List.321 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.327;
let List.324 : U8 = 1i64;
let List.325 : U8 = GetTagId List.321;
let List.326 : Int1 = lowlevel Eq List.324 List.325;
if List.326 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.321;
let List.333 : {{}} = Struct {List.121};
let List.327 : [C [], C {List U8, U64}] = CallByName List.63 List.119 List.120 List.333;
let List.330 : U8 = 1i64;
let List.331 : U8 = GetTagId List.327;
let List.332 : Int1 = lowlevel Eq List.330 List.331;
if List.332 then
let List.126 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.327;
inc List.126;
dec List.321;
dec List.327;
ret List.126;
else
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.321;
dec List.321;
let List.323 : {List U8, U64} = CallByName List.64 List.127;
ret List.323;
let List.127 : [] = UnionAtIndex (Id 0) (Index 0) List.327;
dec List.327;
let List.329 : {List U8, U64} = CallByName List.64 List.127;
ret List.329;
procedure List.4 (List.90, List.91):
let List.382 : U64 = 1i64;
let List.381 : List U8 = CallByName List.65 List.90 List.382;
let List.380 : List U8 = CallByName List.66 List.381 List.91;
ret List.380;
let List.326 : U64 = 1i64;
let List.325 : List U8 = CallByName List.65 List.90 List.326;
let List.324 : List U8 = CallByName List.66 List.325 List.91;
ret List.324;
procedure List.6 (#Attr.2):
let List.295 : U64 = lowlevel ListLen #Attr.2;
ret List.295;
procedure List.6 (#Attr.2):
let List.328 : U64 = lowlevel ListLen #Attr.2;
ret List.328;
let List.334 : U64 = lowlevel ListLen #Attr.2;
ret List.334;
procedure List.60 (#Attr.2, #Attr.3):
let List.348 : {Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.348;
let List.355 : {Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.355;
procedure List.63 (List.283, List.284, List.285):
let List.334 : U64 = 0i64;
let List.335 : U64 = CallByName List.6 List.283;
let List.333 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.334 List.335;
ret List.333;
let List.341 : U64 = 0i64;
let List.342 : U64 = CallByName List.6 List.283;
let List.340 : [C [], C {List U8, U64}] = CallByName List.77 List.283 List.284 List.285 List.341 List.342;
ret List.340;
procedure List.64 (#Attr.2):
let List.332 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.332;
let List.339 : {List U8, U64} = lowlevel Unreachable #Attr.2;
ret List.339;
procedure List.65 (#Attr.2, #Attr.3):
let List.385 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.385;
let List.338 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.338;
procedure List.66 (#Attr.2, #Attr.3):
let List.384 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.384;
let List.337 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.337;
procedure List.77 (List.367, List.368, List.369, List.370, List.371):
joinpoint List.336 List.286 List.287 List.288 List.289 List.290:
let List.338 : Int1 = CallByName Num.22 List.289 List.290;
if List.338 then
let List.347 : {Str} = CallByName List.60 List.286 List.289;
let List.339 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.347 List.288;
let List.344 : U8 = 1i64;
let List.345 : U8 = GetTagId List.339;
let List.346 : Int1 = lowlevel Eq List.344 List.345;
if List.346 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.339;
procedure List.77 (List.374, List.375, List.376, List.377, List.378):
joinpoint List.343 List.286 List.287 List.288 List.289 List.290:
let List.345 : Int1 = CallByName Num.22 List.289 List.290;
if List.345 then
let List.354 : {Str} = CallByName List.60 List.286 List.289;
let List.346 : [C [], C {List U8, U64}] = CallByName List.122 List.287 List.354 List.288;
let List.351 : U8 = 1i64;
let List.352 : U8 = GetTagId List.346;
let List.353 : Int1 = lowlevel Eq List.351 List.352;
if List.353 then
let List.291 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.346;
inc List.291;
dec List.339;
let List.342 : U64 = 1i64;
let List.341 : U64 = CallByName Num.19 List.289 List.342;
jump List.336 List.286 List.291 List.288 List.341 List.290;
dec List.346;
let List.349 : U64 = 1i64;
let List.348 : U64 = CallByName Num.19 List.289 List.349;
jump List.343 List.286 List.291 List.288 List.348 List.290;
else
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.339;
dec List.339;
let List.343 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.343;
let List.292 : [] = UnionAtIndex (Id 0) (Index 0) List.346;
dec List.346;
let List.350 : [C [], C {List U8, U64}] = TagId(0) List.292;
ret List.350;
else
let List.337 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.337;
let List.344 : [C [], C {List U8, U64}] = TagId(1) List.287;
ret List.344;
in
jump List.336 List.367 List.368 List.369 List.370 List.371;
jump List.343 List.374 List.375 List.376 List.377 List.378;
procedure List.8 (#Attr.2, #Attr.3):
let List.383 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.383;
let List.336 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.336;
procedure Num.123 (#Attr.2):
let Num.279 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.279;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.267 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.267;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.265 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.265;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.268 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.268;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.266 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
let Num.266 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.266;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.269 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.269;
procedure Num.20 (#Attr.2, #Attr.3):
let Num.267 : U64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.267;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.270 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.270;
procedure Num.24 (#Attr.2, #Attr.3):
let Num.268 : Int1 = lowlevel NumGt #Attr.2 #Attr.3;
ret Num.268;
procedure Str.12 (#Attr.2):
let Str.211 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.211;
let Str.210 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.210;
procedure Str.48 (#Attr.2, #Attr.3, #Attr.4):
let Str.204 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4;

View File

@ -572,8 +572,8 @@ fn quicksort_help() {
(Pair partitionIndex partitioned) = Pair 0 []
partitioned
|> quicksortHelp low (partitionIndex - 1)
|> quicksortHelp (partitionIndex + 1) high
|> quicksortHelp low (partitionIndex - 1)
|> quicksortHelp (partitionIndex + 1) high
else
list
@ -591,8 +591,8 @@ fn quicksort_swap() {
when Pair (List.get list 0) (List.get list 0) is
Pair (Ok atI) (Ok atJ) ->
list
|> List.set 0 atJ
|> List.set 0 atI
|> List.set 0 atJ
|> List.set 0 atI
_ ->
[]

View File

@ -706,6 +706,12 @@ impl GetSubsSlice<Variable> for Subs {
}
}
impl GetSubsSlice<VariableSubsSlice> for Subs {
fn get_subs_slice(&self, subs_slice: SubsSlice<VariableSubsSlice>) -> &[VariableSubsSlice] {
subs_slice.get_slice(&self.variable_slices)
}
}
impl GetSubsSlice<RecordField<()>> for Subs {
fn get_subs_slice(&self, subs_slice: SubsSlice<RecordField<()>>) -> &[RecordField<()>] {
subs_slice.get_slice(&self.record_fields)
@ -3953,12 +3959,15 @@ fn get_fresh_var_name(state: &mut ErrorTypeState) -> Lowercase {
/// - all implicitly exposed variables, which include
/// - ability member specializations
/// - specialization lambda sets under specialization ability members
/// - lambda sets under ability members defined in the module
#[derive(Clone, Debug)]
pub struct ExposedTypesStorageSubs {
pub storage_subs: StorageSubs,
pub stored_vars_by_symbol: VecMap<Symbol, Variable>,
/// lambda set var in other module -> var in storage subs
/// specialization lambda set var in other module -> var in storage subs
pub stored_specialization_lambda_set_vars: VecMap<Variable, Variable>,
/// ability member signature in other module -> var in storage subs
pub stored_ability_member_vars: VecMap<Variable, Variable>,
}
#[derive(Clone, Debug)]
@ -5282,3 +5291,81 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) {
});
}
}
/// Finds the lambda set of the ability member type (not specialization) at the region `r`,
/// or all lambda sets if no region is specified.
///
/// Panics if the given function type does not correspond with what's expected of an ability
/// member, namely its lambda sets have more than a single unspecialized lambda set.
pub fn get_member_lambda_sets_at_region(subs: &Subs, var: Variable, target_region: u8) -> Variable {
let mut stack = vec![var];
while let Some(var) = stack.pop() {
match subs.get_content_without_compacting(var) {
Content::LambdaSet(LambdaSet {
solved,
recursion_var,
unspecialized,
ambient_function: _,
}) => {
debug_assert!(solved.is_empty());
debug_assert!(recursion_var.is_none());
debug_assert_eq!(unspecialized.len(), 1);
let Uls(_, _, region) = subs.get_subs_slice(*unspecialized)[0];
if region == target_region {
return var;
}
}
Content::Structure(flat_type) => match flat_type {
FlatType::Apply(_, vars) => {
stack.extend(subs.get_subs_slice(*vars));
}
FlatType::Func(args, lset, ret) => {
stack.extend(subs.get_subs_slice(*args));
stack.push(*lset);
stack.push(*ret);
}
FlatType::Record(fields, ext) => {
stack.extend(subs.get_subs_slice(fields.variables()));
stack.push(*ext);
}
FlatType::TagUnion(tags, ext) => {
stack.extend(
subs.get_subs_slice(tags.variables())
.iter()
.flat_map(|slice| subs.get_subs_slice(*slice)),
);
stack.push(*ext);
}
FlatType::FunctionOrTagUnion(_, _, ext) => {
stack.push(*ext);
}
FlatType::RecursiveTagUnion(rec, tags, ext) => {
stack.push(*rec);
stack.extend(
subs.get_subs_slice(tags.variables())
.iter()
.flat_map(|slice| subs.get_subs_slice(*slice)),
);
stack.push(*ext);
}
FlatType::Erroneous(_) | FlatType::EmptyRecord | FlatType::EmptyTagUnion => {}
},
Content::Alias(_, _, real_var, _) => {
stack.push(*real_var);
}
Content::RangedNumber(_)
| Content::Error
| Content::FlexVar(_)
| Content::RigidVar(_)
| Content::FlexAbleVar(_, _)
| Content::RigidAbleVar(_, _)
| Content::RecursionVar {
structure: _,
opt_name: _,
} => {}
}
}
internal_error!("No lambda set at region {} found", target_region);
}

View File

@ -2769,8 +2769,16 @@ fn instantiate_lambda_sets_as_unspecialized(
able_var: Variable,
ability_member: Symbol,
) {
// We want to pop and assign lambda sets pre-order for readability, so types
// should be pushed onto the stack in post-order
// REGION-ORDERING: done in pre-order via the following pseudo code:
//
// Type_function = \region ->
// let left_type, new_region = Type (region + 1)
// let right_type, new_region = Type (new_region)
// let func_type = left_type -[Lambda region]-> right_type
// (func_type, new_region)
//
// Since we want to pop types in pre-order, they should be pushed onto the
// stack in post-order
let mut stack = vec![typ];
let mut region = 0;

View File

@ -5,7 +5,7 @@ use roc_debug_flags::dbg_do;
use roc_debug_flags::{ROC_PRINT_MISMATCHES, ROC_PRINT_UNIFICATIONS};
use roc_error_macros::internal_error;
use roc_module::ident::{Lowercase, TagName};
use roc_module::symbol::Symbol;
use roc_module::symbol::{ModuleId, Symbol};
use roc_types::num::{FloatWidth, IntLitWidth, NumericRange};
use roc_types::subs::Content::{self, *};
use roc_types::subs::{
@ -754,6 +754,15 @@ fn unify_alias<M: MetaCollector>(
}
}
#[inline(always)]
fn opaque_obligation(opaque: Symbol, opaque_var: Variable) -> Obligated {
match opaque.module_id() {
// Numbers should be treated as ad-hoc obligations for ability checking.
ModuleId::NUM => Obligated::Adhoc(opaque_var),
_ => Obligated::Opaque(opaque),
}
}
#[inline(always)]
fn unify_opaque<M: MetaCollector>(
subs: &mut Subs,
@ -772,7 +781,7 @@ fn unify_opaque<M: MetaCollector>(
// Alias wins
merge(subs, ctx, Alias(symbol, args, real_var, kind))
}
FlexAbleVar(_, ability) if args.is_empty() => {
FlexAbleVar(_, ability) => {
// Opaque type wins
merge_flex_able_with_concrete(
subs,
@ -780,7 +789,7 @@ fn unify_opaque<M: MetaCollector>(
ctx.second,
*ability,
Alias(symbol, args, real_var, kind),
Obligated::Opaque(symbol),
opaque_obligation(symbol, ctx.first),
)
}
Alias(_, _, other_real_var, AliasKind::Structural) => {
@ -2562,20 +2571,16 @@ fn unify_flex_able<M: MetaCollector>(
RecursionVar { .. } => mismatch!("FlexAble with RecursionVar"),
LambdaSet(..) => mismatch!("FlexAble with LambdaSet"),
Alias(name, args, _real_var, AliasKind::Opaque) => {
if args.is_empty() {
// Opaque type wins
merge_flex_able_with_concrete(
subs,
ctx,
ctx.first,
ability,
*other,
Obligated::Opaque(*name),
)
} else {
mismatch!("FlexAble vs Opaque with type vars")
}
Alias(name, _args, _real_var, AliasKind::Opaque) => {
// Opaque type wins
merge_flex_able_with_concrete(
subs,
ctx,
ctx.first,
ability,
*other,
opaque_obligation(*name, ctx.second),
)
}
Structure(_) | Alias(_, _, _, AliasKind::Structural) | RangedNumber(..) => {

View File

@ -11,21 +11,17 @@ description = "A surgical linker for Roc"
name = "roc_linker"
path = "src/lib.rs"
[[bin]]
name = "link"
path = "src/main.rs"
test = false
bench = false
[dependencies]
roc_mono = { path = "../compiler/mono" }
roc_build = { path = "../compiler/build" }
roc_collections = { path = "../compiler/collections" }
roc_error_macros = { path = "../error_macros" }
bumpalo = { version = "3.8.0", features = ["collections"] }
clap = { version = "3.1.15", default-features = false, features = ["std", "color", "suggestions"] }
iced-x86 = { version = "1.15.0", default-features = false, features = ["std", "decoder", "op_code_info", "instr_info"] }
memmap2 = "0.5.3"
object = { version = "0.29.0", features = ["read", "write"] }
object = { version = "0.26.2", features = ["read", "write"] }
mach_object = "0.1"
serde = { version = "1.0.130", features = ["derive"] }
bincode = "1.3.3"
target-lexicon = "0.12.3"

View File

@ -39,7 +39,7 @@ This linker is run in 2 phases: preprocessing and surigical linking.
- As a prereq, we need roc building on Windows (I'm not sure it does currently).
- Definitely a solid bit different than elf, but hopefully after refactoring for Macho, won't be that crazy to add.
- Look at enabling completely in memory linking that could be used with `roc run` and/or `roc repl`
- Look more into roc hosts and keeping certain functions. Currently I just disabled linker garbage collection.
- Look more into rust hosts and keeping certain functions. Currently I just disabled linker garbage collection.
This works but adds 1.2MB (40%) to even a tiny app. It may be a size issue for large rust hosts.
Roc, for reference, adds 13MB (20%) when linked without garbage collection.
- Add a feature to the compiler to make this linker optional.

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +0,0 @@
use roc_linker::{build_app, preprocess, surgery, CMD_PREPROCESS, CMD_SURGERY};
use std::io;
fn main() -> io::Result<()> {
let matches = build_app().get_matches();
let exit_code = match matches.subcommand() {
None => Ok::<i32, io::Error>(-1),
Some((CMD_PREPROCESS, sub_matches)) => preprocess(sub_matches),
Some((CMD_SURGERY, sub_matches)) => surgery(sub_matches),
_ => unreachable!(),
}?;
std::process::exit(exit_code);
}

View File

@ -34,4 +34,5 @@ pub struct Metadata {
pub dynamic_symbol_table_section_offset: u64,
pub symbol_table_section_offset: u64,
pub symbol_table_size: u64,
pub macho_cmd_loc: u64,
}

View File

@ -14,8 +14,8 @@ quicksortHelp = \list, low, high ->
when partition low high list is
Pair partitionIndex partitioned ->
partitioned
|> quicksortHelp low (partitionIndex - 1)
|> quicksortHelp (partitionIndex + 1) high
|> quicksortHelp low (partitionIndex - 1)
|> quicksortHelp (partitionIndex + 1) high
else
list
@ -50,8 +50,8 @@ swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
list
|> List.set i atJ
|> List.set j atI
|> List.set i atJ
|> List.set j atI
_ ->
# to prevent a decrement on list

View File

@ -23,17 +23,17 @@ initialModel = \start -> {
cheapestOpen : (position -> F64), Model position -> Result position {}
cheapestOpen = \costFn, model ->
model.openSet
|> Set.toList
|> List.keepOks
(\position ->
when Dict.get model.costs position is
Err _ -> Err {}
Ok cost -> Ok { cost: cost + costFn position, position }
)
|> Quicksort.sortBy .cost
|> List.first
|> Result.map .position
|> Result.mapErr (\_ -> {})
|> Set.toList
|> List.keepOks
(\position ->
when Dict.get model.costs position is
Err _ -> Err {}
Ok cost -> Ok { cost: cost + costFn position, position }
)
|> Quicksort.sortBy .cost
|> List.first
|> Result.map .position
|> Result.mapErr (\_ -> {})
reconstructPath : Dict position position, position -> List position
reconstructPath = \cameFrom, goal ->
@ -51,8 +51,8 @@ updateCost = \current, neighbor, model ->
distanceTo =
reconstructPath newCameFrom neighbor
|> List.len
|> Num.toFrac
|> List.len
|> Num.toFrac
newModel =
{ model &

View File

@ -63,23 +63,23 @@ bitsToCharsHelp = \bits, missing ->
# any 6-bit number is a valid base64 digit, so this is actually safe
p =
Num.shiftRightZfBy 18 bits
|> Num.intCast
|> unsafeToChar
|> Num.intCast
|> unsafeToChar
q =
Num.bitwiseAnd (Num.shiftRightZfBy 12 bits) lowest6BitsMask
|> Num.intCast
|> unsafeToChar
|> Num.intCast
|> unsafeToChar
r =
Num.bitwiseAnd (Num.shiftRightZfBy 6 bits) lowest6BitsMask
|> Num.intCast
|> unsafeToChar
|> Num.intCast
|> unsafeToChar
s =
Num.bitwiseAnd bits lowest6BitsMask
|> Num.intCast
|> unsafeToChar
|> Num.intCast
|> unsafeToChar
equals : U8
equals = 61

View File

@ -8,15 +8,15 @@ InvalidChar : U8
toBytes : Str -> List U8
toBytes = \str ->
str
|> Str.toUtf8
|> encodeChunks
|> Bytes.Encode.sequence
|> Bytes.Encode.encode
|> Str.toUtf8
|> encodeChunks
|> Bytes.Encode.sequence
|> Bytes.Encode.encode
encodeChunks : List U8 -> List Encoder
encodeChunks = \bytes ->
List.walk bytes { output: [], accum: None } folder
|> encodeResidual
|> encodeResidual
coerce : Nat, a -> a
coerce = \_, x -> x

View File

@ -49,7 +49,7 @@ encode = \encoder ->
output = List.repeat 0 (getWidth encoder)
encodeHelp encoder 0 output
|> .output
|> .output
encodeHelp : Encoder, Nat, List U8 -> { output : List U8, offset : Nat }
encodeHelp = \encoder, offset, output ->
@ -80,13 +80,13 @@ encodeHelp = \encoder, offset, output ->
when endianness is
BE ->
output
|> List.set (offset + 0) a
|> List.set (offset + 1) b
|> List.set (offset + 0) a
|> List.set (offset + 1) b
LE ->
output
|> List.set (offset + 0) b
|> List.set (offset + 1) a
|> List.set (offset + 0) b
|> List.set (offset + 1) a
{
output: newOutput,
@ -104,13 +104,13 @@ encodeHelp = \encoder, offset, output ->
when endianness is
BE ->
output
|> List.set (offset + 0) a
|> List.set (offset + 1) b
|> List.set (offset + 0) a
|> List.set (offset + 1) b
LE ->
output
|> List.set (offset + 0) b
|> List.set (offset + 1) a
|> List.set (offset + 0) b
|> List.set (offset + 1) a
{
output: newOutput,

View File

@ -14,10 +14,10 @@ main =
optimized = eval (constFolding (reassoc e))
unoptimized
|> Num.toStr
|> Str.concat " & "
|> Str.concat (Num.toStr optimized)
|> Task.putLine
|> Num.toStr
|> Str.concat " & "
|> Str.concat (Num.toStr optimized)
|> Task.putLine
Expr : [
Add Expr Expr,

View File

@ -13,7 +13,7 @@ main = closure1 {}
closure1 : {} -> Task.Task {} []
closure1 = \_ ->
Task.succeed (foo toUnitBorrowed "a long string such that it's malloced")
|> Task.map (\_ -> {})
|> Task.map \_ -> {}
toUnitBorrowed = \x -> Str.countGraphemes x

View File

@ -18,7 +18,7 @@ main =
f = pow x x
nest deriv n f # original koka n = 10
|> Task.map (\_ -> {})
|> Task.map \_ -> {}
nest : (I64, Expr -> IO Expr), I64, Expr -> IO Expr
nest = \f, n, e -> Task.loop { s: n, f, m: n, x: e } nestHelp
@ -160,8 +160,8 @@ deriv = \i, f ->
fprime = d "x" f
line =
Num.toStr (i + 1)
|> Str.concat " count: "
|> Str.concat (Num.toStr (count fprime))
|> Str.concat " count: "
|> Str.concat (Num.toStr (count fprime))
Task.putLine line
|> Task.after \_ -> Task.succeed fprime
|> Task.after \_ -> Task.succeed fprime

View File

@ -9,8 +9,8 @@ main =
Task.getInt
\n ->
queens n # original koka 13
|> Num.toStr
|> Task.putLine
|> Num.toStr
|> Task.putLine
ConsList a : [Nil, Cons a (ConsList a)]

View File

@ -7,8 +7,8 @@ show = \list ->
else
content =
list
|> List.map Num.toStr
|> Str.joinWith ", "
|> List.map Num.toStr
|> Str.joinWith ", "
"[\(content)]"
@ -30,8 +30,8 @@ quicksortHelp = \list, order, low, high ->
when partition low high list order is
Pair partitionIndex partitioned ->
partitioned
|> quicksortHelp order low (Num.subSaturated partitionIndex 1)
|> quicksortHelp order (partitionIndex + 1) high
|> quicksortHelp order low (Num.subSaturated partitionIndex 1)
|> quicksortHelp order (partitionIndex + 1) high
else
list
@ -68,8 +68,8 @@ swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
list
|> List.set i atJ
|> List.set j atI
|> List.set i atJ
|> List.set j atI
_ ->
[]

File diff suppressed because one or more lines are too long

View File

@ -52,8 +52,8 @@ main =
val = fold (\_, v, r -> if v then r + 1 else r) head 0
val
|> Num.toStr
|> Task.putLine
|> Num.toStr
|> Task.putLine
Nil ->
Task.putLine "fail"

View File

@ -20,8 +20,8 @@ main =
val = fold (\_, v, r -> if v then r + 1 else r) m 0
val
|> Num.toStr
|> Task.putLine
|> Num.toStr
|> Task.putLine
boom : Str -> a
boom = \_ -> boom ""

View File

@ -9,8 +9,8 @@ main =
tree = insert 0 {} Empty
tree
|> show
|> Task.putLine
|> show
|> Task.putLine
show : RedBlackTree I64 {} -> Str
show = \tree -> showRBTree tree Num.toStr (\{} -> "{}")

View File

@ -8,11 +8,11 @@ forever : Task val err -> Task * err
forever = \task ->
looper = \{} ->
task
|> Effect.map
\res ->
when res is
Ok _ -> Step {}
Err e -> Done (Err e)
|> Effect.map
\res ->
when res is
Ok _ -> Step {}
Err e -> Done (Err e)
Effect.loop {} looper
@ -20,12 +20,12 @@ loop : state, (state -> Task [Step state, Done done] err) -> Task done err
loop = \state, step ->
looper = \current ->
step current
|> Effect.map
\res ->
when res is
Ok (Step newState) -> Step newState
Ok (Done result) -> Done (Ok result)
Err e -> Done (Err e)
|> Effect.map
\res ->
when res is
Ok (Step newState) -> Step newState
Ok (Done result) -> Done (Ok result)
Err e -> Done (Err e)
Effect.loop state looper

View File

@ -64,7 +64,7 @@ update = \model, event ->
tick : Model -> Model
tick = \model ->
model
|> moveBall
|> moveBall
moveBall : Model -> Model
moveBall = \model ->
@ -99,12 +99,12 @@ render = \model ->
\index ->
col =
Num.rem index numCols
|> Num.toF32
|> Num.toF32
row =
index
// numCols
|> Num.toF32
// numCols
|> Num.toF32
red = col / Num.toF32 numCols
green = row / Num.toF32 numRows

View File

@ -90,8 +90,8 @@ translate = \child, toChild, toParent ->
Button config label ->
onPress = \parentState, event ->
toChild parentState
|> config.onPress event
|> Action.map \c -> toParent parentState c
|> config.onPress event
|> Action.map \c -> toParent parentState c
Button { onPress } (translate label toChild toParent)
@ -136,8 +136,8 @@ list = \renderChild, parent, toChildren, toParent ->
toChild
\par, ch ->
toChildren par
|> List.set ch index
|> toParent
|> List.set ch index
|> toParent
renderChild newChild
@ -165,8 +165,8 @@ translateOrDrop = \child, toChild, toParent ->
when toChild parentState is
Ok newChild ->
newChild
|> config.onPress event
|> Action.map \c -> toParent parentState c
|> config.onPress event
|> Action.map \c -> toParent parentState c
Err _ ->
# The child was removed from the list before this onPress handler resolved.
@ -182,7 +182,7 @@ translateOrDrop = \child, toChild, toParent ->
when toChild parentState is
Ok newChild ->
renderChild newChild
|> translateOrDrop toChild toParent
|> translateOrDrop toChild toParent
Err _ ->
None

View File

@ -21,7 +21,7 @@ InterpreterErrors : [BadUtf8, DivByZero, EmptyStack, InvalidBooleanValue, Invali
main : Str -> Task {} []
main = \filename ->
interpretFile filename
|> Task.onFail (\StringErr e -> Stdout.line "Ran into problem:\n\(e)\n")
|> Task.onFail \StringErr e -> Stdout.line "Ran into problem:\n\(e)\n"
interpretFile : Str -> Task {} [StringErr Str]
interpretFile = \filename ->
@ -70,19 +70,19 @@ interpretFile = \filename ->
isDigit : U8 -> Bool
isDigit = \char ->
char
>= 0x30 # `0`
&& char
<= 0x39 # `0`
>= 0x30 # `0`
&& char
<= 0x39 # `0`
isWhitespace : U8 -> Bool
isWhitespace = \char ->
char
== 0xA # new line
|| char
== 0xB # carriage return
|| char
== 0x20 # space
|| char
== 0x9 # tab
== 0xA # new line
|| char
== 0xB # carriage return
|| char
== 0x20 # space
|| char
== 0x9 # tab
interpretCtx : Context -> Task Context InterpreterErrors
interpretCtx = \ctx ->
Task.loop ctx interpretCtxLoop

View File

@ -9,8 +9,8 @@ Variable := U8
totalCount : Nat
totalCount =
0x7A # "z"
- 0x61 # "a"
+ 1
- 0x61 # "a"
+ 1
toStr : Variable -> Str
toStr = \@Variable char ->
@ -22,10 +22,9 @@ fromUtf8 : U8 -> Result Variable [InvalidVariableUtf8]
fromUtf8 = \char ->
if
char
>= 0x61 # "a"
&& char
<= 0x7A
# "z"
>= 0x61 # "a"
&& char
<= 0x7A # "z"
then
Ok (@Variable char)
else

View File

@ -13,8 +13,8 @@ chunk = \@Handle handle -> Effect.after (Effect.getFileBytes handle) Task.succee
open : Str -> Task.Task Handle *
open = \path ->
Effect.openFile path
|> Effect.map (\id -> @Handle id)
|> Effect.after Task.succeed
|> Effect.map (\id -> @Handle id)
|> Effect.after Task.succeed
close : Handle -> Task.Task {} *
close = \@Handle handle -> Effect.after (Effect.closeFile handle) Task.succeed

View File

@ -8,12 +8,12 @@ loop : state, (state -> Task [Step state, Done done] err) -> Task done err
loop = \state, step ->
looper = \current ->
step current
|> Effect.map
\res ->
when res is
Ok (Step newState) -> Step newState
Ok (Done result) -> Done (Ok result)
Err e -> Done (Err e)
|> Effect.map
\res ->
when res is
Ok (Step newState) -> Step newState
Ok (Done result) -> Done (Ok result)
Err e -> Done (Err e)
Effect.loop state looper

View File

@ -90,8 +90,8 @@ translate = \child, toChild, toParent ->
Button config label ->
onPress = \parentState, event ->
toChild parentState
|> config.onPress event
|> Action.map \c -> toParent parentState c
|> config.onPress event
|> Action.map \c -> toParent parentState c
Button { onPress } (translate label toChild toParent)
@ -136,8 +136,8 @@ list = \renderChild, parent, toChildren, toParent ->
toChild
\par, ch ->
toChildren par
|> List.set ch index
|> toParent
|> List.set ch index
|> toParent
renderChild newChild
@ -165,8 +165,8 @@ translateOrDrop = \child, toChild, toParent ->
when toChild parentState is
Ok newChild ->
newChild
|> config.onPress event
|> Action.map \c -> toParent parentState c
|> config.onPress event
|> Action.map \c -> toParent parentState c
Err _ ->
# The child was removed from the list before this onPress handler resolved.
@ -182,7 +182,7 @@ translateOrDrop = \child, toChild, toParent ->
when toChild parentState is
Ok newChild ->
renderChild newChild
|> translateOrDrop toChild toParent
|> translateOrDrop toChild toParent
Err _ ->
None

View File

@ -226,37 +226,37 @@ append = \@Path prefix, @Path suffix ->
NoInteriorNul suffixBytes ->
# Neither prefix nor suffix had interior nuls, so the answer won't either
List.append prefixBytes suffixBytes
|> NoInteriorNul
|> NoInteriorNul
ArbitraryBytes suffixBytes ->
List.append prefixBytes suffixBytes
|> ArbitraryBytes
|> ArbitraryBytes
FromStr suffixStr ->
# Append suffixStr by writing it to the end of prefixBytes
Str.writeUtf8 suffixStr prefixBytes (List.len prefixBytes)
|> ArbitraryBytes
|> ArbitraryBytes
ArbitraryBytes prefixBytes ->
when suffix is
ArbitraryBytes suffixBytes | NoInteriorNul suffixBytes ->
List.append prefixBytes suffixBytes
|> ArbitraryBytes
|> ArbitraryBytes
FromStr suffixStr ->
# Append suffixStr by writing it to the end of prefixBytes
Str.writeUtf8 suffixStr prefixBytes (List.len prefixBytes)
|> ArbitraryBytes
|> ArbitraryBytes
FromStr prefixStr ->
when suffix is
ArbitraryBytes suffixBytes | NoInteriorNul suffixBytes ->
List.append (Str.toUtf8 prefixStr) suffixBytes
|> ArbitraryBytes
|> ArbitraryBytes
FromStr suffixStr ->
Str.append prefixStr suffixStr
|> FromStr
|> FromStr
@Path content
@ -267,11 +267,11 @@ appendStr = \@Path prefix, suffixStr ->
NoInteriorNul prefixBytes | ArbitraryBytes prefixBytes ->
# Append suffixStr by writing it to the end of prefixBytes
Str.writeUtf8 suffixStr prefixBytes (List.len prefixBytes)
|> ArbitraryBytes
|> ArbitraryBytes
FromStr prefixStr ->
Str.append prefixStr suffixStr
|> FromStr
|> FromStr
@Path content
@ -354,9 +354,9 @@ withExtension = \@Path path, extension ->
Err NotFound -> list
beforeDot
|> List.reserve (1 + List.len bytes)
|> List.append '.'
|> List.concat bytes
|> List.reserve (1 + List.len bytes)
|> List.append '.'
|> List.concat bytes
FromStr str ->
beforeDot =
@ -365,9 +365,9 @@ withExtension = \@Path path, extension ->
Err NotFound -> str
beforeDot
|> Str.reserve (1 + Str.byteCount str)
|> Str.append "."
|> Str.concat str
|> Str.reserve (1 + Str.byteCount str)
|> Str.append "."
|> Str.concat str
# NOTE: no withExtensionBytes because it's too narrow. If you really need to get some
# non-Unicode in there, do it with

View File

@ -5,5 +5,5 @@ interface Stdin
line : Task Str * [Read [Stdin]*]*
line =
Effect.getLine
|> Effect.map Ok
|> InternalTask.fromEffect
|> Effect.map Ok
|> InternalTask.fromEffect

View File

@ -5,4 +5,4 @@ interface Stdout
line : Str -> Task {} * [Write [Stdout]*]*
line = \str ->
Effect.map (Effect.putLine str) (\_ -> Ok {})
|> InternalTask.fromEffect
|> InternalTask.fromEffect

View File

@ -8,40 +8,40 @@ forever : Task val err fx -> Task * err fx
forever = \task ->
looper = \{} ->
task
|> InternalTask.toEffect
|> Effect.map
\res ->
when res is
Ok _ -> Step {}
Err e -> Done (Err e)
|> InternalTask.toEffect
|> Effect.map
\res ->
when res is
Ok _ -> Step {}
Err e -> Done (Err e)
Effect.loop {} looper
|> InternalTask.fromEffect
|> InternalTask.fromEffect
loop : state, (state -> Task [Step state, Done done] err fx) -> Task done err fx
loop = \state, step ->
looper = \current ->
step current
|> InternalTask.toEffect
|> Effect.map
\res ->
when res is
Ok (Step newState) -> Step newState
Ok (Done result) -> Done (Ok result)
Err e -> Done (Err e)
|> InternalTask.toEffect
|> Effect.map
\res ->
when res is
Ok (Step newState) -> Step newState
Ok (Done result) -> Done (Ok result)
Err e -> Done (Err e)
Effect.loop state looper
|> InternalTask.fromEffect
|> InternalTask.fromEffect
succeed : val -> Task val * *
succeed = \val ->
Effect.always (Ok val)
|> InternalTask.fromEffect
|> InternalTask.fromEffect
fail : err -> Task * err *
fail = \val ->
Effect.always (Err val)
|> InternalTask.fromEffect
|> InternalTask.fromEffect
attempt : Task a b fx, (Result a b -> Task c d fx) -> Task c d fx
attempt = \task, transform ->

View File

@ -104,17 +104,17 @@ append = \@Url urlStr, suffixUnencoded ->
Ok { before, after } ->
bytes =
Str.countUtf8Bytes before
+ 1 # for "/"
+ Str.countUtf8Bytes suffix
+ 1 # for "?"
+ Str.countUtf8Bytes after
+ 1 # for "/"
+ Str.countUtf8Bytes suffix
+ 1 # for "?"
+ Str.countUtf8Bytes after
before
|> Str.reserve bytes
|> appendHelp suffix
|> Str.concat "?"
|> Str.concat after
|> @Url
|> Str.reserve bytes
|> appendHelp suffix
|> Str.concat "?"
|> Str.concat after
|> @Url
Err NotFound ->
# There wasn't a query, but there might still be a fragment
@ -122,17 +122,17 @@ append = \@Url urlStr, suffixUnencoded ->
Ok { before, after } ->
bytes =
Str.countUtf8Bytes before
+ 1 # for "/"
+ Str.countUtf8Bytes suffix
+ 1 # for "#"
+ Str.countUtf8Bytes after
+ 1 # for "/"
+ Str.countUtf8Bytes suffix
+ 1 # for "#"
+ Str.countUtf8Bytes after
before
|> Str.reserve bytes
|> appendHelp suffix
|> Str.concat "#"
|> Str.concat after
|> @Url
|> Str.reserve bytes
|> appendHelp suffix
|> Str.concat "#"
|> Str.concat after
|> @Url
Err NotFound ->
# No query and no fragment, so just append it
@ -169,8 +169,8 @@ appendHelp = \prefix, suffix ->
else
# Neither is empty, but neither has a "/", so add one in between.
prefix
|> Str.concat "/"
|> Str.concat suffix
|> Str.concat "/"
|> Str.concat suffix
## Internal helper. This is intentionally unexposed so that you don't accidentally
## double-encode things. If you really want to percent-encode an arbitrary string,
@ -194,30 +194,30 @@ percentEncode = \input ->
# Spec for percent-encoding: https://www.ietf.org/rfc/rfc3986.txt
if
(byte >= 97 && byte <= 122) # lowercase ASCII
|| (byte >= 65 && byte <= 90) # uppercase ASCII
|| (byte >= 48 && byte <= 57) # digit
|| (byte >= 65 && byte <= 90) # uppercase ASCII
|| (byte >= 48 && byte <= 57) # digit
then
# This is the most common case: an unreserved character,
# which needs no encoding in a path
Str.appendScalar output (Num.toU32 byte)
|> Result.withDefault "" # this will never fail
|> Result.withDefault "" # this will never fail
else
when byte is
46 # '.'
| 95 # '_'
| 126 # '~'
| 150 -> # '-'
| 95 # '_'
| 126 # '~'
| 150 -> # '-'
# These special characters can all be unescaped in paths
Str.appendScalar output (Num.toU32 byte)
|> Result.withDefault "" # this will never fail
|> Result.withDefault "" # this will never fail
_ ->
# This needs encoding in a path
suffix =
Str.toUtf8 percentEncoded
|> List.sublist { len: 3, start: 3 * Num.toNat byte }
|> Str.fromUtf8
|> Result.withDefault "" # This will never fail
|> List.sublist { len: 3, start: 3 * Num.toNat byte }
|> Str.fromUtf8
|> Result.withDefault "" # This will never fail
Str.concat output suffix
@ -251,20 +251,20 @@ appendParam = \@Url urlStr, key, value ->
bytes =
Str.countUtf8Bytes withoutFragment
+ 1 # for "?" or "&"
+ Str.countUtf8Bytes encodedKey
+ 1 # for "="
+ Str.countUtf8Bytes encodedValue
+ Str.countUtf8Bytes afterQuery
+ 1 # for "?" or "&"
+ Str.countUtf8Bytes encodedKey
+ 1 # for "="
+ Str.countUtf8Bytes encodedValue
+ Str.countUtf8Bytes afterQuery
withoutFragment
|> Str.reserve bytes
|> Str.concat (if hasQuery (@Url withoutFragment) then "&" else "?")
|> Str.concat encodedKey
|> Str.concat "="
|> Str.concat encodedValue
|> Str.concat afterQuery
|> @Url
|> Str.reserve bytes
|> Str.concat (if hasQuery (@Url withoutFragment) then "&" else "?")
|> Str.concat encodedKey
|> Str.concat "="
|> Str.concat encodedValue
|> Str.concat afterQuery
|> @Url
## Replaces the URL's [query](https://en.wikipedia.org/wiki/URL#Syntax)—the part after
## the `?`, if it has one, but before any `#` it might have.
@ -300,16 +300,16 @@ withQuery = \@Url urlStr, queryStr ->
else
bytes =
Str.countUtf8Bytes beforeQuery
+ 1 # for "?"
+ Str.countUtf8Bytes queryStr
+ Str.countUtf8Bytes afterQuery
+ 1 # for "?"
+ Str.countUtf8Bytes queryStr
+ Str.countUtf8Bytes afterQuery
beforeQuery
|> Str.reserve bytes
|> Str.concat "?"
|> Str.concat queryStr
|> Str.concat afterQuery
|> @Url
|> Str.reserve bytes
|> Str.concat "?"
|> Str.concat queryStr
|> Str.concat afterQuery
|> @Url
## Returns the URL's [query](https://en.wikipedia.org/wiki/URL#Syntax)—the part after
## the `?`, if it has one, but before any `#` it might have.
@ -348,7 +348,7 @@ hasQuery = \@Url urlStr ->
# TODO use Str.contains once it exists. It should have a "fast path"
# with SIMD iteration if the string is small enough to fit in a SIMD register.
Str.toUtf8 urlStr
|> List.contains (Num.toU8 '?')
|> List.contains (Num.toU8 '?')
## Returns the URL's [fragment](https://en.wikipedia.org/wiki/URL#Syntax)—the part after
## the `#`, if it has one.
@ -418,7 +418,7 @@ hasFragment = \@Url urlStr ->
# TODO use Str.contains once it exists. It should have a "fast path"
# with SIMD iteration if the string is small enough to fit in a SIMD register.
Str.toUtf8 urlStr
|> List.contains (Num.toU8 '#')
|> List.contains (Num.toU8 '#')
strWithCapacity : Nat -> Str
strWithCapacity = \cap ->

View File

@ -21,13 +21,13 @@ echo = \shout ->
List.repeat spaceInUtf8 length
shout
|> Str.toUtf8
|> List.mapWithIndex
(\_, i ->
length = (List.len (Str.toUtf8 shout) - i)
phrase = (List.split (Str.toUtf8 shout) length).before
|> Str.toUtf8
|> List.mapWithIndex
(\_, i ->
length = (List.len (Str.toUtf8 shout) - i)
phrase = (List.split (Str.toUtf8 shout) length).before
List.concat (silence (if i == 0 then 2 * length else length)) phrase)
|> List.join
|> Str.fromUtf8
|> Result.withDefault ""
List.concat (silence (if i == 0 then 2 * length else length)) phrase)
|> List.join
|> Str.fromUtf8
|> Result.withDefault ""