mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 22:43:42 +08:00
Renaming: iterables to sequences
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)),
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <iterable>)`, 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 <sequence>)`, 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"
|
||||
};
|
||||
|
||||
@@ -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<CallableType> {
|
||||
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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user