private bool _readBeforeInitialized; // the variable is read before it's initialized and therefore needs an init check #endregion Fields #region Constructors public TotemVariable(string name, VariableKind kind, ScopeStatement/*!*/ scope) { Assert.NotNull(scope); _name = name; _kind = kind; _scope = scope; }
public PythonVariable(SymbolId name, Type/*!*/ type, VariableKind kind, ScopeStatement/*!*/ scope) { Assert.NotNull(type, scope); _name = name; _type = type; _kind = kind; _scope = scope; }
public TotemVariable(string name, VariableKind kind, ScopeStmt scope) { ContractUtils.RequiresNotNull(scope, "totemCode"); _name = name; _kind = kind; _scope = scope; }
private Variable(SymbolId name, VariableKind kind, CodeBlock block, Type type, Expression defaultValue, bool parameterArray) { _name = name; _kind = kind; _block = block; Debug.Assert(new List<Variable>(block.Variables).Find(x => x.Name == name) == null); // enables case: // // temp = CreateVariable(..., expression.Type, ...) // Ast.Assign(temp, expression) // // where Type is void. _type = (type != typeof(void)) ? type : typeof(object); _defaultValue = defaultValue; _parameterArray = parameterArray; }
BoundVariable CreateVariable(VariableName name, VariableKind kind, Func<BoundExpression> initializer) { switch (kind) { case VariableKind.LocalVariable: Debug.Assert(initializer == null); return new BoundLocal(new SourceLocalSymbol(_routine, name.Value, kind)); case VariableKind.StaticVariable: return new BoundStaticLocal(new SourceLocalSymbol(_routine, name.Value, kind), initializer?.Invoke()); case VariableKind.GlobalVariable: Debug.Assert(initializer == null); return new BoundGlobalVariable(name); default: Debug.Assert(initializer == null); throw Roslyn.Utilities.ExceptionUtilities.UnexpectedValue(kind); } }
//internal TotemReference Reference(string name) //{ // if (_references == null) // { // _references = new Dictionary<string, TotemReference>(StringComparer.Ordinal); // } // TotemReference reference; // if (!_references.TryGetValue(name, out reference)) // { // _references[name] = reference = new TotemReference(name); // } // return reference; //} //internal bool IsReferenced(string name) //{ // TotemReference reference; // return _references != null && _references.TryGetValue(name, out reference); //} internal TotemVariable CreateVariable(string name, VariableKind kind) { EnsureVariables(); Debug.Assert(!_variables.ContainsKey(name)); TotemVariable variable; _variables[name] = variable = new TotemVariable(name, kind, this); return variable; }
private bool _uninitialized; // Variable ever used either uninitialized or after deletion private Variable(SymbolId name, VariableKind kind, CodeBlock block, Type type, Expression defaultValue) : this(name, kind, block, type, defaultValue, true) { }
internal static Variable Create(SymbolId name, VariableKind kind, CodeBlock block, Type type, Expression defaultValue) { Contract.Requires(defaultValue == null || TypeUtils.CanAssign(type, defaultValue.Type)); Contract.Requires(kind != VariableKind.Parameter, "kind"); return(new Variable(name, kind, block, type, defaultValue)); }
public GetVariableOption(VariableKind kind, string defaultName = null) : base(kind, defaultName) { }
public SetDictionaryVariableItemNodeOption(VariableKind kind, string defaultName = null) : base(kind, defaultName) { }
public ILVariable RegisterVariable(VariableKind kind, StackType stackType, string name = null) { var type = Method.Compilation.FindType(stackType.ToKnownTypeCode()); return(RegisterVariable(kind, type, stackType, name)); }
public VariableSymbol(string name, SourceRange source, Type type, VariableKind kind) => (Name, Source, Type, Kind) = (name, source, type, kind);
public BoxedVariable(bool slack) { this.var = default(Variable); this.innerVar = new InnerVariable(); this.varKind = slack ? VariableKind.Slack: VariableKind.NoFramework; }
protected IDisposable NameRefTag(VariableKind kind, string name = null, string fullName = null) { return(Tag(NameRefElementName, VariableKindAttribute(kind), NameAttribute(name), FullNameAttribute(fullName))); }
protected RDomBaseVariable(string name, string typeName, IExpression initializer, bool isImplicitlyTyped, bool isAliased, VariableKind variableKind) : this(name, initializer, isImplicitlyTyped, isAliased, variableKind) { _type = new RDomReferencedType(this, typeName, isAliased); }
/// <summary> /// Returns the name of the given variable kind. /// </summary> /// <param name="variableKind">The variable kind whose name is to be returned.</param> /// <returns></returns> public static string VariableKindName(VariableKind variableKind) { return(CNTKLib.VariableKindName(variableKind)); }
private RDomBaseVariable(string name, IExpression initializer, bool isImplicitlyTyped, bool isAliased, VariableKind variableKind) : base() { _name = name; _initializer = initializer; _isImplicitlyTyped = IsImplicitlyTyped; _isAliased = isAliased; _variableKind = variableKind; }
public static void Add(ListView view, string sfOffset, string name, string type, string value, VariableKind kind, IntPtr sf, IntPtr pc, int callDepth) { var s = new SFItem { Name = name, SFOffset = sfOffset, Type = type, Value = value, Kind = kind, SF = sf, PC = pc, CallDepth = callDepth }; var item = new ListViewItem { Content = s }; switch (kind) { case VariableKind.Global: item.Foreground = Brushes.DimGray; break; case VariableKind.Input: item.Foreground = Brushes.Black; break; case VariableKind.Output: item.Foreground = Brushes.Black; break; case VariableKind.Local: item.Foreground = Brushes.Black; break; case VariableKind.Pseudo: item.Foreground = Brushes.Red; break; } view.Items.Add(item); }
/// <summary> /// Create virtual reference according to originatedVariable /// </summary> /// <param name="originatedVariable">Variable determining reference target</param> /// <param name="kind">Kind of virtual reference</param> /// <param name="stamp">Context stamp of virtual reference</param> internal VirtualReference(VariableName originatedVariable, VariableKind kind, int stamp) { OriginatedVariable = originatedVariable; Kind = kind; ContextStamp = stamp; }
public ZVariable(VariableKind variableKind) { _variableKind = variableKind; }
internal static Variable Create(SymbolId name, VariableKind kind, CodeBlock block, Type type) { return Create(name, kind, block, type, null); }
/*!*/ internal JVariable CreateVariable(string name, VariableKind kind) { EnsureVariables(); JVariable variable; _variables[name] = variable = new JVariable(name, kind, this); return variable; }
internal static Variable Create(SymbolId name, VariableKind kind, CodeBlock block, Type type, Expression defaultValue) { Contract.Requires(defaultValue == null || TypeUtils.CanAssign(type, defaultValue.Type)); Contract.Requires(kind != VariableKind.Parameter, "kind"); return new Variable(name, kind, block, type, defaultValue); }
private Variable(int index, Type type, VariableKind kind, string name) { this.index = index; this.type = type; this.kind = kind; this.name = name; options = new OptionsHash(); usersArray = new NodeArray(); }
internal void LiftToClosure() { switch(_kind) { case VariableKind.Local: case VariableKind.Parameter: _lift = true; Block.HasEnvironment = true; break; case VariableKind.Temporary: _kind = VariableKind.Local; goto case VariableKind.Local; default: throw new InvalidOperationException(String.Format("Cannot lift variable of kind {0} to a closure ('{1}')", _kind, _name)); } }
// Update a field in a table entry. Create new entry if necessary. // Returns null on success, otherwise error message. public string PutField(string parameterNameOrIndex, string fieldNameOrId, object value) { string result = null; if (!String.IsNullOrWhiteSpace(parameterNameOrIndex) && value != null) { DeviceParameter d = Find(parameterNameOrIndex); bool isNew = (d == null); if (isNew) { d = new DeviceParameter(parameterNameOrIndex); } switch (DeviceParameter.GetFieldId(fieldNameOrId)) { case DeviceParameter.FieldId.IndexField: try { int v = (int)value; if (v >= 0) { if (!isNew && d.ParamIndex >= 0) { IndexTable.Remove(d.ParamIndex); } d.ParamIndex = v; isNew = true; } else { result = "Error: negative index."; } } catch (Exception) { result = "Error: invalid index type."; } break; case DeviceParameter.FieldId.CategoryField: try { int v = (int)value; if (v >= 0) { d.ParamCategory = v; } else { result = "Error: negative category."; } } catch (Exception) { result = "Error: invalid category type."; } break; case DeviceParameter.FieldId.VariableKindField: try { VariableKind v = VariableValue.StringToVK(value.ToString()); d.ParamVarKind = v; if (v == VariableKind.VK_None) { result = "Error: bad representation kind."; } } catch (Exception) { result = "Error: invalid representation kind type."; } break; case DeviceParameter.FieldId.SizeField: try { int v = (int)value; if (v >= 0) { d.ParamSize = v; } else { d.ParamSize = VariableValue.DataSize(d.ParamVarKind); } } catch (Exception) { result = "Error: invalid size value."; } break; case DeviceParameter.FieldId.StorageFlagsField: try { StorageFlags v = VariableValue.StringToSF(value.ToString()); d.ParamStorageFlags = v; if (v == StorageFlags.SF_None) { result = "Error: bad storage flags."; } } catch (Exception) { result = "Error: invalid storage flags type."; } break; case DeviceParameter.FieldId.MinValueField: try { d.MinValue = new VariableValue(d.ParamVarKind, value.ToString()); } catch (Exception) { result = "Error: invalid min value type."; } break; case DeviceParameter.FieldId.MaxValueField: try { d.MaxValue = new VariableValue(d.ParamVarKind, value.ToString()); } catch (Exception) { result = "Error: invalid max value type."; } break; case DeviceParameter.FieldId.DefaultValueField: try { d.DefaultValue = new VariableValue(d.ParamVarKind, value.ToString()); } catch (Exception) { result = "Error: invalid default value type."; } break; case DeviceParameter.FieldId.RamValueField: try { d.RamValue = new VariableValue(d.ParamVarKind, value.ToString()); } catch (Exception) { result = "Error: invalid ram value type."; } break; case DeviceParameter.FieldId.EepromValueField: try { d.EEPromValue = new VariableValue(d.ParamVarKind, value.ToString()); } catch (Exception) { result = "Error: invalid Eeprom value type."; } break; case DeviceParameter.FieldId.NameField: try { string s = value.ToString().Trim().ToLower(); if (!isNew && !String.IsNullOrWhiteSpace(d.ParamName)) { NameTable.Remove(d.ParamName); } d.ParamName = s; isNew = true; } catch (Exception) { result = "Error: invalid index type."; } break; default: result = "Error: invalid field name or Id."; break; } if (isNew && result == null) { Add(d); } } return(result); }
private bool _uninitialized; // Variable ever used either uninitialized or after deletion #endregion Fields #region Constructors private Variable(SymbolId name, VariableKind kind, CodeBlock block, Type type, Expression defaultValue) : this(name, kind, block, type, defaultValue, true) { }
protected BoundVariable(VariableKind kind) { this.VariableKind = kind; }
internal VariableDefinition(VariableDescriptor[] variables, Expression[] initializers, VariableKind kind) { _initializers = initializers; _variables = variables; _kind = kind; }
public PlusEqualNodeOption(VariableKind kind, string defaultName = null) : base(kind, defaultName) { }
/// <summary> /// Gets local variable or create local if not yet. /// </summary> public BoundVariable BindVariable(VariableName varname, VariableKind kind, Func<BoundExpression> initializer = null) { BoundVariable value; if (_dict.TryGetValue(varname, out value)) { if (value.VariableKind != kind) { // variable redeclared with a different kind throw new ArgumentException("", nameof(kind)); } } else { _dict[varname] = value = CreateVariable(varname, kind, initializer); } // Debug.Assert(value != null); return value; }
internal static Variable Create(SymbolId name, VariableKind kind, CodeBlock block, Type type) { return(Create(name, kind, block, type, null)); }
internal PythonVariable/*!*/ CreateVariable(string name, VariableKind kind) { EnsureVariables(); Debug.Assert(!_variables.ContainsKey(name)); PythonVariable variable; _variables[name] = variable = new PythonVariable(name, kind, this); return variable; }
public RDomVariableDeclaration( string name, IReferencedType type, IExpression initializer = null, bool isImplicitlyTyped = false, bool isAliased = false, VariableKind variableKind = VariableKind.Local) : base(name, type, initializer, isImplicitlyTyped, isAliased, variableKind) { }
private bool _accessedInNestedScope; // the variable is accessed in a nested scope and therefore needs to be a closure var internal PythonVariable(string name, VariableKind kind, ScopeStatement/*!*/ scope) { _name = name; _kind = kind; _scope = scope; }
internal PythonVariable/*!*/ CreateVariable(string name, VariableKind kind) { EnsureVariables(); PythonVariable variable; _variables[name] = variable = new PythonVariable(name, kind, this); return variable; }
private AttributeInfo VariableKindAttribute(VariableKind kind) { if (kind == VariableKind.None) { return AttributeInfo.Empty; } return new AttributeInfo(VariableKindAttributeName, GetVariableKindText(kind)); }
public ZVariable(VariableKind variableKind, byte variableNumber) : this(variableKind) { _variableNumber = variableNumber; }
internal PythonVariable CreateVariable(SymbolId name, VariableKind kind) { EnsureVariables(); Debug.Assert(!_variables.ContainsKey(name)); PythonVariable variable; _variables[name] = variable = new PythonVariable(name, typeof(object), kind, this); return variable; }
private bool _accessedInNestedScope; // the variable is accessed in a nested scope and therefore needs to be a closure var internal PythonVariable(string name, VariableKind kind, ScopeStatement /*!*/ scope) { _name = name; _kind = kind; _scope = scope; }
public ILVariable RegisterVariable(VariableKind kind, IType type, string name = null) { return(RegisterVariable(kind, type, type.GetStackType(), name)); }
protected IDisposable NameRefTag(VariableKind kind) { return Tag(NameRefElementName, VariableKindAttribute(kind)); }
public static String Format(VariableKind kind, double val, int size) { switch (kind) { case VariableKind.VK_OnOff: case VariableKind.VK_Enum: return(String.Format("0x{0:x2}", (Byte)val)); case VariableKind.VK_Bits: if (size < 0) { size = DataSize(kind); } switch (size) { case 4: return(String.Format("0x{0:x8}", (UInt32)val)); case 2: return(String.Format("0x{0:x4}", (UInt16)val)); default: return(String.Format("0x{0:x2}", (Byte)val)); } case VariableKind.VK_Byte: return(String.Format("0x{0:x2}", (Byte)val)); case VariableKind.VK_UShort: return(String.Format("0x{0:x4}", (ushort)val)); case VariableKind.VK_UInt: return(String.Format("0x{0:x8}", (UInt32)val)); case VariableKind.VK_ULong: return(String.Format("0x{0:x16}", (UInt64)val)); case VariableKind.VK_ID: return(String.Format("0x{0:x8}", (UInt32)val)); case VariableKind.VK_LID: return(String.Format("0x{0:x16}", (UInt64)val)); case VariableKind.VK_String: return("\"" + DoubleToString(val) + "\""); case VariableKind.VK_Float: return(((float)val).ToString()); case VariableKind.VK_Double: return(val.ToString()); case VariableKind.VK_SByte: case VariableKind.VK_Short: case VariableKind.VK_Int: case VariableKind.VK_Long: return(val.ToString()); default: break; } return("0"); }
private static string GetVariableKindText(VariableKind kind) { switch (kind) { case VariableKind.Property: return "property"; case VariableKind.Method: return "method"; case VariableKind.Field: return "field"; case VariableKind.Local: return "local"; case VariableKind.Unknown: return "unknown"; default: throw new InvalidOperationException("Invalid SymbolKind: " + kind.ToString()); } }
public VariableValue(VariableKind kind, byte[] ary, int startIndex, int len) { Kind = kind; SetValue(ary, startIndex, len); }
protected IDisposable NameRefTag(VariableKind kind, string name = null, string fullName = null) { return Tag(NameRefElementName, VariableKindAttribute(kind), NameAttribute(name), FullNameAttribute(fullName)); }
internal BoundLocal(SourceLocalSymbol symbol, VariableKind kind = VariableKind.LocalVariable) : base(kind) { Debug.Assert(kind == VariableKind.LocalVariable || kind == VariableKind.LocalTemporalVariable); _symbol = symbol; }
internal Variable(Type type, VariableKind kind) { index = freeIndex++; this.type = type; this.kind = kind; options = new OptionsHash(); usersArray = new NodeArray(); switch (kind) { case VariableKind.Local: name = "Loc" + index; break; case VariableKind.Parameter: name = "Arg" + index; break; case VariableKind.ArgList: name = "ArgList"; break; } }
public DecrementUnitOption(VariableKind kind, string defaultName = null) : base(kind, defaultName) { }
public Variable CreateVar(Type type, VariableKind kind) { Variable var = new Variable(type,kind); vars.Add(var.Index,var); if (var.Kind != VariableKind.Local) mapper.Add(var); return var; }
public static IEnumerable <string> GetVariableNameSuggestions(VariableKind kind, GraphReference reference) { return(LinqUtility.Concat <string>(GetPredefinedVariableNames(kind, reference), GetDynamicVariableNames(kind, reference)).Distinct().OrderBy(name => name)); }