/// <summary> /// Marks variable as being referenced. /// </summary> public void MarkLocalByRef(VariableHandle handle) { handle.ThrowIfInvalid(); this.FlowContext.SetReference(handle); this.SetVarInitialized(handle); _flowCtx.SetUsed(handle); }
/// <summary> /// Sets variable type in this state. /// </summary> /// <param name="handle">Variable handle.</param> /// <param name="tmask">Variable type. If <c>uninitialized</c>, the variable is set as not initialized in this state.</param> public void SetLocalType(VariableHandle handle, TypeRefMask tmask) { handle.ThrowIfInvalid(); if (handle >= _varsType.Length) { Array.Resize(ref _varsType, handle + 1); } _varsType[handle] = tmask; this.FlowContext.AddVarType(handle, tmask); // TODO: collect merged type information at the end of analysis // update the _initializedMask SetVarInitialized(handle); }
/// <summary> /// Gets kind of variable declaration in this state. /// </summary> public VariableKind GetVarKind(VariableHandle handle) { handle.ThrowIfInvalid(); //// explicit variable declaration //if (_varKindMap != null) //{ // VariableKind kind = VariableKind.LocalVariable; // if (_varKindMap.TryGetValue(varname, out kind)) // { // return kind; // } //} // already declared on locals label return(Routine.LocalsTable.GetVariableKind(handle.Name)); }
/// <summary> /// Gets value indicating the variable is set in all code paths. /// Gets also <c>true</c> if we don't known. /// </summary> public bool IsLocalSet(VariableHandle handle) { handle.ThrowIfInvalid(); return(handle.Slot >= FlowContext.BitsCount || (_initializedMask & (1u << handle)) != 0); }
/// <summary> /// Handles use of a local variable. /// </summary> public void VisitLocal(VariableHandle handle) { handle.ThrowIfInvalid(); _flowCtx.SetUsed(handle); }
/// <summary> /// Gets type of variable at this state. /// </summary> public TypeRefMask GetLocalType(VariableHandle handle) { handle.ThrowIfInvalid(); return((handle < _varsType.Length) ? _varsType[handle] : 0); }
/// <summary> /// Handles use of a local variable. /// </summary> public void VisitLocal(VariableHandle handle) { handle.ThrowIfInvalid(); FlowContext.SetUsed(handle); }