|
|
@ -55,17 +55,21 @@ pub(crate) fn parse_op<'a>(op_pos: &SourcePosition, keyword: &str, mut args: Tok |
|
|
|
let mut pstate = pcx.state.borrow_mut(); |
|
|
|
let mut pstate = pcx.state.borrow_mut(); |
|
|
|
if pstate.reg_aliases.contains_key(&alias) { |
|
|
|
if pstate.reg_aliases.contains_key(&alias) { |
|
|
|
return Err(CrsnError::Parse(format!("Register alias \"{}\" already defined!", alias).into(), rpos)); |
|
|
|
return Err(CrsnError::Parse(format!("Register alias \"{}\" already defined!", alias).into(), rpos)); |
|
|
|
} |
|
|
|
} else if pstate.global_reg_aliases.contains_key(&alias) { |
|
|
|
|
|
|
|
return Err(CrsnError::Parse(format!("Register alias \"{}\" already defined (global)!", alias).into(), rpos)); |
|
|
|
if pstate.constants.contains_key(&alias) { |
|
|
|
} else if pstate.constants.contains_key(&alias) { |
|
|
|
return Err(CrsnError::Parse(format!("Name \"{}\" already used for a constant!", alias).into(), aliaspos)); |
|
|
|
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() { |
|
|
|
if register.is_global() { |
|
|
|
return Err(CrsnError::Parse(format!("Register \"{}\" already aliased!", register).into(), rpos)); |
|
|
|
pstate.global_reg_aliases.insert(alias, register); |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
pstate.reg_aliases.insert(alias, register); |
|
|
|
pstate.reg_aliases.insert(alias, register); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Ok(ParseRes::ParsedNone); |
|
|
|
return Ok(ParseRes::ParsedNone); |
|
|
|
} |
|
|
|
} |
|
|
@ -75,8 +79,10 @@ pub(crate) fn parse_op<'a>(op_pos: &SourcePosition, keyword: &str, mut args: Tok |
|
|
|
|
|
|
|
|
|
|
|
let mut pstate = pcx.state.borrow_mut(); |
|
|
|
let mut pstate = pcx.state.borrow_mut(); |
|
|
|
if pstate.reg_aliases.remove(&alias.0).is_none() { |
|
|
|
if pstate.reg_aliases.remove(&alias.0).is_none() { |
|
|
|
|
|
|
|
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 Err(CrsnError::Parse(format!("Register alias \"{}\" not defined!", alias.0).into(), alias.1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return Ok(ParseRes::ParsedNone); |
|
|
|
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(); |
|
|
|
let mut pstate = pcx.state.borrow_mut(); |
|
|
|
if pstate.constants.contains_key(&name) { |
|
|
|
if pstate.constants.contains_key(&name) { |
|
|
|
return Err(CrsnError::Parse(format!("Constant \"{}\" already defined!", name).into(), namepos)); |
|
|
|
return Err(CrsnError::Parse(format!("Constant \"{}\" already defined!", name).into(), namepos)); |
|
|
|
} |
|
|
|
} else if pstate.reg_aliases.contains_key(&name) { |
|
|
|
|
|
|
|
|
|
|
|
if pstate.reg_aliases.contains_key(&name) { |
|
|
|
|
|
|
|
return Err(CrsnError::Parse(format!("Name \"{}\" already used for a register alias!", name).into(), namepos)); |
|
|
|
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); |
|
|
|
pstate.constants.insert(name, value); |
|
|
|