static public bool cliAddShorttype(PlTerm valueName, PlTerm valueIn) { if (!valueName.IsString && !valueName.IsAtom) { return(Warn("valueName must be string or atom {0}", valueName)); } string name = valueName.Name; Type otherType; lock (ShortNameType) { if (ShortNameType.TryGetValue(name, out otherType)) { if (valueIn.IsNumber) { ShortNameType.Remove(name); TypeShortName.Remove(otherType); return(true); } if (valueIn.IsVar) { return(valueIn.UnifyAtom(otherType.FullName)); } Type val = GetType(valueIn); if (val == otherType) { return(true); } return(false); } else { if (valueIn.IsNumber) { return(true); } if (valueIn.IsVar) { return(true); } Type val = GetType(valueIn); if (val == null) { return(false); } ShortNameType[name] = val; TypeShortName[val] = name; return(true); } } }
static public bool cliAddShorttype(PlTerm valueName, PlTerm valueIn) { if (!valueName.IsString && !valueName.IsAtom) return Warn("valueName must be string or atom {0}", valueName); string name = valueName.Name; Type otherType; lock (ShortNameType) { if (ShortNameType.TryGetValue(name, out otherType)) { if (valueIn.IsNumber) { ShortNameType.Remove(name); TypeShortName.Remove(otherType); return true; } if (valueIn.IsVar) { return valueIn.UnifyAtom(otherType.FullName); } Type val = GetType(valueIn); if (val == otherType) return true; return false; } else { if (valueIn.IsNumber) { return true; } if (valueIn.IsVar) { return true; } Type val = GetType(valueIn); if (val == null) return false; ShortNameType[name] = val; TypeShortName[val] = name; return true; } } }