mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-14 16:08:02 -05:00
Add release pseudo-instruction
This commit is contained in:
@@ -142,6 +142,7 @@ impl std::fmt::Display for Function {
|
||||
FnLine::Label(label) => write!(f, "{}\n", label)?,
|
||||
FnLine::Empty => write!(f, "\n")?,
|
||||
FnLine::Comment(message) => write!(f, " // {}\n", message)?,
|
||||
FnLine::Release(reg) => write!(f, " (release {})\n", reg)?,
|
||||
}
|
||||
}
|
||||
write!(f, "}}")
|
||||
@@ -297,21 +298,17 @@ pub enum FnLine {
|
||||
Label(Label),
|
||||
Empty,
|
||||
Comment(String),
|
||||
Release(Register),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for FnLine {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
FnLine::Instruction(instruction) => {
|
||||
write!(f, "{}", instruction)
|
||||
}
|
||||
FnLine::Label(label) => {
|
||||
write!(f, "{}", label)
|
||||
}
|
||||
FnLine::Instruction(instruction) => write!(f, "{}", instruction),
|
||||
FnLine::Label(label) => write!(f, "{}", label),
|
||||
FnLine::Empty => Ok(()),
|
||||
FnLine::Comment(message) => {
|
||||
write!(f, "// {}", message)
|
||||
}
|
||||
FnLine::Comment(message) => write!(f, "// {}", message),
|
||||
FnLine::Release(reg) => write!(f, "(release {})", reg),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -890,6 +887,7 @@ impl std::fmt::Display for Lazy {
|
||||
FnLine::Label(label) => write!(f, "{}\n", label)?,
|
||||
FnLine::Empty => write!(f, "\n")?,
|
||||
FnLine::Comment(message) => write!(f, " // {}\n", message)?,
|
||||
FnLine::Release(reg) => write!(f, " (release {})\n", reg)?,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ impl Assembler {
|
||||
FnLine::Label(label) => {
|
||||
self.label(label);
|
||||
}
|
||||
FnLine::Empty | FnLine::Comment(..) => {}
|
||||
FnLine::Empty | FnLine::Comment(..) | FnLine::Release(..) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ impl Assembler {
|
||||
FnLine::Label(label) => {
|
||||
self.label(label);
|
||||
}
|
||||
FnLine::Empty | FnLine::Comment(..) => {}
|
||||
FnLine::Empty | FnLine::Comment(..) | FnLine::Release(..) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -497,6 +497,19 @@ impl<'a> AssemblyParser<'a> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if c == '(' {
|
||||
self.parse_exact("(release");
|
||||
self.parse_whitespace();
|
||||
|
||||
let reg = self.assemble_register();
|
||||
self.parse_optional_whitespace();
|
||||
self.parse_exact(")\n");
|
||||
|
||||
function.body.push(FnLine::Release(reg));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
let optional_label = self.test_label();
|
||||
|
||||
if optional_label.is_some() {
|
||||
|
||||
@@ -216,6 +216,7 @@ impl FunctionCompiler {
|
||||
|
||||
pub fn release_reg(&mut self, reg: &Register) {
|
||||
self.reg_allocator.release(reg);
|
||||
self.current.body.push(FnLine::Release(reg.clone()));
|
||||
}
|
||||
|
||||
pub fn compile(
|
||||
|
||||
@@ -123,7 +123,7 @@ impl FnState {
|
||||
Instruction::Next(_, _) => {}
|
||||
Instruction::UnpackIterRes(_, _, _) => {}
|
||||
},
|
||||
FnLine::Label(..) | FnLine::Empty | FnLine::Comment(..) => {}
|
||||
FnLine::Label(..) | FnLine::Empty | FnLine::Comment(..) | FnLine::Release(..) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,6 +285,9 @@ impl FnState {
|
||||
},
|
||||
FnLine::Label(..) => self.clear(),
|
||||
FnLine::Empty | FnLine::Comment(..) => {}
|
||||
FnLine::Release(_reg) => {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ where
|
||||
FnLine::Instruction(instruction) => {
|
||||
self.instruction(owner, instruction);
|
||||
}
|
||||
FnLine::Label(..) | FnLine::Empty | FnLine::Comment(..) => {}
|
||||
FnLine::Label(..) | FnLine::Empty | FnLine::Comment(..) | FnLine::Release(..) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user