|
|
|
@ -55,18 +55,22 @@ pub(crate) fn parse_op<'a>(op_pos: &SourcePosition, keyword: &str, mut args: Tok |
|
|
|
|
let mut pstate = pcx.state.borrow_mut(); |
|
|
|
|
if pstate.reg_aliases.contains_key(&alias) { |
|
|
|
|
return Err(CrsnError::Parse(format!("Register alias \"{}\" already defined!", alias).into(), rpos)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if pstate.constants.contains_key(&alias) { |
|
|
|
|
} else if pstate.global_reg_aliases.contains_key(&alias) { |
|
|
|
|
return Err(CrsnError::Parse(format!("Register alias \"{}\" already defined (global)!", alias).into(), rpos)); |
|
|
|
|
} else if pstate.constants.contains_key(&alias) { |
|
|
|
|
return Err(CrsnError::Parse(format!("Name \"{}\" already used for a constant!", alias).into(), aliaspos)); |
|
|
|
|
} else if let Some((name, _)) = pstate.reg_aliases.iter().find(|x| x.1 == ®ister) { |
|
|
|
|
return Err(CrsnError::Parse(format!("Register \"{}\" already aliased as \"{}\"!", register, name).into(), rpos)); |
|
|
|
|
} else if let Some((name, _)) = pstate.global_reg_aliases.iter().find(|x| x.1 == ®ister) { |
|
|
|
|
return Err(CrsnError::Parse(format!("Register \"{}\" already aliased (globally) as \"{}\"!", register, name).into(), rpos)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if pstate.reg_aliases.iter().find(|x| x.1 == ®ister).is_some() { |
|
|
|
|
return Err(CrsnError::Parse(format!("Register \"{}\" already aliased!", register).into(), rpos)); |
|
|
|
|
if register.is_global() { |
|
|
|
|
pstate.global_reg_aliases.insert(alias, register); |
|
|
|
|
} else { |
|
|
|
|
pstate.reg_aliases.insert(alias, register); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pstate.reg_aliases.insert(alias, register); |
|
|
|
|
|
|
|
|
|
return Ok(ParseRes::ParsedNone); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -75,7 +79,9 @@ pub(crate) fn parse_op<'a>(op_pos: &SourcePosition, keyword: &str, mut args: Tok |
|
|
|
|
|
|
|
|
|
let mut pstate = pcx.state.borrow_mut(); |
|
|
|
|
if pstate.reg_aliases.remove(&alias.0).is_none() { |
|
|
|
|
return Err(CrsnError::Parse(format!("Register alias \"{}\" not defined!", alias.0).into(), alias.1)); |
|
|
|
|
if pstate.global_reg_aliases.remove(&alias.0).is_none() { |
|
|
|
|
return Err(CrsnError::Parse(format!("Register alias \"{}\" not defined!", alias.0).into(), alias.1)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return Ok(ParseRes::ParsedNone); |
|
|
|
|
} |
|
|
|
@ -87,10 +93,10 @@ pub(crate) fn parse_op<'a>(op_pos: &SourcePosition, keyword: &str, mut args: Tok |
|
|
|
|
let mut pstate = pcx.state.borrow_mut(); |
|
|
|
|
if pstate.constants.contains_key(&name) { |
|
|
|
|
return Err(CrsnError::Parse(format!("Constant \"{}\" already defined!", name).into(), namepos)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if pstate.reg_aliases.contains_key(&name) { |
|
|
|
|
} else if pstate.reg_aliases.contains_key(&name) { |
|
|
|
|
return Err(CrsnError::Parse(format!("Name \"{}\" already used for a register alias!", name).into(), namepos)); |
|
|
|
|
} else if pstate.global_reg_aliases.contains_key(&name) { |
|
|
|
|
return Err(CrsnError::Parse(format!("Name \"{}\" already used for a global register alias!", name).into(), namepos)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pstate.constants.insert(name, value); |
|
|
|
|