-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reader && Undoable Instructions (#90)
- Added input instructions - Added transformations model of instructions to allow for undo operations - Added cheese! --------- Co-authored-by: michaelni678 <[email protected]> Co-authored-by: Trevor Brunette <[email protected]> Co-authored-by: Aleks Bekker <[email protected]>
- Loading branch information
1 parent
d4c9b30
commit 5a4708e
Showing
36 changed files
with
1,254 additions
and
262 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Read an integer. | ||
prints "Input an integer: " | ||
readi $t0 | ||
# Print the read integer. | ||
printi $t0 | ||
prints "\n" | ||
# Allocate memory according to what was inputted. | ||
alloc $s0 $t0 | ||
# Subtract 1 from the allocation size. This is because room is needed for the null terminator. | ||
sub $t0 $t0 1 | ||
# Read string (sized). | ||
prints "Input a string: " | ||
reads $s0 $t0 | ||
# Print the read string. | ||
prints $s0 | ||
prints "\n" | ||
# Read a float. | ||
prints "Input a float: " | ||
readf $fs0 | ||
printf $fs0 | ||
prints "\n" | ||
prints "Input a char: " | ||
readc $t1 | ||
printc $t1 | ||
prints "\n" | ||
alloc $t2 100 | ||
prints "Input a line: " | ||
readln $t2 100 | ||
prints $t2 | ||
printc '\n' |
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
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,45 @@ | ||
use std::collections::VecDeque; | ||
use std::io::{Read, Write}; | ||
|
||
use rezasm_core::{simulation::reader::Reader, util::as_any::AsAny}; | ||
|
||
#[derive(Debug)] | ||
pub struct TauriReader { | ||
buffer: VecDeque<u8>, | ||
} | ||
|
||
impl TauriReader { | ||
pub fn new() -> TauriReader { | ||
TauriReader { | ||
buffer: VecDeque::new(), | ||
} | ||
} | ||
} | ||
|
||
impl Reader for TauriReader {} | ||
|
||
impl Read for TauriReader { | ||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { | ||
self.buffer.read(buf) | ||
} | ||
} | ||
|
||
impl Write for TauriReader { | ||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { | ||
self.buffer.write(buf) | ||
} | ||
|
||
fn flush(&mut self) -> std::io::Result<()> { | ||
self.buffer.flush() | ||
} | ||
} | ||
|
||
impl AsAny for TauriReader { | ||
fn as_any(&self) -> &dyn std::any::Any { | ||
self | ||
} | ||
|
||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any { | ||
self | ||
} | ||
} |
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.