|
|
@ -94,10 +94,19 @@ pub fn parse_data_disp(tok: Sexp, pcx: &ParserContext) -> Result<DataDisp, CrsnE |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if let Some(reference) = s.strip_prefix('@') { |
|
|
|
if let Some(reference) = s.strip_prefix('@') { |
|
|
|
|
|
|
|
/* extension constants (pre-defined handles) */ |
|
|
|
|
|
|
|
for p in pcx.parsers { |
|
|
|
|
|
|
|
if let Some(val) = p.get_constant_value(&s) { |
|
|
|
|
|
|
|
return Ok(DataDisp::ImmObject(val)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* register aliases */ |
|
|
|
let pstate = pcx.state.borrow(); |
|
|
|
let pstate = pcx.state.borrow(); |
|
|
|
if let Some(reg) = pstate.reg_aliases.get(reference) { |
|
|
|
if let Some(reg) = pstate.reg_aliases.get(reference) { |
|
|
|
Ok(DataDisp::RegObject(*reg)) |
|
|
|
return Ok(DataDisp::RegObject(*reg)) |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let reg = reg::parse_reg(reference, &pos)?; |
|
|
|
let reg = reg::parse_reg(reference, &pos)?; |
|
|
|
|
|
|
|
|
|
|
|
if pstate.reg_aliases.values().find(|v| **v == reg).is_some() { |
|
|
|
if pstate.reg_aliases.values().find(|v| **v == reg).is_some() { |
|
|
@ -105,19 +114,28 @@ pub fn parse_data_disp(tok: Sexp, pcx: &ParserContext) -> Result<DataDisp, CrsnE |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Ok(DataDisp::RegObject(reg)) |
|
|
|
Ok(DataDisp::RegObject(reg)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if s.starts_with(|c: char| c.is_ascii_digit() || c == '-') { |
|
|
|
} else if s.starts_with(|c: char| c.is_ascii_digit() || c == '-') { |
|
|
|
Ok(DataDisp::Immediate(unsafe { std::mem::transmute(parse_i64(&s, &pos)?) })) |
|
|
|
Ok(DataDisp::Immediate(unsafe { std::mem::transmute(parse_i64(&s, &pos)?) })) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
/* extension constants */ |
|
|
|
|
|
|
|
for p in pcx.parsers { |
|
|
|
|
|
|
|
if let Some(val) = p.get_constant_value(&s) { |
|
|
|
|
|
|
|
return Ok(DataDisp::Immediate(val)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* program constants */ |
|
|
|
let pstate = pcx.state.borrow(); |
|
|
|
let pstate = pcx.state.borrow(); |
|
|
|
if let Some(val) = pstate.constants.get(&s) { |
|
|
|
if let Some(val) = pstate.constants.get(&s) { |
|
|
|
return Ok(DataDisp::Immediate(*val)); |
|
|
|
return Ok(DataDisp::Immediate(*val)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* register aliases */ |
|
|
|
if let Some(val) = pstate.reg_aliases.get(&s) { |
|
|
|
if let Some(val) = pstate.reg_aliases.get(&s) { |
|
|
|
return Ok(DataDisp::Register(*val)); |
|
|
|
return Ok(DataDisp::Register(*val)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* register */ |
|
|
|
let reg = reg::parse_reg(&s, &pos)?; |
|
|
|
let reg = reg::parse_reg(&s, &pos)?; |
|
|
|
|
|
|
|
|
|
|
|
let pstate = pcx.state.borrow(); |
|
|
|
let pstate = pcx.state.borrow(); |
|
|
|