public LegacyRegister getRegister(AbstractToken tok) { String name = labelName(tok); LegacyRegister reg = LegacyRegister.getRegisterByName(name); if (reg == null) reg = (LegacyRegister) definitions.get(name); if (reg == null) ERROR.UnknownRegister(tok); return reg; }
protected void simplify(Item i) { Item.Instruction instr = null; if (i instanceof Item.Instruction) instr = (Item.Instruction) i; try { i.simplify(); } catch (LegacyInstr.ImmediateRequired e) { ERROR.ConstantExpected((SyntacticOperand) e.operand); } catch (LegacyInstr.InvalidImmediate e) { ERROR.ConstantOutOfRange( instr.operands[e.number - 1], e.value, StringUtil.interval(e.low, e.high)); } catch (LegacyInstr.InvalidRegister e) { ERROR.IncorrectRegister(instr.operands[e.number - 1], e.register, e.set.toString()); } catch (LegacyInstr.RegisterRequired e) { ERROR.RegisterExpected((SyntacticOperand) e.operand); } catch (LegacyInstr.WrongNumberOfOperands e) { ERROR.WrongNumberOfOperands(instr.name, e.found, e.expected); } }
public int getVariable(AbstractToken tok) { String name = labelName(tok); Integer v = (Integer) constants.get(name); if (v == null) { Item.Label li = (Item.Label) labels.get(name); if (li == null) ERROR.UnknownVariable(tok); if (li.segment == programSegment && !useByteAddresses) return li.getByteAddress() >> 1; else return li.getByteAddress(); } else return v.intValue(); }
// .include directive public void includeFile(AbstractToken fname) throws AbstractParseException { try { modulePrinter.println("includeFile(" + fname.image + ')'); String fn = StringUtil.trimquotes(fname.image); AtmelParser parser = new AtmelParser(new FileInputStream(fn), this, fn); // TODO: handle infinite include recursion possibility parser.Module(); } catch (FileNotFoundException e) { ERROR.IncludeFileNotFound(fname); } }
public void addRegisterName(String name, AbstractToken reg) { LegacyRegister register = LegacyRegister.getRegisterByName(reg.image); if (register == null) ERROR.UnknownRegister(reg); definitions.put(labelName(name), register); }