protected override Variable Evaluate(ParsingScript script) { // 1. Get the name of the variable. string varName = Utils.GetToken(script, Constants.END_ARG_ARRAY); Utils.CheckNotEnd(script, m_name); List <Variable> arrayIndices = Utils.GetArrayIndices(ref varName); // 2. Get the current value of the variable. ParserFunction func = ParserFunction.GetFunction(varName); Utils.CheckNotNull(varName, func); Variable currentValue = func.GetValue(script); Variable element = currentValue; // 2b. Special case for an array. if (arrayIndices.Count > 0)// array element { element = Utils.ExtractArrayElement(currentValue, arrayIndices); script.MoveForwardIf(Constants.END_ARRAY); } // 3. Convert type to string. string type = Constants.TypeToString(element.Type); script.MoveForwardIf(Constants.END_ARG, Constants.SPACE); Variable newValue = new Variable(type); return(newValue); }
public virtual string GetTypeString() { if (Type == VarType.OBJECT && Object != null) { return(Object.GetType().ToString()); } return(Constants.TypeToString(Type)); }
public override string GetTypeString() { switch (WidgetType) { case UIVariable.UIType.VIEW: return("View"); case UIVariable.UIType.BUTTON: return("Button"); case UIVariable.UIType.LABEL: return("Label"); case UIVariable.UIType.TEXT_FIELD: return("TextEdit"); case UIVariable.UIType.TEXT_VIEW: return("TextView"); case UIVariable.UIType.IMAGE_VIEW: return("ImageView"); case UIVariable.UIType.COMBOBOX: return("Combobox"); case UIVariable.UIType.INDICATOR: return("Indicator"); case UIVariable.UIType.PICKER_VIEW: return("TypePicker"); case UIVariable.UIType.PICKER_IMAGES: return("Picker"); case UIVariable.UIType.LIST_VIEW: return("ListView"); case UIVariable.UIType.SWITCH: return("Switch"); case UIVariable.UIType.SLIDER: return("Slider"); case UIVariable.UIType.STEPPER: return("Stepper"); case UIVariable.UIType.SEGMENTED: return("SegmentedControl"); } return(Constants.TypeToString(Type)); }
static string CreateVariableEntry(ParserFunction variable, bool isLocal = false) { if (!(variable is GetVarFunction) || string.IsNullOrWhiteSpace(variable.Name)) { return(null); } GetVarFunction gvf = variable as GetVarFunction; string value = gvf.Value.AsString(true, true, 16); string localGlobal = isLocal ? "0" : "1"; string varData = variable.Name + ":" + localGlobal + ":" + Constants.TypeToString(gvf.Value.Type).ToLower() + ":" + value; return(varData.Trim()); }
static string CreateVariableEntry(Variable var, string name, bool isLocal = false) { try { string value = var.AsString(true, true, 16); string localGlobal = isLocal ? "0" : "1"; string varData = name + ":" + localGlobal + ":" + Constants.TypeToString(var.Type).ToLower() + ":" + value; return(varData.Trim()); } catch (Exception exc) { // TODO: Clean up not used objects. bool removed = isLocal ? PopLocalVariable(name) : RemoveGlobal(name); Console.WriteLine("Object {0} is probably dead ({1}): {2}. Removing it.", name, removed, exc); return(null); } }