public IDisposable TrackPass(EvaluationPass evaluationPass, string passDescription = null) { return(_shouldTrackElements ? new EvaluationFrame(this, CurrentLocation.WithEvaluationPass(evaluationPass, passDescription)) : null); }
private EvaluationLocation ReadEvaluationLocation() { string elementName = ReadOptionalString(); string description = ReadOptionalString(); string evaluationDescription = ReadOptionalString(); string file = ReadOptionalString(); EvaluationLocationKind kind = (EvaluationLocationKind)ReadInt32(); EvaluationPass evaluationPass = (EvaluationPass)ReadInt32(); int? line = null; bool hasLine = ReadBoolean(); if (hasLine) { line = ReadInt32(); } // Id and parent Id were introduced in version 6 if (fileFormatVersion > 5) { long id = ReadInt64(); long?parentId = null; bool hasParent = ReadBoolean(); if (hasParent) { parentId = ReadInt64(); } return(new EvaluationLocation(id, parentId, evaluationPass, evaluationDescription, file, line, elementName, description, kind)); } return(new EvaluationLocation(0, null, evaluationPass, evaluationDescription, file, line, elementName, description, kind)); }
public EvaluatedPassInfo(EvaluationPass pass, string description, IEnumerable <EvaluatedLocationInfo> locations, TimeInfo time) { Pass = pass; Description = description; Locations = locations?.ToImmutableArray() ?? ImmutableArray <EvaluatedLocationInfo> .Empty; Time = time; }
public EvaluatedPass(EvaluationPass pass, string description, ImmutableArray <EvaluatedLocation> locations, Time time) { Pass = pass; Description = description; Locations = locations; Time = time; }
/// <summary> /// Constructs the generic case. /// </summary> /// <remarks> /// Used by serialization/deserialization purposes /// </remarks> public EvaluationLocation(EvaluationPass evaluationPass, string evaluationDescription, string file, int?line, string elementName, string description, EvaluationLocationKind kind) { EvaluationPass = evaluationPass; EvaluationDescription = evaluationDescription; File = file; Line = line; ElementName = elementName; Description = description; Kind = kind; }
/// <nodoc/> public static EvaluationLocation CreateLocationForGlob( long?parentId, EvaluationPass evaluationPass, string evaluationDescription, string file, int?line, string globDescription) { return(new EvaluationLocation(parentId, evaluationPass, evaluationDescription, file, line, "Glob", globDescription, kind: EvaluationLocationKind.Glob)); }
/// <nodoc/> public static EvaluationLocation CreateLocationForCondition( long?parentId, EvaluationPass evaluationPass, string evaluationDescription, string file, int?line, string condition) { return(new EvaluationLocation(parentId, evaluationPass, evaluationDescription, file, line, "Condition", condition, kind: EvaluationLocationKind.Condition)); }
/// <nodoc/> public EvaluationLocation WithEvaluationPass(EvaluationPass evaluationPass, string passDescription = null) { return(new EvaluationLocation( Id, evaluationPass, passDescription ?? PassDefaultDescription[evaluationPass], File, Line, ElementName, ElementDescription, Kind)); }
/// <summary> /// Constructs a generic evaluation location /// </summary> /// <remarks> /// Used by serialization/deserialization purposes /// </remarks> public EvaluationLocation(long id, long?parentId, EvaluationPass evaluationPass, string evaluationPassDescription, string file, int?line, string elementName, string elementDescription, EvaluationLocationKind kind) { Id = id; ParentId = parentId == EmptyLocation.Id? null : parentId; // The empty location doesn't count as a parent id, since it's just a dummy starting point EvaluationPass = evaluationPass; EvaluationPassDescription = evaluationPassDescription; File = file; Line = line; ElementName = elementName; ElementDescription = elementDescription; Kind = kind; }
/// <nodoc/> public override int GetHashCode() { var hashCode = 1198539463; hashCode = hashCode * -1521134295 + base.GetHashCode(); hashCode = hashCode * -1521134295 + EvaluationPass.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(EvaluationDescription); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(File); hashCode = hashCode * -1521134295 + EqualityComparer <int?> .Default.GetHashCode(Line); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ElementName); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Description); hashCode = hashCode * -1521134295 + Kind.GetHashCode(); return(hashCode); }
/// <nodoc/> public override int GetHashCode() { int hashCode = 1198539463; hashCode = (hashCode * -1521134295) + base.GetHashCode(); hashCode = (hashCode * -1521134295) + Id.GetHashCode(); hashCode = (hashCode * -1521134295) + EqualityComparer <long?> .Default.GetHashCode(ParentId); hashCode = (hashCode * -1521134295) + EvaluationPass.GetHashCode(); hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode(EvaluationPassDescription); hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode(File); hashCode = (hashCode * -1521134295) + EqualityComparer <int?> .Default.GetHashCode(Line); hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode(ElementName); hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode(ElementDescription); return((hashCode * -1521134295) + Kind.GetHashCode()); }
/// <summary> /// Constructs a generic evaluation location with no parent. /// </summary> /// <remarks> /// A unique Id gets assigned automatically /// Used by serialization/deserialization purposes /// </remarks> public EvaluationLocation(EvaluationPass evaluationPass, string evaluationPassDescription, string file, int?line, string elementName, string elementDescription, EvaluationLocationKind kind) : this(null, evaluationPass, evaluationPassDescription, file, line, elementName, elementDescription, kind) { }
/// <summary> /// Constructs a generic evaluation location based on a (possibly null) parent Id. /// </summary> /// <remarks> /// A unique Id gets assigned automatically /// Used by serialization/deserialization purposes /// </remarks> public EvaluationLocation(long?parentId, EvaluationPass evaluationPass, string evaluationPassDescription, string file, int?line, string elementName, string elementDescription, EvaluationLocationKind kind) : this(EvaluationIdProvider.GetNextId(), parentId, evaluationPass, evaluationPassDescription, file, line, elementName, elementDescription, kind) { }
/// <nodoc/> public static EvaluationLocation CreateLocationForProject(long?parentId, EvaluationPass evaluationPass, string evaluationDescription, string file, int?line, IProjectElement element) { return(new EvaluationLocation(parentId, evaluationPass, evaluationDescription, file, line, element?.ElementName, element?.OuterElement, kind: EvaluationLocationKind.Element)); }
public bool EvaluateSkolemConstants(EvaluationPass pass) { Hashtable temp = new Hashtable (); Regex regex = new Regex (argVarPrefix+@"[0-9]+"); Match argsMatch; Hashtable predArgs; List<object> objs = new List<object>(); Queue<String> argsStrings; bool doSkolemReplacement = false; Triple<String,String,String> replaceSkolems = null; foreach (DictionaryEntry kv in skolems) { objs.Clear (); if (kv.Value is String) { argsMatch = regex.Match ((String)kv.Value); if (argsMatch.Groups [0].Value.Length == 0) { // matched an empty string = no match Debug.Log (kv.Value); predArgs = Helper.ParsePredicate ((String)kv.Value); String pred = Helper.GetTopPredicate ((String)kv.Value); if (((String)kv.Value).Count (f => f == '(') + // make sure actually a predicate ((String)kv.Value).Count (f => f == ')') >= 2) { argsStrings = new Queue<String> (((String)predArgs [pred]).Split (new char[] {','})); while (argsStrings.Count > 0) { object arg = argsStrings.Dequeue (); if (Helper.v.IsMatch ((String)arg)) { // if arg is vector form objs.Add (Helper.ParsableToVector ((String)arg)); } else if (arg is String) { // if arg is String if ((arg as String).Count (f => f == '(') + // not a predicate (arg as String).Count (f => f == ')') == 0) { if (preds.GetType ().GetMethod (pred.ToUpper ()).ReturnType != typeof(String)) { // if predicate not going to return string (as in "AS") List<GameObject> matches = new List<GameObject> (); foreach (Voxeme voxeme in objSelector.allVoxemes) { if (voxeme.voxml.Lex.Pred.Equals(arg)) { matches.Add (voxeme.gameObject); } } if (matches.Count == 0) { GameObject go = GameObject.Find (arg as String); if (go == null) { OutputHelper.PrintOutput (OutputController.Role.Affector,string.Format("What is a \"{0}\"?", (arg as String))); return false; // abort } objs.Add (go); } else if (matches.Count == 1) { GameObject go = matches[0]; if (go == null) { OutputHelper.PrintOutput (OutputController.Role.Affector,string.Format("What is a \"{0}\"?", (arg as String))); return false; // abort } objs.Add (go); doSkolemReplacement = true; replaceSkolems = new Triple<String,String,String> (kv.Key as String, arg as String, go.name); //skolems[kv] = go.name; } else { Debug.Log (string.Format ("Which {0}?", (arg as String))); OutputHelper.PrintOutput (OutputController.Role.Affector,string.Format("Which {0}?", (arg as String))); return false; // abort } } } Regex q = new Regex("\".*\""); if (q.IsMatch(arg as String)) { objs.Add (arg); } else { objs.Add (GameObject.Find (arg as String)); } } } methodToCall = preds.GetType ().GetMethod (pred.ToUpper()); if (methodToCall == null) { OutputHelper.PrintOutput (OutputController.Role.Affector,"Sorry, what does " + "\"" + pred + "\" mean?"); return false; } if ((methodToCall.ReturnType == typeof(String)) && (pass == EvaluationPass.Attributes)) { Debug.Log ("EvaluateSkolemConstants: invoke " + methodToCall.Name); object obj = methodToCall.Invoke (preds, new object[]{ objs.ToArray () }); Debug.Log (obj); temp [kv.Key] = obj; } else if ((methodToCall.ReturnType == typeof(Vector3)) && (pass == EvaluationPass.RelationsAndFunctions)) { Debug.Log ("EvaluateSkolemConstants: invoke " + methodToCall.Name); object obj = methodToCall.Invoke (preds, new object[]{ objs.ToArray () }); Debug.Log (obj); temp [kv.Key] = obj; } } } else { temp [kv.Key] = kv.Value; } } } // replace improperly named arguments if (doSkolemReplacement) { skolems [replaceSkolems.Item1] = ((String)skolems [replaceSkolems.Item1]).Replace (replaceSkolems.Item2, replaceSkolems.Item3); } foreach (DictionaryEntry kv in temp) { //Debug.Log (kv.Value); String matchVal = kv.Value as String; if (matchVal == null) { matchVal = @"DEADBEEF"; } argsMatch = regex.Match (matchVal); if (argsMatch.Groups [0].Value.Length > 0) { Debug.Log (argsMatch.Groups [0]); if (temp.ContainsKey (argsMatch.Groups [0].Value)) { object replaceWith = temp [(String)argsMatch.Groups [0].Value]; Debug.Log (replaceWith.GetType ()); //String replaced = ((String)skolems [kv.Key]).Replace ((String)argsMatch.Groups [0].Value, // replaceWith.ToString ().Replace (',', ';').Replace ('(', '<').Replace (')', '>')); String replaced = (String)argsMatch.Groups [0].Value; if (replaceWith is String) { replaced = ((String)skolems [kv.Key]).Replace ((String)argsMatch.Groups [0].Value, (String)replaceWith); } else if (replaceWith is Vector3) { replaced = ((String)skolems [kv.Key]).Replace ((String)argsMatch.Groups [0].Value, Helper.VectorToParsable ((Vector3)replaceWith)); } Debug.Log (replaced); //if (replace is Vector3) { skolems [kv.Key] = replaced; //} } } else { skolems [kv.Key] = temp [kv.Key]; } } Helper.PrintKeysAndValues(skolems); int newEvaluations = 0; foreach (DictionaryEntry kv in skolems) { //Debug.Log(kv.Key + " : " + kv.Value.GetType()); if (kv.Value is String) { argsMatch = r.Match ((String)kv.Value); if (argsMatch.Groups [0].Value.Length > 0) { string pred = argsMatch.Groups [0].Value.Split ('(') [0]; methodToCall = pred.GetType ().GetMethod (pred.ToUpper()); if (methodToCall != null) { if ((methodToCall.ReturnType == typeof(String)) && (pass == EvaluationPass.Attributes)) { newEvaluations++; } if ((methodToCall.ReturnType == typeof(Vector3)) && (pass == EvaluationPass.RelationsAndFunctions)) { newEvaluations++; } } } } } //Debug.Log (newEvaluations); if (newEvaluations > 0) { EvaluateSkolemConstants (pass); } return true; }
/// <nodoc/> public EvaluationLocation WithEvaluationPass(EvaluationPass evaluationPass, string passDescription = null) { return(new EvaluationLocation(evaluationPass, passDescription ?? PassDefaultDescription[evaluationPass], this.File, this.Line, this.ElementName, this.Description, this.Kind)); }