public override bool Equals(object obj) { LabelSymbol l = obj as LabelSymbol; if (l != null) { return(l.Name == this.Name); } return(false); }
public int GetLabelAddress(string labelId) { LabelSymbol label; if (_labels.TryGetValue(labelId, out label)) { if (label.IsFwdRef) { label.AddFwdRef(_ip); } return(label.Address); } else { LabelSymbol newLab = new LabelSymbol(labelId); newLab.AddFwdRef(_ip); _labels.Add(labelId, newLab); return(0); } }
public void DefineLabel(IToken idToken) { LabelSymbol label; if (_labels.TryGetValue(idToken.Text, out label)) { if (label.IsFwdRef) { //label exists, patch up references label.Define(_ip); label.ResolveFwdRefs(_code); } else { throw new GenerationException(String.Format("line {0}:{1} Label '{2}' already defined", idToken.Line, idToken.CharPositionInLine, idToken.Text)); } } else { label = new LabelSymbol(idToken.Text, _ip); _labels.Add(label.Name, label); } }
public int GetLabelAddress(string labelId) { LabelSymbol label; if (_labels.TryGetValue(labelId, out label)) { if (label.IsFwdRef) { label.AddFwdRef(_ip); } return label.Address; } else { LabelSymbol newLab = new LabelSymbol(labelId); newLab.AddFwdRef(_ip); _labels.Add(labelId, newLab); return 0; } }