From 43364541569175d6c87d13686d56d9d1dacbd990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Thu, 1 Oct 2020 23:29:49 +0200 Subject: [PATCH] add unsym and undef --- crsn/src/builtin/parse.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crsn/src/builtin/parse.rs b/crsn/src/builtin/parse.rs index 75b231d..6880f48 100644 --- a/crsn/src/builtin/parse.rs +++ b/crsn/src/builtin/parse.rs @@ -71,6 +71,16 @@ impl CrsnExtension for BuiltinOps { return Ok(ParseRes::ParsedNone); } + "unsym" => { + let alias = parse_reg_alias(args.next())?; + + let mut pstate = pcx.state.borrow_mut(); + if pstate.reg_aliases.remove(&alias).is_none() { + return Err(CrsnError::Parse(format!("Register alias \"{}\" not defined!", alias).into())); + } + return Ok(ParseRes::ParsedNone); + } + "def" => { let name = parse_constant_name(args.next())?; let value = parse_value(args.next())?; @@ -89,6 +99,16 @@ impl CrsnExtension for BuiltinOps { return Ok(ParseRes::ParsedNone); } + "undef" => { + let name = parse_constant_name(args.next())?; + + let mut pstate = pcx.state.borrow_mut(); + if pstate.constants.remove(&name).is_none() { + return Err(CrsnError::Parse(format!("Constant \"{}\" not defined!", name).into())); + } + return Ok(ParseRes::ParsedNone); + } + "j" => { let dest = parse_label(args.next())?; BuiltinOp::Jump(dest)