Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::errors::SourceError;
use crate::parser::{AstNode, Block, NodeId};
use crate::parser::{AstNode, Block, Expr, NodeId};
use crate::protocol::Command;
use crate::resolver::{DeclId, Frame, NameBindings, ScopeId, VarId, Variable};
use crate::typechecker::{TypeId, Types};
Expand Down Expand Up @@ -126,7 +126,9 @@ impl Compiler {

if matches!(
ast_node,
AstNode::Name | AstNode::Variable | AstNode::Int | AstNode::Float | AstNode::String
AstNode::Name
| AstNode::VarDecl
| AstNode::Expr(Expr::VarRef | Expr::Int | Expr::Float | Expr::String)
) {
result.push_str(&format!(
" \"{}\"",
Expand Down
8 changes: 4 additions & 4 deletions src/ir_generator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::compiler::Compiler;
use crate::errors::{Severity, SourceError};
use crate::parser::{AstNode, NodeId};
use crate::parser::{AstNode, Expr, NodeId};
use nu_protocol::ast::{Math, Operator};
use nu_protocol::ir::{Instruction, IrBlock, Literal};
use nu_protocol::{RegId, Span};
Expand Down Expand Up @@ -97,7 +97,7 @@ impl<'a> IrGenerator<'a> {
fn generate_node(&mut self, node_id: NodeId) -> Option<RegId> {
let ast_node = &self.compiler.ast_nodes[node_id.0];
match ast_node {
AstNode::Int => {
AstNode::Expr(Expr::Int) => {
let next_reg = self.next_register();
let val = self.compiler.node_as_i64(node_id);
self.add_instruction(
Expand All @@ -109,7 +109,7 @@ impl<'a> IrGenerator<'a> {
);
Some(next_reg)
}
AstNode::Block(block_id) => {
AstNode::Expr(Expr::Block(block_id)) => {
let block = &self.compiler.blocks[block_id.0];
let mut last = None;
for id in &block.nodes {
Expand All @@ -118,7 +118,7 @@ impl<'a> IrGenerator<'a> {
}
last
}
AstNode::BinaryOp { lhs, op, rhs } => {
AstNode::Expr(Expr::BinaryOp { lhs, op, rhs }) => {
let l = self.generate_node(*lhs)?;
let r = self.generate_node(*rhs)?;
let o = self.node_to_operator(*op)?;
Expand Down
Loading
Loading