public static object FreeAtRuntime(InputContext context, object o) { // free an object if (o is string) { // if o is a string, we further need to see if it's a v: or an o: string s = o as string; if (s.StartsWith("v")) { context.FreeVar(s); } else if (s.StartsWith("o")) { context.FreeObject(s); } else { throw new Exception("Could not free '" + s + "' because it was an unsupported type."); } } else if (o is InputVar) { InputVar v = o as InputVar; context.FreeVar(v.Name); } else if (o is InputObject) { InputObject ob = o as InputObject; context.FreeObject(ob.Name); } else { throw new Exception("Could not free '" + o.ToString() + "' because it was an unsupported type."); } return(0); }
public bool FreeVar(string name, bool originator = true) { if (originator) { name = name.ToLower(); } if (!Vars.TryGetValue(name, out InputVar var)) { if (ParentScope != null) { return(ParentScope.FreeVar(name, false)); } return(false); } var.Free(); Vars[name] = null; return(true); }