From 1da7145fe607b446cdf3b56f5a7d0d2db0e02b81 Mon Sep 17 00:00:00 2001 From: Ludo Galabru Date: Thu, 30 Jul 2020 02:31:16 -0400 Subject: [PATCH] Renaming: iterables to sequences --- sip/sip-006-runtime-cost-assessment.md | 2 +- sip/sip-008-analysis-cost-assessment.md | 6 +++--- src/vm/analysis/type_checker/natives/mod.rs | 16 ++++++++-------- .../natives/{iterables.rs => sequences.rs} | 8 ++++---- src/vm/docs/mod.rs | 4 ++-- src/vm/functions/mod.rs | 18 +++++++++--------- .../functions/{iterables.rs => sequences.rs} | 0 src/vm/tests/mod.rs | 2 +- src/vm/tests/{iterables.rs => sequences.rs} | 0 9 files changed, 28 insertions(+), 28 deletions(-) rename src/vm/analysis/type_checker/natives/{iterables.rs => sequences.rs} (98%) rename src/vm/functions/{iterables.rs => sequences.rs} (100%) rename src/vm/tests/{iterables.rs => sequences.rs} (100%) diff --git a/sip/sip-006-runtime-cost-assessment.md b/sip/sip-006-runtime-cost-assessment.md index f6b33d093..51d794178 100644 --- a/sip/sip-006-runtime-cost-assessment.md +++ b/sip/sip-006-runtime-cost-assessment.md @@ -485,7 +485,7 @@ X := the size of the list _entry_ type ### concat The cost of concatting two lists or buffers is linear in -the size of the two iterables: +the size of the two sequences: ``` a + b * (X+Y) diff --git a/sip/sip-008-analysis-cost-assessment.md b/sip/sip-008-analysis-cost-assessment.md index d2c3ce055..1b0ea1985 100644 --- a/sip/sip-008-analysis-cost-assessment.md +++ b/sip/sip-008-analysis-cost-assessment.md @@ -222,9 +222,9 @@ checking pass. Some functions require additional work from the static analysis system. -## Functions on iterables (e.g., map, filter, fold) +## Functions on sequences (e.g., map, filter, fold) -Functions on iterables need to perform an additional check that the +Functions on sequences need to perform an additional check that the supplied type is a list or buffer before performing the normal argument type checking. This cost is assessed as: @@ -236,7 +236,7 @@ where a is a constant. ## Functions on options/responses -Similarly to the functions on iterables, option/response functions +Similarly to the functions on sequences, option/response functions must perform a simple check to see if the supplied input is an option or response before performing additional argument type checking. This cost is assessed as: diff --git a/src/vm/analysis/type_checker/natives/mod.rs b/src/vm/analysis/type_checker/natives/mod.rs index cfdf7b633..4b107596c 100644 --- a/src/vm/analysis/type_checker/natives/mod.rs +++ b/src/vm/analysis/type_checker/natives/mod.rs @@ -12,7 +12,7 @@ use std::convert::TryFrom; use vm::costs::{cost_functions, analysis_typecheck_cost, CostOverflowingMath}; mod assets; -mod iterables; +mod sequences; mod maps; mod options; @@ -415,13 +415,13 @@ impl TypedNativeFunction { Let => Special(SpecialNativeFunction(&check_special_let)), FetchVar => Special(SpecialNativeFunction(&check_special_fetch_var)), SetVar => Special(SpecialNativeFunction(&check_special_set_var)), - Map => Special(SpecialNativeFunction(&iterables::check_special_map)), - Filter => Special(SpecialNativeFunction(&iterables::check_special_filter)), - Fold => Special(SpecialNativeFunction(&iterables::check_special_fold)), - Append => Special(SpecialNativeFunction(&iterables::check_special_append)), - Concat => Special(SpecialNativeFunction(&iterables::check_special_concat)), - AsMaxLen => Special(SpecialNativeFunction(&iterables::check_special_as_max_len)), - Len => Special(SpecialNativeFunction(&iterables::check_special_len)), + Map => Special(SpecialNativeFunction(&sequences::check_special_map)), + Filter => Special(SpecialNativeFunction(&sequences::check_special_filter)), + Fold => Special(SpecialNativeFunction(&sequences::check_special_fold)), + Append => Special(SpecialNativeFunction(&sequences::check_special_append)), + Concat => Special(SpecialNativeFunction(&sequences::check_special_concat)), + AsMaxLen => Special(SpecialNativeFunction(&sequences::check_special_as_max_len)), + Len => Special(SpecialNativeFunction(&sequences::check_special_len)), ListCons => Special(SpecialNativeFunction(&check_special_list_cons)), FetchEntry => Special(SpecialNativeFunction(&maps::check_special_fetch_entry)), SetEntry => Special(SpecialNativeFunction(&maps::check_special_set_entry)), diff --git a/src/vm/analysis/type_checker/natives/iterables.rs b/src/vm/analysis/type_checker/natives/sequences.rs similarity index 98% rename from src/vm/analysis/type_checker/natives/iterables.rs rename to src/vm/analysis/type_checker/natives/sequences.rs index e85ffe93f..689caf61e 100644 --- a/src/vm/analysis/type_checker/natives/iterables.rs +++ b/src/vm/analysis/type_checker/natives/sequences.rs @@ -208,10 +208,10 @@ pub fn check_special_as_max_len(checker: &mut TypeChecker, args: &[SymbolicExpre let expected_len = u32::try_from(expected_len) .map_err(|_e| CheckErrors::MaxLengthOverflow)?; - let iterable = checker.type_check(&args[0], context)?; - analysis_typecheck_cost(checker, &iterable, &iterable)?; + let sequence = checker.type_check(&args[0], context)?; + analysis_typecheck_cost(checker, &sequence, &sequence)?; - match iterable { + match sequence { TypeSignature::SequenceType(ListType(list)) => { let (lhs_entry_type, _) = list.destruct(); let resized_list = ListTypeData::new_list(lhs_entry_type, expected_len)?; @@ -226,7 +226,7 @@ pub fn check_special_as_max_len(checker: &mut TypeChecker, args: &[SymbolicExpre TypeSignature::SequenceType(StringType(UTF8(_))) => { Ok(TypeSignature::OptionalType(Box::new(TypeSignature::SequenceType(StringType(UTF8(StringUTF8Length::try_from(expected_len).unwrap())))))) }, - _ => Err(CheckErrors::ExpectedSequence(iterable).into()) + _ => Err(CheckErrors::ExpectedSequence(sequence).into()) } } diff --git a/src/vm/docs/mod.rs b/src/vm/docs/mod.rs index 479a1dafd..6eeb04ffe 100644 --- a/src/vm/docs/mod.rs +++ b/src/vm/docs/mod.rs @@ -416,8 +416,8 @@ const ASSERTS_MAX_LEN_API: SpecialAPI = SpecialAPI { description: "The `as-max-len?` function takes a length N (must be a literal) and a buffer or list argument, which must be typed as a list or buffer of length M and outputs that same list or buffer, but typed with max length N. -This function returns an optional type with the resulting iterable. If the input iterable is less than -or equal to the supplied max-len, it returns `(some )`, otherwise it returns `none`.", +This function returns an optional type with the resulting sequence. If the input sequence is less than +or equal to the supplied max-len, it returns `(some )`, otherwise it returns `none`.", example: "(as-max-len? (list 2 2 2) u3) ;; Returns (some (2 2 2)) (as-max-len? (list 1 2 3) u2) ;; Returns none" }; diff --git a/src/vm/functions/mod.rs b/src/vm/functions/mod.rs index a9560e3a3..e72c468b0 100644 --- a/src/vm/functions/mod.rs +++ b/src/vm/functions/mod.rs @@ -1,6 +1,6 @@ pub mod define; pub mod tuples; -mod iterables; +mod sequences; mod arithmetic; mod boolean; mod database; @@ -116,14 +116,14 @@ pub fn lookup_reserved_functions(name: &str) -> Option { Let => SpecialFunction("special_let", &special_let), FetchVar => SpecialFunction("special_var-get", &database::special_fetch_variable), SetVar => SpecialFunction("special_set-var", &database::special_set_variable), - Map => SpecialFunction("special_map", &iterables::special_map), - Filter => SpecialFunction("special_filter", &iterables::special_filter), - Fold => SpecialFunction("special_fold", &iterables::special_fold), - Concat => SpecialFunction("special_concat", &iterables::special_concat), - AsMaxLen => SpecialFunction("special_as_max_len", &iterables::special_as_max_len), - Append => SpecialFunction("special_append", &iterables::special_append), - Len => NativeFunction("native_len", NativeHandle::SingleArg(&iterables::native_len), cost_functions::LEN), - ListCons => SpecialFunction("special_list_cons", &iterables::list_cons), + Map => SpecialFunction("special_map", &sequences::special_map), + Filter => SpecialFunction("special_filter", &sequences::special_filter), + Fold => SpecialFunction("special_fold", &sequences::special_fold), + Concat => SpecialFunction("special_concat", &sequences::special_concat), + AsMaxLen => SpecialFunction("special_as_max_len", &sequences::special_as_max_len), + Append => SpecialFunction("special_append", &sequences::special_append), + Len => NativeFunction("native_len", NativeHandle::SingleArg(&sequences::native_len), cost_functions::LEN), + ListCons => SpecialFunction("special_list_cons", &sequences::list_cons), FetchEntry => SpecialFunction("special_map-get?", &database::special_fetch_entry), SetEntry => SpecialFunction("special_set-entry", &database::special_set_entry), InsertEntry => SpecialFunction("special_insert-entry", &database::special_insert_entry), diff --git a/src/vm/functions/iterables.rs b/src/vm/functions/sequences.rs similarity index 100% rename from src/vm/functions/iterables.rs rename to src/vm/functions/sequences.rs diff --git a/src/vm/tests/mod.rs b/src/vm/tests/mod.rs index 9485479a9..c399540c6 100644 --- a/src/vm/tests/mod.rs +++ b/src/vm/tests/mod.rs @@ -15,7 +15,7 @@ use chainstate::stacks::StacksBlockId; mod forking; mod assets; mod events; -mod iterables; +mod sequences; mod defines; mod simple_apply_eval; mod datamaps; diff --git a/src/vm/tests/iterables.rs b/src/vm/tests/sequences.rs similarity index 100% rename from src/vm/tests/iterables.rs rename to src/vm/tests/sequences.rs