protected override string CanonicalBaseName(Model.Element elt, out NameSeqSuffix suff) { Model.FuncTuple fnTuple; suff = NameSeqSuffix.WhenNonZero; if (DatatypeValues.TryGetValue(elt, out fnTuple)) { // elt is s a datatype value, make its name be the name of the datatype constructor string nm = fnTuple.Func.Name; if (fnTuple.Func.Arity == 0) { return(nm); } else { return(nm + "(...)"); } } var seqLen = f_seq_length.AppWithArg(0, elt); if (seqLen != null) { // elt is a sequence return(string.Format("[Length {0}]", seqLen.Result.AsInt())); } if (elt == f_null.GetConstant()) { return("null"); } var tp = f_dtype.TryEval(elt); if (tp != null) { foreach (var app in tp.References) { if (app.Args.Length == 0 && app.Func.Name.StartsWith("class.")) { suff = NameSeqSuffix.Always; return(app.Func.Name.Substring(6)); } } } return(base.CanonicalBaseName(elt, out suff)); }
// Elements (other than integers and Booleans) get canonical names of the form // "<base>'<idx>", where <base> is returned by this function, and <idx> is given // starting with 0, and incrementing when there are conflicts between bases. // // This function needs to return an appropriate base name for the element. It is given // the element. // // A reasonable strategy is to check if it's a name of the local, and if so return it, // and otherwise use the type of element (e.g., return "seq" for elements representing // sequences). It is also possible to return "" in such cases. // // The suff output parameter specifies whether the number sequence suffix should be // always added, only when it's non-zero, or never. protected virtual string CanonicalBaseName(Model.Element elt, out NameSeqSuffix suff) { string res; if (elt is Model.Integer || elt is Model.Boolean) { suff = NameSeqSuffix.None; return(elt.ToString()); } suff = NameSeqSuffix.Always; if (UseLocalsForCanonicalNames) { if (localValue.TryGetValue(elt, out res)) { return(res); } } return(""); }
protected override string CanonicalBaseName(Model.Element elt, out NameSeqSuffix suff) { Model.FuncTuple fnTuple; suff = NameSeqSuffix.WhenNonZero; if (DatatypeValues.TryGetValue(elt, out fnTuple)) { // elt is s a datatype value, make its name be the name of the datatype constructor string nm = fnTuple.Func.Name; if (fnTuple.Func.Arity == 0) return nm; else return nm + "(...)"; } var seqLen = f_seq_length.AppWithArg(0, elt); if (seqLen != null) { // elt is a sequence return string.Format("[Length {0}]", seqLen.Result.AsInt()); } if (elt == f_null.GetConstant()) return "null"; var tp = f_dtype.TryEval(elt); if (tp != null) { foreach (var app in tp.References) { if (app.Args.Length == 0 && app.Func.Name.StartsWith("class.")) { suff = NameSeqSuffix.Always; return app.Func.Name.Substring(6); } } } return base.CanonicalBaseName(elt, out suff); }