forked from Wandalen/wTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Wandalen#924 from Barsik-sus/willbe_integration_tests
READY : willbe - wca
- Loading branch information
Showing
19 changed files
with
543 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/// Internal namespace. | ||
pub( crate ) mod private | ||
{ | ||
use wca:: | ||
{ | ||
Args, Props, | ||
Context, | ||
Result, BasicError, | ||
}; | ||
|
||
use crate::commands::{ StartPointStack, EndPointStack }; | ||
|
||
// ! TODO: Remove this command somehow | ||
|
||
/// End command declaration | ||
pub fn end_command() -> wca::Command | ||
{ | ||
wca::Command::former() | ||
.hint( "Command that is end of a block or a program" ) | ||
.phrase( "end" ) | ||
.form() | ||
} | ||
|
||
/// | ||
/// End of loop/program | ||
/// | ||
pub fn end( _ : ( Args, Props ), ctx : Context ) -> Result< () > | ||
{ | ||
println!( "[LOG] end called" ); | ||
|
||
if let Some( startpoints ) = ctx.get_ref::< StartPointStack >() | ||
{ | ||
if let Some( point ) = startpoints.last() | ||
{ | ||
let prog_state = ctx.get_mut::< wca::RuntimeState >() | ||
.ok_or_else( || BasicError::new( "Have no Program State" ) )?; | ||
|
||
let endpoints = ctx.get_or_default::< EndPointStack >(); | ||
// if has no point at current instruction - push it | ||
if endpoints.last() != Some( &( prog_state.pos - 1 ) ) | ||
{ | ||
endpoints.push( prog_state.pos - 1 ); | ||
} | ||
|
||
// Go to start point | ||
prog_state.pos = *point; | ||
} | ||
} | ||
|
||
Ok( () ) | ||
} | ||
} | ||
|
||
// | ||
|
||
crate::mod_interface! | ||
{ | ||
prelude use end_command; | ||
prelude use end; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.