public override State Build(FSMRepresentationBuilder fb) { // SuperSub states depend upon other states, and so must request // that they be built first. Also, they are depended upon by other // states, so they must ignore duplicate requests for being built. State retval = null; if (!fb.IsStateBuilt(this.StateName)) { var sr = fb.GetStateRep(this.SuperStateName); if (sr != null) { sr.Build(fb); var superState = fb.GetBuiltSuperState(this.SuperStateName); if (superState != null) { var s = new SuperSubStateImpl(this.StateName, superState); retval = s; fb.AddBuiltSuperState(s); } else { var e = "Could not build super sub state (" + this.StateName + ") because super state (" + this.SuperStateName + ") had an error."; fb.SetError(); fb.Error(sr.SyntaxLocation, e); } } else { var e = $"Super state ({this.SuperStateName}) was not declared."; fb.SetError(); fb.Error(sr.SyntaxLocation, e); } } else { retval = fb.GetBuiltState(this.StateName); } return(retval); }
public override State Build(FSMRepresentationBuilder fb) { // Many other states may depend upon super states. Thus there may // be many requests for them to be built. Thus we have to check to // see if its has already been built, and ignore any subsequent // requests. // // Also, since super states do not depend upon anyone, they can be // built as soon as they are seen. SuperState retval; if (!fb.IsStateBuilt(this.StateName)) { var ss = new SuperStateImpl(this.StateName); fb.AddBuiltSuperState(ss); retval = ss; } else { retval = fb.GetBuiltSuperState(this.StateName); } return(retval); }