1
0
This commit is contained in:
Jeff 2024-12-03 17:11:02 -05:00
parent e241051870
commit 8f9e285214
4 changed files with 15 additions and 19 deletions

View File

@ -150,9 +150,7 @@ impl<'src> Compiler<'src> {
.iter()
.rev()
.find_map(|(instruction, _, _)| {
let is_get_local = matches!(instruction.operation(), Operation::GetLocal);
if instruction.yields_value() && !is_get_local {
if instruction.yields_value() {
Some(instruction.a() + 1)
} else {
None
@ -632,7 +630,11 @@ impl<'src> Compiler<'src> {
let rule = ParseRule::from(&operator);
let is_assignment = matches!(
operator,
Token::PlusEqual | Token::MinusEqual | Token::StarEqual | Token::SlashEqual
Token::PlusEqual
| Token::MinusEqual
| Token::StarEqual
| Token::SlashEqual
| Token::PercentEqual
);
if push_back_left {
@ -1729,7 +1731,7 @@ impl<'src> Compiler<'src> {
) -> Result<(), CompileError> {
if matches!(
(left, right),
(Type::Float, Type::Float) | (Type::Integer, Type::Integer)
(Type::Byte, Type::Byte) | (Type::Float, Type::Float) | (Type::Integer, Type::Integer)
) {
Ok(())
} else {

View File

@ -120,10 +120,7 @@ fn add_character_and_string() {
),
(Instruction::r#return(true), Span(9, 9))
],
vec![
ConcreteValue::Character('a'),
ConcreteValue::String("b".to_string())
],
vec![ConcreteValue::Character('a'), ConcreteValue::string("b")],
vec![]
))
);
@ -287,8 +284,8 @@ fn add_strings() {
(Instruction::r#return(true), Span(20, 20))
],
vec![
ConcreteValue::String("Hello, ".to_string()),
ConcreteValue::String("world!".to_string())
ConcreteValue::string("Hello, "),
ConcreteValue::string("world!")
],
vec![]
))
@ -327,8 +324,5 @@ fn add_string_and_character() {
))
);
assert_eq!(
run(source),
Ok(Some(ConcreteValue::String("ab".to_string())))
);
assert_eq!(run(source), Ok(Some(ConcreteValue::string("ab"))));
}

View File

@ -18,9 +18,9 @@ fn divide_bytes() {
Instruction::divide(
Destination::Register(0),
Argument::Constant(0),
Argument::Constant(0)
Argument::Constant(1)
),
Span(0, 7)
Span(5, 6)
),
(Instruction::r#return(true), Span(11, 11))
],

View File

@ -18,13 +18,13 @@ fn multiply_floats() {
Instruction::multiply(
Destination::Register(0),
Argument::Constant(0),
Argument::Constant(1)
Argument::Constant(0)
),
Span(4, 5)
),
(Instruction::r#return(true), Span(9, 9)),
],
vec![ConcreteValue::Float(2.0), ConcreteValue::Float(2.0)],
vec![ConcreteValue::Float(2.0)],
vec![]
))
);