cas-compiler 0.2.0

Bytecode compiler for CalcScript programs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use cas_error::Error;
use cas_parser::parser::ast::unary::Unary;
use crate::{Compile, Compiler, InstructionKind};

impl Compile for Unary {
    fn compile(&self, compiler: &mut Compiler) -> Result<(), Error> {
        self.operand.compile(compiler)?;
        compiler.add_instr_with_spans(
            InstructionKind::Unary(self.op.kind),
            vec![self.operand.span(), self.op.span.clone()],
        );
        Ok(())
    }
}