mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 15:20:16 +00:00
feat(air-parser)!: optimize Instruction type layout (#767)
Instead of being boxed for each node, the `Instruction` type contains a boxed variable-size elements. Thus `Instruction` is quite lean, and the allocator deals with variable-sized elements. Total number of allocations is more or less same, but less space is wasted for unused memory: previously the Instruction's size was 112 bytes in WASM, now it is 16. It reduces memory consumption on large AIR scripts (heap size decreased from 7.7MiB to 4.625MiB in parser-10000-100, and for the new parser-calls-10000-100 benchmark, it decreased from 5.115MiB to 4.375MiB). This is a breaking change as the API changes (though the code that navigates the parsed tree generally should work as is).
This commit is contained in:
parent
f1b6c48987
commit
1673cdf06c
@ -70,7 +70,7 @@ pub mod parser {
|
||||
pub use air_parser::ast::Instruction;
|
||||
|
||||
/// Parse an AIR script to AST.
|
||||
pub fn parse(script: &str) -> Result<Box<Instruction<'_>>, String> {
|
||||
pub fn parse(script: &str) -> Result<Instruction<'_>, String> {
|
||||
air_parser::parse(script)
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ pub(crate) fn prepare<'i>(
|
||||
run_parameters: RunParameters,
|
||||
signature_store: SignatureStore,
|
||||
) -> PreparationResult<PreparationDescriptor<'static, 'i>> {
|
||||
let air: Instruction<'i> = *air_parser::parse(raw_air).map_err(PreparationError::AIRParseError)?;
|
||||
let air: Instruction<'i> = air_parser::parse(raw_air).map_err(PreparationError::AIRParseError)?;
|
||||
|
||||
let prev_ingredients = ExecCtxIngredients {
|
||||
last_call_request_id: prev_data.last_call_request_id,
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -14,11 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#[macro_use]
|
||||
extern crate fstrings;
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use air_parser::ast::Instruction;
|
||||
use criterion::criterion_group;
|
||||
use criterion::criterion_main;
|
||||
use criterion::Criterion;
|
||||
|
@ -27,24 +27,24 @@ use std::rc::Rc;
|
||||
#[allow(clippy::large_enum_variant)] // for Null and Error variants
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
pub enum Instruction<'i> {
|
||||
Call(Call<'i>),
|
||||
Ap(Ap<'i>),
|
||||
ApMap(ApMap<'i>),
|
||||
Canon(Canon<'i>),
|
||||
CanonMap(CanonMap<'i>),
|
||||
CanonStreamMapScalar(CanonStreamMapScalar<'i>),
|
||||
Seq(Seq<'i>),
|
||||
Par(Par<'i>),
|
||||
Xor(Xor<'i>),
|
||||
Match(Match<'i>),
|
||||
MisMatch(MisMatch<'i>),
|
||||
Fail(Fail<'i>),
|
||||
FoldScalar(FoldScalar<'i>),
|
||||
FoldStream(FoldStream<'i>),
|
||||
FoldStreamMap(FoldStreamMap<'i>),
|
||||
Call(Box<Call<'i>>),
|
||||
Ap(Box<Ap<'i>>),
|
||||
ApMap(Box<ApMap<'i>>),
|
||||
Canon(Box<Canon<'i>>),
|
||||
CanonMap(Box<CanonMap<'i>>),
|
||||
CanonStreamMapScalar(Box<CanonStreamMapScalar<'i>>),
|
||||
Seq(Box<Seq<'i>>),
|
||||
Par(Box<Par<'i>>),
|
||||
Xor(Box<Xor<'i>>),
|
||||
Match(Box<Match<'i>>),
|
||||
MisMatch(Box<MisMatch<'i>>),
|
||||
Fail(Box<Fail<'i>>),
|
||||
FoldScalar(Box<FoldScalar<'i>>),
|
||||
FoldStream(Box<FoldStream<'i>>),
|
||||
FoldStreamMap(Box<FoldStreamMap<'i>>),
|
||||
Never(Never),
|
||||
New(New<'i>),
|
||||
Next(Next<'i>),
|
||||
New(Box<New<'i>>),
|
||||
Next(Box<Next<'i>>),
|
||||
Null(Null),
|
||||
Error,
|
||||
}
|
||||
@ -98,22 +98,22 @@ pub struct CanonStreamMapScalar<'i> {
|
||||
|
||||
/// (seq instruction instruction)
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
pub struct Seq<'i>(pub Box<Instruction<'i>>, pub Box<Instruction<'i>>);
|
||||
pub struct Seq<'i>(pub Instruction<'i>, pub Instruction<'i>);
|
||||
|
||||
/// (par instruction instruction)
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
pub struct Par<'i>(pub Box<Instruction<'i>>, pub Box<Instruction<'i>>);
|
||||
pub struct Par<'i>(pub Instruction<'i>, pub Instruction<'i>);
|
||||
|
||||
/// (xor instruction instruction)
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
pub struct Xor<'i>(pub Box<Instruction<'i>>, pub Box<Instruction<'i>>);
|
||||
pub struct Xor<'i>(pub Instruction<'i>, pub Instruction<'i>);
|
||||
|
||||
/// (match left_value right_value instruction)
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
pub struct Match<'i> {
|
||||
pub left_value: ImmutableValue<'i>,
|
||||
pub right_value: ImmutableValue<'i>,
|
||||
pub instruction: Box<Instruction<'i>>,
|
||||
pub instruction: Instruction<'i>,
|
||||
}
|
||||
|
||||
/// (mismatch left_value right_value instruction)
|
||||
@ -121,7 +121,7 @@ pub struct Match<'i> {
|
||||
pub struct MisMatch<'i> {
|
||||
pub left_value: ImmutableValue<'i>,
|
||||
pub right_value: ImmutableValue<'i>,
|
||||
pub instruction: Box<Instruction<'i>>,
|
||||
pub instruction: Instruction<'i>,
|
||||
}
|
||||
|
||||
/// (fail 1337 "error message")
|
||||
@ -191,7 +191,7 @@ pub struct Never;
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
pub struct New<'i> {
|
||||
pub argument: NewArgument<'i>,
|
||||
pub instruction: Box<Instruction<'i>>,
|
||||
pub instruction: Instruction<'i>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
@ -85,28 +85,19 @@ impl<'i> CanonStreamMapScalar<'i> {
|
||||
}
|
||||
|
||||
impl<'i> Seq<'i> {
|
||||
pub fn new(
|
||||
left_instruction: Box<Instruction<'i>>,
|
||||
right_instruction: Box<Instruction<'i>>,
|
||||
) -> Self {
|
||||
pub fn new(left_instruction: Instruction<'i>, right_instruction: Instruction<'i>) -> Self {
|
||||
Self(left_instruction, right_instruction)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'i> Par<'i> {
|
||||
pub fn new(
|
||||
left_instruction: Box<Instruction<'i>>,
|
||||
right_instruction: Box<Instruction<'i>>,
|
||||
) -> Self {
|
||||
pub fn new(left_instruction: Instruction<'i>, right_instruction: Instruction<'i>) -> Self {
|
||||
Self(left_instruction, right_instruction)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'i> Xor<'i> {
|
||||
pub fn new(
|
||||
left_instruction: Box<Instruction<'i>>,
|
||||
right_instruction: Box<Instruction<'i>>,
|
||||
) -> Self {
|
||||
pub fn new(left_instruction: Instruction<'i>, right_instruction: Instruction<'i>) -> Self {
|
||||
Self(left_instruction, right_instruction)
|
||||
}
|
||||
}
|
||||
@ -115,7 +106,7 @@ impl<'i> Match<'i> {
|
||||
pub fn new(
|
||||
left_value: ImmutableValue<'i>,
|
||||
right_value: ImmutableValue<'i>,
|
||||
instruction: Box<Instruction<'i>>,
|
||||
instruction: Instruction<'i>,
|
||||
) -> Self {
|
||||
Self {
|
||||
left_value,
|
||||
@ -129,7 +120,7 @@ impl<'i> MisMatch<'i> {
|
||||
pub fn new(
|
||||
left_value: ImmutableValue<'i>,
|
||||
right_value: ImmutableValue<'i>,
|
||||
instruction: Box<Instruction<'i>>,
|
||||
instruction: Instruction<'i>,
|
||||
) -> Self {
|
||||
Self {
|
||||
left_value,
|
||||
@ -201,7 +192,7 @@ impl<'i> Next<'i> {
|
||||
|
||||
impl<'i> New<'i> {
|
||||
#[allow(clippy::self_named_constructors)]
|
||||
pub fn new(argument: NewArgument<'i>, instruction: Box<Instruction<'i>>, span: Span) -> Self {
|
||||
pub fn new(argument: NewArgument<'i>, instruction: Instruction<'i>, span: Span) -> Self {
|
||||
Self {
|
||||
argument,
|
||||
instruction,
|
||||
|
@ -13,7 +13,7 @@ grammar<'err, 'input, 'v>(input: &'input str, errors: &'err mut Vec<ErrorRecover
|
||||
|
||||
pub AIR = Instr;
|
||||
|
||||
Instr: Box<Instruction<'input>> = {
|
||||
Instr: Instruction<'input> = {
|
||||
<left: @L> "(" call <triplet:Triplet> <args:Args> <output:CallOutput?> ")" <right: @R> => {
|
||||
let args = Rc::new(args);
|
||||
let output = output.unwrap_or(CallOutputValue::None);
|
||||
@ -22,7 +22,7 @@ Instr: Box<Instruction<'input>> = {
|
||||
|
||||
validator.met_call(&call, span);
|
||||
|
||||
Box::new(Instruction::Call(call))
|
||||
Instruction::Call(call.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" canon <peer_id:ResolvableToPeerIdVariable> <stream:StreamArgument> <canon_stream:CanonStreamArgument> ")" <right: @R> => {
|
||||
@ -31,7 +31,7 @@ Instr: Box<Instruction<'input>> = {
|
||||
let span = Span::new(left, right);
|
||||
validator.met_canon(&canon, span);
|
||||
|
||||
Box::new(Instruction::Canon(canon))
|
||||
Instruction::Canon(canon.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" canon <peer_id:ResolvableToPeerIdVariable> <stream_map:StreamMapArgument> <canon_stream_map:CanonStreamMapArgument> ")" <right: @R> => {
|
||||
@ -40,7 +40,7 @@ Instr: Box<Instruction<'input>> = {
|
||||
let span = Span::new(left, right);
|
||||
validator.met_canon_map(&canon_map, span);
|
||||
|
||||
Box::new(Instruction::CanonMap(canon_map))
|
||||
Instruction::CanonMap(canon_map.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" canon <peer_id:ResolvableToPeerIdVariable> <stream_map:StreamMapArgument> <scalar_pair:Scalar> ")" <right: @R> => {
|
||||
@ -50,7 +50,7 @@ Instr: Box<Instruction<'input>> = {
|
||||
let span = Span::new(left, right);
|
||||
validator.met_canon_map_scalar(&canon, span);
|
||||
|
||||
Box::new(Instruction::CanonStreamMapScalar(canon))
|
||||
Instruction::CanonStreamMapScalar(canon.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" ap <arg:ApArgument> <result:ApResult> ")" <right: @R> => {
|
||||
@ -59,7 +59,7 @@ Instr: Box<Instruction<'input>> = {
|
||||
let span = Span::new(left, right);
|
||||
validator.met_ap(&apply, span);
|
||||
|
||||
Box::new(Instruction::Ap(apply))
|
||||
Instruction::Ap(apply.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" ap "(" <key:StreamMapKeyClause> <value:ApArgument> ")" <map:StreamMap> ")" <right: @R> => {
|
||||
@ -69,13 +69,13 @@ Instr: Box<Instruction<'input>> = {
|
||||
let span = Span::new(left, right);
|
||||
validator.met_ap_map(&apply, span);
|
||||
|
||||
Box::new(Instruction::ApMap(apply))
|
||||
Instruction::ApMap(apply.into())
|
||||
},
|
||||
|
||||
"(" seq <l:Instr> <r:Instr> ")" => Box::new(Instruction::Seq(Seq::new(l, r))),
|
||||
"(" par <l:Instr> <r:Instr> ")" => Box::new(Instruction::Par(Par::new(l, r))),
|
||||
"(" never ")" => Box::new(Instruction::Never(Never)),
|
||||
"(" null ")" => Box::new(Instruction::Null(Null)),
|
||||
"(" seq <l:Instr> <r:Instr> ")" => Instruction::Seq(Seq::new(l, r).into()),
|
||||
"(" par <l:Instr> <r:Instr> ")" => Instruction::Par(Par::new(l, r).into()),
|
||||
"(" never ")" => Instruction::Never(Never),
|
||||
"(" null ")" => Instruction::Null(Null),
|
||||
|
||||
<left: @L> "(" new <argument: NewArgument> <instruction:Instr> ")" <right: @R> => {
|
||||
let span = Span::new(left, right);
|
||||
@ -83,44 +83,44 @@ Instr: Box<Instruction<'input>> = {
|
||||
|
||||
validator.met_new(&new, span);
|
||||
|
||||
Box::new(Instruction::New(new))
|
||||
Instruction::New(new.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" fail <fail_body: FailBody> ")" <right: @R> => {
|
||||
let span = Span::new(left, right);
|
||||
validator.met_fail_literal(&fail_body, span);
|
||||
|
||||
Box::new(Instruction::Fail(fail_body))
|
||||
Instruction::Fail(fail_body.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" fold <iterable:FoldScalarIterable> <iterator:Scalar> <instruction:Instr> <last_instruction:Instr?>")" <right: @R> => {
|
||||
let iterator = Scalar::new(iterator.0, iterator.1);
|
||||
let span = Span::new(left, right);
|
||||
let fold = FoldScalar::new(iterable, iterator, *instruction, last_instruction.map(|v| *v), span);
|
||||
let fold = FoldScalar::new(iterable, iterator, instruction, last_instruction, span);
|
||||
|
||||
validator.met_fold_scalar(&fold, span);
|
||||
|
||||
Box::new(Instruction::FoldScalar(fold))
|
||||
Instruction::FoldScalar(fold.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" fold <stream:Stream> <iterator:Scalar> <instruction:Instr> <last_instruction:Instr?> ")" <right: @R> => {
|
||||
let iterable = Stream::new(stream.0, stream.1);
|
||||
let iterator = Scalar::new(iterator.0, iterator.1);
|
||||
let span = Span::new(left, right);
|
||||
let fold = FoldStream::new(iterable, iterator, *instruction, last_instruction.map(|v| *v), span);
|
||||
let fold = FoldStream::new(iterable, iterator, instruction, last_instruction, span);
|
||||
|
||||
validator.meet_fold_stream(&fold, span);
|
||||
|
||||
Box::new(Instruction::FoldStream(fold))
|
||||
Instruction::FoldStream(fold.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" fold <stream_map:StreamMap> <iterator:Scalar> <instruction:Instr> <last_instruction:Instr?> ")" <right: @R> => {
|
||||
let iterator = Scalar::new(iterator.0, iterator.1);
|
||||
let span = Span::new(left, right);
|
||||
let iterable = StreamMap::new(stream_map.0, stream_map.1);
|
||||
let fold = FoldStreamMap::new(iterable, iterator, *instruction, last_instruction.map(|v| *v), span);
|
||||
let fold = FoldStreamMap::new(iterable, iterator, instruction, last_instruction, span);
|
||||
validator.meet_fold_stream_map(&fold, span);
|
||||
Box::new(Instruction::FoldStreamMap(fold))
|
||||
Instruction::FoldStreamMap(fold.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" next <iterator:Scalar> ")" <right: @R> => {
|
||||
@ -129,17 +129,17 @@ Instr: Box<Instruction<'input>> = {
|
||||
let span = Span::new(left, right);
|
||||
validator.met_next(&next, span);
|
||||
|
||||
Box::new(Instruction::Next(next))
|
||||
Instruction::Next(next.into())
|
||||
},
|
||||
|
||||
"(" xor <l:Instr> <r:Instr> ")" => Box::new(Instruction::Xor(Xor(l, r))),
|
||||
"(" xor <l:Instr> <r:Instr> ")" => Instruction::Xor(Xor(l, r).into()),
|
||||
|
||||
<left: @L> "(" match_ <l:Value> <r:Value> <i:Instr> ")" <right: @R> => {
|
||||
let match_ = Match::new(l, r, i);
|
||||
let span = Span::new(left, right);
|
||||
validator.met_match(&match_, span);
|
||||
|
||||
Box::new(Instruction::Match(match_))
|
||||
Instruction::Match(match_.into())
|
||||
},
|
||||
|
||||
<left: @L> "(" mismatch <l:Value> <r:Value> <i:Instr> ")" <right: @R> => {
|
||||
@ -147,10 +147,10 @@ Instr: Box<Instruction<'input>> = {
|
||||
let span = Span::new(left, right);
|
||||
validator.met_mismatch(&mismatch, span);
|
||||
|
||||
Box::new(Instruction::MisMatch(mismatch))
|
||||
Instruction::MisMatch(mismatch.into())
|
||||
},
|
||||
|
||||
! => { errors.push(<>); Box::new(Instruction::Error) },
|
||||
! => { errors.push(<>); Instruction::Error },
|
||||
}
|
||||
|
||||
Args: Vec<ImmutableValue<'input>> = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// auto-generated: "lalrpop 0.20.0"
|
||||
// sha3: 3f2a00b4e0b0922c986743c02f1829a8610259b5697c6508b93c823c487de1de
|
||||
// sha3: 127100bc464d586a4839740daea718cfbd4c90154fcbc34ebfb7cc898a24b6d7
|
||||
use crate::ast::*;
|
||||
use crate::parser::ParserError;
|
||||
use crate::parser::VariableValidator;
|
||||
@ -49,7 +49,7 @@ mod __parse__AIR {
|
||||
Variant9(ImmutableValue<'input>),
|
||||
Variant10(alloc::vec::Vec<ImmutableValue<'input>>),
|
||||
Variant11(AirPos),
|
||||
Variant12(Box<Instruction<'input>>),
|
||||
Variant12(Instruction<'input>),
|
||||
Variant13(ApArgument<'input>),
|
||||
Variant14(ApResult<'input>),
|
||||
Variant15(Vec<ImmutableValue<'input>>),
|
||||
@ -60,7 +60,7 @@ mod __parse__AIR {
|
||||
Variant20(Fail<'input>),
|
||||
Variant21(FoldScalarIterable<'input>),
|
||||
Variant22(ResolvableToStringVariable<'input>),
|
||||
Variant23(core::option::Option<Box<Instruction<'input>>>),
|
||||
Variant23(core::option::Option<Instruction<'input>>),
|
||||
Variant24(NewArgument<'input>),
|
||||
Variant25(Number),
|
||||
Variant26(ResolvableToPeerIdVariable<'input>),
|
||||
@ -952,7 +952,7 @@ mod __parse__AIR {
|
||||
type Token = Token<'input>;
|
||||
type TokenIndex = usize;
|
||||
type Symbol = __Symbol<'input>;
|
||||
type Success = Box<Instruction<'input>>;
|
||||
type Success = Instruction<'input>;
|
||||
type StateIndex = i16;
|
||||
type Action = i16;
|
||||
type ReduceIndex = i16;
|
||||
@ -1889,7 +1889,7 @@ mod __parse__AIR {
|
||||
errors: &'err mut Vec<ErrorRecovery<AirPos, Token<'input>, ParserError>>,
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
__tokens0: __TOKENS,
|
||||
) -> Result<Box<Instruction<'input>>, __lalrpop_util::ParseError<AirPos, Token<'input>, ParserError>>
|
||||
) -> Result<Instruction<'input>, __lalrpop_util::ParseError<AirPos, Token<'input>, ParserError>>
|
||||
{
|
||||
let __tokens = __tokens0.into_iter();
|
||||
let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t));
|
||||
@ -1955,7 +1955,7 @@ mod __parse__AIR {
|
||||
__states: &mut alloc::vec::Vec<i16>,
|
||||
__symbols: &mut alloc::vec::Vec<(AirPos,__Symbol<'input>,AirPos)>,
|
||||
_: core::marker::PhantomData<(&'err (), &'input (), &'v ())>,
|
||||
) -> Option<Result<Box<Instruction<'input>>,__lalrpop_util::ParseError<AirPos, Token<'input>, ParserError>>>
|
||||
) -> Option<Result<Instruction<'input>,__lalrpop_util::ParseError<AirPos, Token<'input>, ParserError>>>
|
||||
{
|
||||
let (__pop_states, __nonterminal) = match __action {
|
||||
0 => {
|
||||
@ -2391,17 +2391,6 @@ mod __parse__AIR {
|
||||
_ => __symbol_type_mismatch()
|
||||
}
|
||||
}
|
||||
fn __pop_Variant12<
|
||||
'input,
|
||||
>(
|
||||
__symbols: &mut alloc::vec::Vec<(AirPos,__Symbol<'input>,AirPos)>
|
||||
) -> (AirPos, Box<Instruction<'input>>, AirPos)
|
||||
{
|
||||
match __symbols.pop() {
|
||||
Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r),
|
||||
_ => __symbol_type_mismatch()
|
||||
}
|
||||
}
|
||||
fn __pop_Variant16<
|
||||
'input,
|
||||
>(
|
||||
@ -2468,6 +2457,17 @@ mod __parse__AIR {
|
||||
_ => __symbol_type_mismatch()
|
||||
}
|
||||
}
|
||||
fn __pop_Variant12<
|
||||
'input,
|
||||
>(
|
||||
__symbols: &mut alloc::vec::Vec<(AirPos,__Symbol<'input>,AirPos)>
|
||||
) -> (AirPos, Instruction<'input>, AirPos)
|
||||
{
|
||||
match __symbols.pop() {
|
||||
Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r),
|
||||
_ => __symbol_type_mismatch()
|
||||
}
|
||||
}
|
||||
fn __pop_Variant4<
|
||||
'input,
|
||||
>(
|
||||
@ -2622,17 +2622,6 @@ mod __parse__AIR {
|
||||
_ => __symbol_type_mismatch()
|
||||
}
|
||||
}
|
||||
fn __pop_Variant23<
|
||||
'input,
|
||||
>(
|
||||
__symbols: &mut alloc::vec::Vec<(AirPos,__Symbol<'input>,AirPos)>
|
||||
) -> (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos)
|
||||
{
|
||||
match __symbols.pop() {
|
||||
Some((__l, __Symbol::Variant23(__v), __r)) => (__l, __v, __r),
|
||||
_ => __symbol_type_mismatch()
|
||||
}
|
||||
}
|
||||
fn __pop_Variant17<
|
||||
'input,
|
||||
>(
|
||||
@ -2644,6 +2633,17 @@ mod __parse__AIR {
|
||||
_ => __symbol_type_mismatch()
|
||||
}
|
||||
}
|
||||
fn __pop_Variant23<
|
||||
'input,
|
||||
>(
|
||||
__symbols: &mut alloc::vec::Vec<(AirPos,__Symbol<'input>,AirPos)>
|
||||
) -> (AirPos, core::option::Option<Instruction<'input>>, AirPos)
|
||||
{
|
||||
match __symbols.pop() {
|
||||
Some((__l, __Symbol::Variant23(__v), __r)) => (__l, __v, __r),
|
||||
_ => __symbol_type_mismatch()
|
||||
}
|
||||
}
|
||||
fn __pop_Variant5<
|
||||
'input,
|
||||
>(
|
||||
@ -5331,8 +5331,8 @@ fn __action0<
|
||||
input: &'input str,
|
||||
errors: &'err mut Vec<ErrorRecovery<AirPos, Token<'input>, ParserError>>,
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
(_, __0, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
(_, __0, _): (AirPos, Instruction<'input>, AirPos),
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
__0
|
||||
}
|
||||
@ -5347,8 +5347,8 @@ fn __action1<
|
||||
input: &'input str,
|
||||
errors: &'err mut Vec<ErrorRecovery<AirPos, Token<'input>, ParserError>>,
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
(_, __0, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
(_, __0, _): (AirPos, Instruction<'input>, AirPos),
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
__0
|
||||
}
|
||||
@ -5371,7 +5371,7 @@ fn __action2<
|
||||
(_, output, _): (AirPos, core::option::Option<CallOutputValue<'input>>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let args = Rc::new(args);
|
||||
@ -5381,7 +5381,7 @@ fn __action2<
|
||||
|
||||
validator.met_call(&call, span);
|
||||
|
||||
Box::new(Instruction::Call(call))
|
||||
Instruction::Call(call.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5403,7 +5403,7 @@ fn __action3<
|
||||
(_, canon_stream, _): (AirPos, CanonStream<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let canon = Canon::new(peer_id, stream, canon_stream);
|
||||
@ -5411,7 +5411,7 @@ fn __action3<
|
||||
let span = Span::new(left, right);
|
||||
validator.met_canon(&canon, span);
|
||||
|
||||
Box::new(Instruction::Canon(canon))
|
||||
Instruction::Canon(canon.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5433,7 +5433,7 @@ fn __action4<
|
||||
(_, canon_stream_map, _): (AirPos, CanonStreamMap<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let canon_map = CanonMap::new(peer_id, stream_map, canon_stream_map);
|
||||
@ -5441,7 +5441,7 @@ fn __action4<
|
||||
let span = Span::new(left, right);
|
||||
validator.met_canon_map(&canon_map, span);
|
||||
|
||||
Box::new(Instruction::CanonMap(canon_map))
|
||||
Instruction::CanonMap(canon_map.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5463,7 +5463,7 @@ fn __action5<
|
||||
(_, scalar_pair, _): (AirPos, (&'input str, AirPos), AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let scalar = Scalar::new(scalar_pair.0, scalar_pair.1);
|
||||
@ -5472,7 +5472,7 @@ fn __action5<
|
||||
let span = Span::new(left, right);
|
||||
validator.met_canon_map_scalar(&canon, span);
|
||||
|
||||
Box::new(Instruction::CanonStreamMapScalar(canon))
|
||||
Instruction::CanonStreamMapScalar(canon.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5493,7 +5493,7 @@ fn __action6<
|
||||
(_, result, _): (AirPos, ApResult<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let apply = Ap::new(arg, result);
|
||||
@ -5501,7 +5501,7 @@ fn __action6<
|
||||
let span = Span::new(left, right);
|
||||
validator.met_ap(&apply, span);
|
||||
|
||||
Box::new(Instruction::Ap(apply))
|
||||
Instruction::Ap(apply.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5525,7 +5525,7 @@ fn __action7<
|
||||
(_, map, _): (AirPos, (&'input str, AirPos), AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let map = StreamMap::new(map.0, map.1);
|
||||
@ -5534,7 +5534,7 @@ fn __action7<
|
||||
let span = Span::new(left, right);
|
||||
validator.met_ap_map(&apply, span);
|
||||
|
||||
Box::new(Instruction::ApMap(apply))
|
||||
Instruction::ApMap(apply.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5550,12 +5550,12 @@ fn __action8<
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, l, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, r, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, l, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, r, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
Box::new(Instruction::Seq(Seq::new(l, r)))
|
||||
Instruction::Seq(Seq::new(l, r).into())
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -5570,12 +5570,12 @@ fn __action9<
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, l, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, r, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, l, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, r, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
Box::new(Instruction::Par(Par::new(l, r)))
|
||||
Instruction::Par(Par::new(l, r).into())
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -5591,9 +5591,9 @@ fn __action10<
|
||||
(_, __0, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, __1, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, __2, _): (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
Box::new(Instruction::Never(Never))
|
||||
Instruction::Never(Never)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -5609,9 +5609,9 @@ fn __action11<
|
||||
(_, __0, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, __1, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, __2, _): (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
Box::new(Instruction::Null(Null))
|
||||
Instruction::Null(Null)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -5628,10 +5628,10 @@ fn __action12<
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, argument, _): (AirPos, NewArgument<'input>, AirPos),
|
||||
(_, instruction, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, instruction, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let span = Span::new(left, right);
|
||||
@ -5639,7 +5639,7 @@ fn __action12<
|
||||
|
||||
validator.met_new(&new, span);
|
||||
|
||||
Box::new(Instruction::New(new))
|
||||
Instruction::New(new.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5659,13 +5659,13 @@ fn __action13<
|
||||
(_, fail_body, _): (AirPos, Fail<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let span = Span::new(left, right);
|
||||
validator.met_fail_literal(&fail_body, span);
|
||||
|
||||
Box::new(Instruction::Fail(fail_body))
|
||||
Instruction::Fail(fail_body.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5684,20 +5684,20 @@ fn __action14<
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, iterable, _): (AirPos, FoldScalarIterable<'input>, AirPos),
|
||||
(_, iterator, _): (AirPos, (&'input str, AirPos), AirPos),
|
||||
(_, instruction, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, last_instruction, _): (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
(_, instruction, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, last_instruction, _): (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let iterator = Scalar::new(iterator.0, iterator.1);
|
||||
let span = Span::new(left, right);
|
||||
let fold = FoldScalar::new(iterable, iterator, *instruction, last_instruction.map(|v| *v), span);
|
||||
let fold = FoldScalar::new(iterable, iterator, instruction, last_instruction, span);
|
||||
|
||||
validator.met_fold_scalar(&fold, span);
|
||||
|
||||
Box::new(Instruction::FoldScalar(fold))
|
||||
Instruction::FoldScalar(fold.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5716,21 +5716,21 @@ fn __action15<
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, stream, _): (AirPos, (&'input str, AirPos), AirPos),
|
||||
(_, iterator, _): (AirPos, (&'input str, AirPos), AirPos),
|
||||
(_, instruction, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, last_instruction, _): (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
(_, instruction, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, last_instruction, _): (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let iterable = Stream::new(stream.0, stream.1);
|
||||
let iterator = Scalar::new(iterator.0, iterator.1);
|
||||
let span = Span::new(left, right);
|
||||
let fold = FoldStream::new(iterable, iterator, *instruction, last_instruction.map(|v| *v), span);
|
||||
let fold = FoldStream::new(iterable, iterator, instruction, last_instruction, span);
|
||||
|
||||
validator.meet_fold_stream(&fold, span);
|
||||
|
||||
Box::new(Instruction::FoldStream(fold))
|
||||
Instruction::FoldStream(fold.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5749,19 +5749,19 @@ fn __action16<
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, stream_map, _): (AirPos, (&'input str, AirPos), AirPos),
|
||||
(_, iterator, _): (AirPos, (&'input str, AirPos), AirPos),
|
||||
(_, instruction, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, last_instruction, _): (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
(_, instruction, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, last_instruction, _): (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let iterator = Scalar::new(iterator.0, iterator.1);
|
||||
let span = Span::new(left, right);
|
||||
let iterable = StreamMap::new(stream_map.0, stream_map.1);
|
||||
let fold = FoldStreamMap::new(iterable, iterator, *instruction, last_instruction.map(|v| *v), span);
|
||||
let fold = FoldStreamMap::new(iterable, iterator, instruction, last_instruction, span);
|
||||
validator.meet_fold_stream_map(&fold, span);
|
||||
Box::new(Instruction::FoldStreamMap(fold))
|
||||
Instruction::FoldStreamMap(fold.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5781,7 +5781,7 @@ fn __action17<
|
||||
(_, iterator, _): (AirPos, (&'input str, AirPos), AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let iterator = Scalar::new(iterator.0, iterator.1);
|
||||
@ -5789,7 +5789,7 @@ fn __action17<
|
||||
let span = Span::new(left, right);
|
||||
validator.met_next(&next, span);
|
||||
|
||||
Box::new(Instruction::Next(next))
|
||||
Instruction::Next(next.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5805,12 +5805,12 @@ fn __action18<
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, l, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, r, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, l, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, r, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
Box::new(Instruction::Xor(Xor(l, r)))
|
||||
Instruction::Xor(Xor(l, r).into())
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -5828,17 +5828,17 @@ fn __action19<
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, l, _): (AirPos, ImmutableValue<'input>, AirPos),
|
||||
(_, r, _): (AirPos, ImmutableValue<'input>, AirPos),
|
||||
(_, i, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, i, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let match_ = Match::new(l, r, i);
|
||||
let span = Span::new(left, right);
|
||||
validator.met_match(&match_, span);
|
||||
|
||||
Box::new(Instruction::Match(match_))
|
||||
Instruction::Match(match_.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5857,17 +5857,17 @@ fn __action20<
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, l, _): (AirPos, ImmutableValue<'input>, AirPos),
|
||||
(_, r, _): (AirPos, ImmutableValue<'input>, AirPos),
|
||||
(_, i, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
(_, i, _): (AirPos, Instruction<'input>, AirPos),
|
||||
(_, _, _): (AirPos, Token<'input>, AirPos),
|
||||
(_, right, _): (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{
|
||||
let mismatch = MisMatch::new(l, r, i);
|
||||
let span = Span::new(left, right);
|
||||
validator.met_mismatch(&mismatch, span);
|
||||
|
||||
Box::new(Instruction::MisMatch(mismatch))
|
||||
Instruction::MisMatch(mismatch.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -5882,9 +5882,9 @@ fn __action21<
|
||||
errors: &'err mut Vec<ErrorRecovery<AirPos, Token<'input>, ParserError>>,
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
(_, __0, _): (AirPos, __lalrpop_util::ErrorRecovery<AirPos, Token<'input>, ParserError>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
{ errors.push(__0); Box::new(Instruction::Error) }
|
||||
{ errors.push(__0); Instruction::Error }
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -7283,8 +7283,8 @@ fn __action107<
|
||||
input: &'input str,
|
||||
errors: &'err mut Vec<ErrorRecovery<AirPos, Token<'input>, ParserError>>,
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
(_, __0, _): (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
) -> core::option::Option<Box<Instruction<'input>>>
|
||||
(_, __0, _): (AirPos, Instruction<'input>, AirPos),
|
||||
) -> core::option::Option<Instruction<'input>>
|
||||
{
|
||||
Some(__0)
|
||||
}
|
||||
@ -7301,7 +7301,7 @@ fn __action108<
|
||||
validator: &'v mut VariableValidator<'input>,
|
||||
__lookbehind: &AirPos,
|
||||
__lookahead: &AirPos,
|
||||
) -> core::option::Option<Box<Instruction<'input>>>
|
||||
) -> core::option::Option<Instruction<'input>>
|
||||
{
|
||||
None
|
||||
}
|
||||
@ -7619,7 +7619,7 @@ fn __action121<
|
||||
__4: (AirPos, core::option::Option<CallOutputValue<'input>>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
__6: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -7663,7 +7663,7 @@ fn __action122<
|
||||
__4: (AirPos, CanonStream<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
__6: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -7707,7 +7707,7 @@ fn __action123<
|
||||
__4: (AirPos, CanonStreamMap<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
__6: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -7751,7 +7751,7 @@ fn __action124<
|
||||
__4: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
__6: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -7794,7 +7794,7 @@ fn __action125<
|
||||
__3: (AirPos, ApResult<'input>, AirPos),
|
||||
__4: (AirPos, Token<'input>, AirPos),
|
||||
__5: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -7839,7 +7839,7 @@ fn __action126<
|
||||
__6: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__7: (AirPos, Token<'input>, AirPos),
|
||||
__8: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -7881,10 +7881,10 @@ fn __action127<
|
||||
__0: (AirPos, Token<'input>, AirPos),
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, NewArgument<'input>, AirPos),
|
||||
__3: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__3: (AirPos, Instruction<'input>, AirPos),
|
||||
__4: (AirPos, Token<'input>, AirPos),
|
||||
__5: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -7925,7 +7925,7 @@ fn __action128<
|
||||
__2: (AirPos, Fail<'input>, AirPos),
|
||||
__3: (AirPos, Token<'input>, AirPos),
|
||||
__4: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -7964,11 +7964,11 @@ fn __action129<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, FoldScalarIterable<'input>, AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
__7: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -8010,11 +8010,11 @@ fn __action130<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
__7: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -8056,11 +8056,11 @@ fn __action131<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
__7: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -8103,7 +8103,7 @@ fn __action132<
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, Token<'input>, AirPos),
|
||||
__4: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -8142,10 +8142,10 @@ fn __action133<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, ImmutableValue<'input>, AirPos),
|
||||
__3: (AirPos, ImmutableValue<'input>, AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
__6: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -8186,10 +8186,10 @@ fn __action134<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, ImmutableValue<'input>, AirPos),
|
||||
__3: (AirPos, ImmutableValue<'input>, AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
__6: (AirPos, AirPos, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __0.0;
|
||||
let __end0 = __0.0;
|
||||
@ -8296,7 +8296,7 @@ fn __action137<
|
||||
__3: (AirPos, Vec<ImmutableValue<'input>>, AirPos),
|
||||
__4: (AirPos, core::option::Option<CallOutputValue<'input>>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.2;
|
||||
let __end0 = __5.2;
|
||||
@ -8338,7 +8338,7 @@ fn __action138<
|
||||
__3: (AirPos, Stream<'input>, AirPos),
|
||||
__4: (AirPos, CanonStream<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.2;
|
||||
let __end0 = __5.2;
|
||||
@ -8380,7 +8380,7 @@ fn __action139<
|
||||
__3: (AirPos, StreamMap<'input>, AirPos),
|
||||
__4: (AirPos, CanonStreamMap<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.2;
|
||||
let __end0 = __5.2;
|
||||
@ -8422,7 +8422,7 @@ fn __action140<
|
||||
__3: (AirPos, StreamMap<'input>, AirPos),
|
||||
__4: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.2;
|
||||
let __end0 = __5.2;
|
||||
@ -8463,7 +8463,7 @@ fn __action141<
|
||||
__2: (AirPos, ApArgument<'input>, AirPos),
|
||||
__3: (AirPos, ApResult<'input>, AirPos),
|
||||
__4: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __4.2;
|
||||
let __end0 = __4.2;
|
||||
@ -8506,7 +8506,7 @@ fn __action142<
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
__6: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__7: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __7.2;
|
||||
let __end0 = __7.2;
|
||||
@ -8547,9 +8547,9 @@ fn __action143<
|
||||
__0: (AirPos, Token<'input>, AirPos),
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, NewArgument<'input>, AirPos),
|
||||
__3: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__3: (AirPos, Instruction<'input>, AirPos),
|
||||
__4: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __4.2;
|
||||
let __end0 = __4.2;
|
||||
@ -8588,7 +8588,7 @@ fn __action144<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, Fail<'input>, AirPos),
|
||||
__3: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __3.2;
|
||||
let __end0 = __3.2;
|
||||
@ -8626,10 +8626,10 @@ fn __action145<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, FoldScalarIterable<'input>, AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __6.2;
|
||||
let __end0 = __6.2;
|
||||
@ -8670,10 +8670,10 @@ fn __action146<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __6.2;
|
||||
let __end0 = __6.2;
|
||||
@ -8714,10 +8714,10 @@ fn __action147<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Box<Instruction<'input>>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, core::option::Option<Instruction<'input>>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __6.2;
|
||||
let __end0 = __6.2;
|
||||
@ -8758,7 +8758,7 @@ fn __action148<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __3.2;
|
||||
let __end0 = __3.2;
|
||||
@ -8796,9 +8796,9 @@ fn __action149<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, ImmutableValue<'input>, AirPos),
|
||||
__3: (AirPos, ImmutableValue<'input>, AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.2;
|
||||
let __end0 = __5.2;
|
||||
@ -8838,9 +8838,9 @@ fn __action150<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, ImmutableValue<'input>, AirPos),
|
||||
__3: (AirPos, ImmutableValue<'input>, AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.2;
|
||||
let __end0 = __5.2;
|
||||
@ -8882,7 +8882,7 @@ fn __action151<
|
||||
__3: (AirPos, Vec<ImmutableValue<'input>>, AirPos),
|
||||
__4: (AirPos, CallOutputValue<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __4.0;
|
||||
let __end0 = __4.2;
|
||||
@ -8921,7 +8921,7 @@ fn __action152<
|
||||
__2: (AirPos, Triplet<'input>, AirPos),
|
||||
__3: (AirPos, Vec<ImmutableValue<'input>>, AirPos),
|
||||
__4: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __3.2;
|
||||
let __end0 = __4.0;
|
||||
@ -8960,10 +8960,10 @@ fn __action153<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, FoldScalarIterable<'input>, AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Instruction<'input>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.0;
|
||||
let __end0 = __5.2;
|
||||
@ -9002,9 +9002,9 @@ fn __action154<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, FoldScalarIterable<'input>, AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __4.2;
|
||||
let __end0 = __5.0;
|
||||
@ -9044,10 +9044,10 @@ fn __action155<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Instruction<'input>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.0;
|
||||
let __end0 = __5.2;
|
||||
@ -9086,9 +9086,9 @@ fn __action156<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __4.2;
|
||||
let __end0 = __5.0;
|
||||
@ -9128,10 +9128,10 @@ fn __action157<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__5: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Instruction<'input>, AirPos),
|
||||
__6: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __5.0;
|
||||
let __end0 = __5.2;
|
||||
@ -9170,9 +9170,9 @@ fn __action158<
|
||||
__1: (AirPos, Token<'input>, AirPos),
|
||||
__2: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__3: (AirPos, (&'input str, AirPos), AirPos),
|
||||
__4: (AirPos, Box<Instruction<'input>>, AirPos),
|
||||
__4: (AirPos, Instruction<'input>, AirPos),
|
||||
__5: (AirPos, Token<'input>, AirPos),
|
||||
) -> Box<Instruction<'input>>
|
||||
) -> Instruction<'input>
|
||||
{
|
||||
let __start0 = __4.2;
|
||||
let __end0 = __5.0;
|
||||
|
@ -34,7 +34,7 @@ thread_local!(static PARSER: AIRParser = AIRParser::new());
|
||||
|
||||
/// Parse AIR `source_code` to `Box<Instruction>`
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub fn parse(air_script: &str) -> Result<Box<Instruction<'_>>, String> {
|
||||
pub fn parse(air_script: &str) -> Result<Instruction<'_>, String> {
|
||||
let mut files = SimpleFiles::new();
|
||||
let file_id = files.add("script.air", air_script);
|
||||
|
||||
|
@ -572,18 +572,21 @@ fn seq_with_empty_and_dash() {
|
||||
CallOutputValue::Scalar(Scalar::new("module", 409.into())),
|
||||
),
|
||||
seq(
|
||||
Instruction::Call(Call {
|
||||
triplet: Triplet {
|
||||
peer_id: ResolvableToPeerIdVariable::Literal("A"),
|
||||
service_id: ResolvableToStringVariable::Literal("add_blueprint"),
|
||||
function_name: ResolvableToStringVariable::Literal(""),
|
||||
},
|
||||
args: Rc::new(vec![ImmutableValue::Variable(ImmutableVariable::scalar(
|
||||
"blueprint",
|
||||
490.into(),
|
||||
))]),
|
||||
output: CallOutputValue::Scalar(Scalar::new("blueprint_id", 501.into())),
|
||||
}),
|
||||
Instruction::Call(
|
||||
Call {
|
||||
triplet: Triplet {
|
||||
peer_id: ResolvableToPeerIdVariable::Literal("A"),
|
||||
service_id: ResolvableToStringVariable::Literal("add_blueprint"),
|
||||
function_name: ResolvableToStringVariable::Literal(""),
|
||||
},
|
||||
args: Rc::new(vec![ImmutableValue::Variable(ImmutableVariable::scalar(
|
||||
"blueprint",
|
||||
490.into(),
|
||||
))]),
|
||||
output: CallOutputValue::Scalar(Scalar::new("blueprint_id", 501.into())),
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
seq(
|
||||
call(
|
||||
ResolvableToPeerIdVariable::Literal("A"),
|
||||
|
@ -30,23 +30,26 @@ pub(super) fn call<'i>(
|
||||
function_name,
|
||||
};
|
||||
|
||||
Instruction::Call(Call {
|
||||
triplet,
|
||||
args,
|
||||
output,
|
||||
})
|
||||
Instruction::Call(
|
||||
Call {
|
||||
triplet,
|
||||
args,
|
||||
output,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn seq<'i>(l: Instruction<'i>, r: Instruction<'i>) -> Instruction<'i> {
|
||||
Instruction::Seq(Seq(Box::new(l), Box::new(r)))
|
||||
Instruction::Seq(Seq(l, r).into())
|
||||
}
|
||||
|
||||
pub(super) fn par<'i>(l: Instruction<'i>, r: Instruction<'i>) -> Instruction<'i> {
|
||||
Instruction::Par(Par(Box::new(l), Box::new(r)))
|
||||
Instruction::Par(Par(l, r).into())
|
||||
}
|
||||
|
||||
pub(super) fn xor<'i>(l: Instruction<'i>, r: Instruction<'i>) -> Instruction<'i> {
|
||||
Instruction::Xor(Xor(Box::new(l), Box::new(r)))
|
||||
Instruction::Xor(Xor(l, r).into())
|
||||
}
|
||||
|
||||
pub(super) fn seqnn() -> Instruction<'static> {
|
||||
@ -58,11 +61,14 @@ pub(super) fn new<'i>(
|
||||
instruction: Instruction<'i>,
|
||||
span: Span,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::New(New {
|
||||
argument,
|
||||
instruction: Box::new(instruction),
|
||||
span,
|
||||
})
|
||||
Instruction::New(
|
||||
New {
|
||||
argument,
|
||||
instruction,
|
||||
span,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn never() -> Instruction<'static> {
|
||||
@ -74,26 +80,29 @@ pub(super) fn null() -> Instruction<'static> {
|
||||
}
|
||||
|
||||
pub(super) fn fail_scalar(scalar: Scalar) -> Instruction<'_> {
|
||||
Instruction::Fail(Fail::Scalar(scalar))
|
||||
Instruction::Fail(Fail::Scalar(scalar).into())
|
||||
}
|
||||
|
||||
pub(super) fn fail_scalar_wl(scalar: ScalarWithLambda) -> Instruction<'_> {
|
||||
Instruction::Fail(Fail::ScalarWithLambda(scalar))
|
||||
Instruction::Fail(Fail::ScalarWithLambda(scalar).into())
|
||||
}
|
||||
|
||||
pub(super) fn fail_literals(ret_code: i64, error_message: &str) -> Instruction<'_> {
|
||||
Instruction::Fail(Fail::Literal {
|
||||
ret_code,
|
||||
error_message,
|
||||
})
|
||||
Instruction::Fail(
|
||||
Fail::Literal {
|
||||
ret_code,
|
||||
error_message,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn fail_last_error() -> Instruction<'static> {
|
||||
Instruction::Fail(Fail::LastError)
|
||||
Instruction::Fail(Fail::LastError.into())
|
||||
}
|
||||
|
||||
pub(super) fn fail_error() -> Instruction<'static> {
|
||||
Instruction::Fail(Fail::Error)
|
||||
Instruction::Fail(Fail::Error.into())
|
||||
}
|
||||
|
||||
pub(super) fn fold_scalar_variable<'i>(
|
||||
@ -103,13 +112,16 @@ pub(super) fn fold_scalar_variable<'i>(
|
||||
last_instruction: Option<Instruction<'i>>,
|
||||
span: Span,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::FoldScalar(FoldScalar {
|
||||
iterable: FoldScalarIterable::Scalar(scalar),
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
})
|
||||
Instruction::FoldScalar(
|
||||
FoldScalar {
|
||||
iterable: FoldScalarIterable::Scalar(scalar),
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn fold_scalar_variable_wl<'i>(
|
||||
@ -119,13 +131,16 @@ pub(super) fn fold_scalar_variable_wl<'i>(
|
||||
last_instruction: Option<Instruction<'i>>,
|
||||
span: Span,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::FoldScalar(FoldScalar {
|
||||
iterable: FoldScalarIterable::ScalarWithLambda(scalar),
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
})
|
||||
Instruction::FoldScalar(
|
||||
FoldScalar {
|
||||
iterable: FoldScalarIterable::ScalarWithLambda(scalar),
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn fold_scalar_canon_stream<'i>(
|
||||
@ -135,13 +150,16 @@ pub(super) fn fold_scalar_canon_stream<'i>(
|
||||
last_instruction: Option<Instruction<'i>>,
|
||||
span: Span,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::FoldScalar(FoldScalar {
|
||||
iterable: FoldScalarIterable::CanonStream(canon_stream),
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
})
|
||||
Instruction::FoldScalar(
|
||||
FoldScalar {
|
||||
iterable: FoldScalarIterable::CanonStream(canon_stream),
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn fold_scalar_canon_stream_map<'i>(
|
||||
@ -151,13 +169,16 @@ pub(super) fn fold_scalar_canon_stream_map<'i>(
|
||||
last_instruction: Option<Instruction<'i>>,
|
||||
span: Span,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::FoldScalar(FoldScalar {
|
||||
iterable: FoldScalarIterable::CanonStreamMap(canon_stream_map),
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
})
|
||||
Instruction::FoldScalar(
|
||||
FoldScalar {
|
||||
iterable: FoldScalarIterable::CanonStreamMap(canon_stream_map),
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn fold_scalar_empty_array<'i>(
|
||||
@ -166,13 +187,16 @@ pub(super) fn fold_scalar_empty_array<'i>(
|
||||
last_instruction: Option<Instruction<'i>>,
|
||||
span: Span,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::FoldScalar(FoldScalar {
|
||||
iterable: FoldScalarIterable::EmptyArray,
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
})
|
||||
Instruction::FoldScalar(
|
||||
FoldScalar {
|
||||
iterable: FoldScalarIterable::EmptyArray,
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn fold_stream<'i>(
|
||||
@ -182,13 +206,16 @@ pub(super) fn fold_stream<'i>(
|
||||
last_instruction: Option<Instruction<'i>>,
|
||||
span: Span,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::FoldStream(FoldStream {
|
||||
iterable,
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
})
|
||||
Instruction::FoldStream(
|
||||
FoldStream {
|
||||
iterable,
|
||||
iterator,
|
||||
instruction: Rc::new(instruction),
|
||||
last_instruction: last_instruction.map(Rc::new),
|
||||
span,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn match_<'i>(
|
||||
@ -196,11 +223,14 @@ pub(super) fn match_<'i>(
|
||||
right_value: ImmutableValue<'i>,
|
||||
instruction: Instruction<'i>,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::Match(Match {
|
||||
left_value,
|
||||
right_value,
|
||||
instruction: Box::new(instruction),
|
||||
})
|
||||
Instruction::Match(
|
||||
Match {
|
||||
left_value,
|
||||
right_value,
|
||||
instruction,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn mismatch<'i>(
|
||||
@ -208,15 +238,18 @@ pub(super) fn mismatch<'i>(
|
||||
right_value: ImmutableValue<'i>,
|
||||
instruction: Instruction<'i>,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::MisMatch(MisMatch {
|
||||
left_value,
|
||||
right_value,
|
||||
instruction: Box::new(instruction),
|
||||
})
|
||||
Instruction::MisMatch(
|
||||
MisMatch {
|
||||
left_value,
|
||||
right_value,
|
||||
instruction,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn ap<'i>(argument: ApArgument<'i>, result: ApResult<'i>) -> Instruction<'i> {
|
||||
Instruction::Ap(Ap { argument, result })
|
||||
Instruction::Ap(Ap { argument, result }.into())
|
||||
}
|
||||
|
||||
pub(super) fn ap_with_map<'i>(
|
||||
@ -224,11 +257,14 @@ pub(super) fn ap_with_map<'i>(
|
||||
argument: ApArgument<'i>,
|
||||
result: StreamMap<'i>,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::ApMap(ApMap {
|
||||
key: key,
|
||||
value: argument,
|
||||
map: result,
|
||||
})
|
||||
Instruction::ApMap(
|
||||
ApMap {
|
||||
key,
|
||||
value: argument,
|
||||
map: result,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn canon<'i>(
|
||||
@ -236,11 +272,14 @@ pub(super) fn canon<'i>(
|
||||
stream: Stream<'i>,
|
||||
canon_stream: CanonStream<'i>,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::Canon(Canon {
|
||||
peer_id: peer_pk,
|
||||
stream,
|
||||
canon_stream,
|
||||
})
|
||||
Instruction::Canon(
|
||||
Canon {
|
||||
peer_id: peer_pk,
|
||||
stream,
|
||||
canon_stream,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn canon_stream_map_scalar<'i>(
|
||||
@ -248,11 +287,14 @@ pub(super) fn canon_stream_map_scalar<'i>(
|
||||
stream_map: StreamMap<'i>,
|
||||
scalar: Scalar<'i>,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::CanonStreamMapScalar(CanonStreamMapScalar {
|
||||
peer_id: peer_pk,
|
||||
stream_map,
|
||||
scalar,
|
||||
})
|
||||
Instruction::CanonStreamMapScalar(
|
||||
CanonStreamMapScalar {
|
||||
peer_id: peer_pk,
|
||||
stream_map,
|
||||
scalar,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn canon_stream_map_canon_map<'i>(
|
||||
@ -260,11 +302,14 @@ pub(super) fn canon_stream_map_canon_map<'i>(
|
||||
stream_map: StreamMap<'i>,
|
||||
canon_stream_map: CanonStreamMap<'i>,
|
||||
) -> Instruction<'i> {
|
||||
Instruction::CanonMap(CanonMap {
|
||||
peer_id: peer_pk,
|
||||
stream_map,
|
||||
canon_stream_map,
|
||||
})
|
||||
Instruction::CanonMap(
|
||||
CanonMap {
|
||||
peer_id: peer_pk,
|
||||
stream_map,
|
||||
canon_stream_map,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn binary_instruction<'i, 'b>(
|
||||
|
@ -33,7 +33,7 @@ use crate::parser::AIRParser;
|
||||
thread_local!(static TEST_PARSER: AIRParser = AIRParser::new());
|
||||
|
||||
fn parse(source_code: &str) -> Instruction {
|
||||
*TEST_PARSER.with(|parser| {
|
||||
TEST_PARSER.with(|parser| {
|
||||
let mut errors = Vec::new();
|
||||
let lexer = crate::parser::AIRLexer::new(source_code);
|
||||
let mut validator = crate::parser::VariableValidator::new();
|
||||
|
@ -109,15 +109,12 @@ impl<W: io::Write> Beautifier<W> {
|
||||
/// Emit beautified code for the `air_script`.
|
||||
pub fn beautify(&mut self, air_script: &str) -> Result<(), BeautifyError> {
|
||||
let tree = air_parser::parse(air_script).map_err(BeautifyError::Parse)?;
|
||||
self.beautify_ast(tree)
|
||||
self.beautify_ast(&tree)
|
||||
}
|
||||
|
||||
/// Emit beautified code for the `ast`.
|
||||
pub fn beautify_ast<'i>(
|
||||
&mut self,
|
||||
ast: impl AsRef<ast::Instruction<'i>>,
|
||||
) -> Result<(), BeautifyError> {
|
||||
Ok(self.beautify_walker(ast.as_ref(), 0)?)
|
||||
pub fn beautify_ast(&mut self, ast: &ast::Instruction<'_>) -> Result<(), BeautifyError> {
|
||||
Ok(self.beautify_walker(ast, 0)?)
|
||||
}
|
||||
|
||||
fn beautify_walker(&mut self, node: &ast::Instruction<'_>, indent: usize) -> io::Result<()> {
|
||||
|
@ -25,6 +25,7 @@ for bench in multiple-cids10 \
|
||||
call-requests500 \
|
||||
call-results500 \
|
||||
parser-10000-100 \
|
||||
parser-calls-10000-100 \
|
||||
null \
|
||||
;
|
||||
do
|
||||
|
@ -53,8 +53,10 @@ enum Bench {
|
||||
BigValuesData,
|
||||
CallRequests500,
|
||||
CallResults500,
|
||||
#[command(name="parser-10000-100")]
|
||||
#[command(name = "parser-10000-100")]
|
||||
Parser10000_100,
|
||||
#[command(name = "parser-calls-10000-100")]
|
||||
ParserCalls10000_100,
|
||||
Null,
|
||||
}
|
||||
|
||||
@ -85,6 +87,7 @@ fn main() {
|
||||
Bench::CallRequests500 => calls::call_requests(500),
|
||||
Bench::CallResults500 => calls::call_results(500),
|
||||
Bench::Parser10000_100 => parser_10000_100(),
|
||||
Bench::ParserCalls10000_100 => parser_calls(10000, 100),
|
||||
Bench::Null => null(),
|
||||
};
|
||||
|
||||
@ -712,6 +715,55 @@ fn parser_10000_100() -> Data {
|
||||
}
|
||||
}
|
||||
|
||||
fn parser_calls(calls: usize, vars: usize) -> Data {
|
||||
let (keypair, peer_id) = derive_dummy_keypair("init_peer_id");
|
||||
let particle_id = "particle_id";
|
||||
|
||||
let vars = (0..vars).map(|n| format!("var{}", n)).collect_vec();
|
||||
let init_var = vars[0].clone();
|
||||
let statements = vars
|
||||
.iter()
|
||||
.cycle()
|
||||
.take(calls)
|
||||
.tuple_windows()
|
||||
.map(|(a, b)| format!(r#"(call {a} ("serv" "func") [] {b})"#))
|
||||
.collect_vec();
|
||||
|
||||
fn build_tree(statements: &[String]) -> String {
|
||||
assert!(!statements.is_empty());
|
||||
if statements.len() == 1 {
|
||||
statements[0].clone()
|
||||
} else {
|
||||
let mid = statements.len() / 2;
|
||||
format!(
|
||||
"(seq {} {})",
|
||||
build_tree(&statements[..mid]),
|
||||
build_tree(&statements[mid..])
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
let tree = build_tree(&statements);
|
||||
let air = format!(
|
||||
r#"(seq (call "peer" ("serv" "func") [] {}) {})"#,
|
||||
init_var, tree
|
||||
);
|
||||
|
||||
Data {
|
||||
air,
|
||||
prev_data: vec![],
|
||||
cur_data: vec![],
|
||||
call_results: None,
|
||||
keypair: bs58::encode(keypair.as_inner().to_vec()).into_string(),
|
||||
params_json: hashmap! {
|
||||
"comment".to_owned() => "multiple calls parser benchmark".to_owned(),
|
||||
"particle-id".to_owned() => particle_id.to_owned(),
|
||||
"current-peer-id".to_owned() => peer_id.clone(),
|
||||
"init-peer-id".to_owned() => peer_id,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn null() -> Data {
|
||||
let air_script = "(null)";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user