public static Value ToValue(this List <float> floats) { if (floats == null) { return(null); } var result = new ValList(); foreach (float f in floats) { if (f == 0) { result.values.Add(ValNumber.zero); } else if (f == 1) { result.values.Add(ValNumber.one); } else { result.values.Add(new ValNumber(f)); } } return(result); }
public static Value ToValue(this Vector2 v) { ValList item = new ValList(); item.values.Add(new ValNumber(v.X)); item.values.Add(new ValNumber(v.Y)); return(item); }
public static List <float> ToFloatList(this ValList value) { var result = new List <float>(value.values.Count); for (int i = 0; i < value.values.Count; i++) { Value item = value.values[i]; result.Add(item.FloatValue()); } return(result); }
public static List <Vector2> ToVector2List(this ValList value) { var result = new List <Vector2>(value.values.Count); for (int i = 0; i < value.values.Count; i++) { Value item = value.values[i]; result.Add(item.ToVector2()); } return(result); }
public void Break(bool silent = false) { if (!silent && !allowControlCBreak) { return; } // grab the full stack and tuck it away for future reference ValList stack = M1API.StackList(interpreter.vm); // also find the first non-null entry, to display right away SourceLoc loc = null; if (interpreter.vm != null) { foreach (var stackLoc in interpreter.vm.GetStack()) { loc = stackLoc; if (loc != null) { break; } } } interpreter.Stop(); console.AbortInput(); console.keyBuffer.Clear(); if (!silent) { string msg = "BREAK"; if (loc != null) { msg += " at "; if (loc.context != null) { msg += loc.context + " "; } msg += "line " + loc.lineNum; } textDisplay.Print(msg + "\n"); //Debug.Log("printed: " + msg); } ValMap globals = interpreter.vm.globalContext.variables; interpreter.Reset(); interpreter.REPL(""); // (forces creation of a VM) interpreter.vm.globalContext.variables = globals; globals.SetElem(M1API._stackAtBreak, stack); AddGlobals(); //Debug.Log("Rebuilt VM and restored " + globals.Count + " globals"); }
public static ValList ToValue(this List <Vector2> vectors) { var result = new ValList(); for (int i = 0; i < vectors.Count; i++) { Vector2 v = vectors[i]; ValList item = new ValList(); item.values.Add(new ValNumber(v.X)); item.values.Add(new ValNumber(v.Y)); result.values.Add(item); } return(result); }
public static Value ToValue(this List <string> strings) { if (strings == null) { return(null); } var result = new ValList(); foreach (string name in strings) { result.values.Add(new ValString(name)); } return(result); }
public TimeFilter(ExCell exCell) : base() { ValList = exCell.ValList.Where(v => v.Type == CellValue.CellValType.Time). Select(v => v.ValTime).OrderBy(v => v).ToArray(); if (ValList.Any()) { _from = ValList.Min(); _to = ValList.Max(); } else { _from = new TimeSpan(0); _to = new TimeSpan(23, 59, 59); } }
void Invoke(string funcName) { Debug.Log("Invoking: " + funcName); Value handler = interpreter.GetGlobalValue(funcName); if (handler == null) { return; // no handler defined } var eventQ = interpreter.GetGlobalValue("_events") as ValList; if (eventQ == null) // make sure _events list exists! { eventQ = new ValList(); interpreter.SetGlobalValue("_events", eventQ); } // Add a reference to the handler function onto the event queue. // The main event loop will pick this up and invoke it ASAP. eventQ.values.Add(handler); }