public VariableDereferenceNode(
     Token var,
     List <TypeLiteral> typeConstraint,
     bool inExpandableString)
 {
     this.NodeToken     = var;
     this._varName      = var.TokenText;
     this._variablePath = new ScopedItemLookupPath(this._varName);
     if (this.NodeToken.TokenText.Equals("true", StringComparison.OrdinalIgnoreCase))
     {
         this._useConstantValue      = true;
         this._constantValue         = (object)true;
         this.ValidAttributeArgument = true;
     }
     else if (this.NodeToken.TokenText.Equals("false", StringComparison.OrdinalIgnoreCase))
     {
         this._useConstantValue      = true;
         this._constantValue         = (object)false;
         this.ValidAttributeArgument = true;
     }
     else if (this.NodeToken.TokenText.Equals("null", StringComparison.OrdinalIgnoreCase))
     {
         this._useConstantValue      = true;
         this._constantValue         = (object)null;
         this.ValidAttributeArgument = true;
     }
     this._inExpandableString = inExpandableString;
     this._typeConstraint     = typeConstraint;
 }
 internal VariableDereferenceNode(string varName, int variableSlot)
 {
     this._varName              = varName;
     this._variablePath         = new ScopedItemLookupPath(varName);
     this._activationRecordSlot = variableSlot;
     this.IsInternalCode        = true;
 }
Пример #3
0
 internal void BindParameter(ScopedItemLookupPath variable, object value)
 {
     if (value == AutomationNull.Value)
     {
         value = (object)null;
     }
     this.Context.EngineSessionState.SetVariable(variable, value, true, CommandOrigin.Internal);
 }
Пример #4
0
 internal ScopedItemSearcher(SessionStateInternal sessionState, ScopedItemLookupPath lookupPath)
 {
     using (ScopedItemSearcher <T> .tracer.TraceConstructor((object)this))
     {
         if (sessionState == null)
         {
             throw ScopedItemSearcher <T> .tracer.NewArgumentNullException(nameof (sessionState));
         }
         if (lookupPath == null)
         {
             throw ScopedItemSearcher <T> .tracer.NewArgumentNullException(nameof (lookupPath));
         }
         this.sessionState = sessionState;
         this.lookupPath   = lookupPath;
         this.InitializeScopeEnumerator();
     }
 }
        private void PrivateSetValue(object value, ExecutionContext context)
        {
            SessionStateInternal engineSessionState = context.EngineSessionState;
            CommandOrigin        scopeOrigin        = engineSessionState.currentScope.ScopeOrigin;

            if (!this._variablePath.IsScopedItem)
            {
                engineSessionState.SetVariable(this._variablePath, value, true, scopeOrigin);
            }
            else
            {
                PSVariable variable1 = engineSessionState.CurrentActivationRecord.GetVariable(this._activationRecordSlot, scopeOrigin);
                if (variable1 != null)
                {
                    this.UpdateVariable(variable1, value);
                }
                else
                {
                    ScopedItemLookupPath variablePath = !this._variablePath.IsUnqualified ? this._variablePath : new ScopedItemLookupPath(this._variablePath, true);
                    SessionStateScope    scope;
                    PSVariable           variable2 = engineSessionState.GetVariableItem(variablePath, out scope, scopeOrigin);
                    if (variable2 == null)
                    {
                        if (string.IsNullOrEmpty(variablePath.LookupPath.NamespaceSpecificString))
                        {
                            throw InterpreterError.NewInterpreterException((object)this._varName, typeof(RuntimeException), this.NodeToken, "InvalidVariableReference");
                        }
                        variable2 = new PSVariable(variablePath.LookupPath.NamespaceSpecificString, (object)null, ScopedItemOptions.None, new Collection <Attribute>());
                        engineSessionState.SetVariable(variablePath, (object)variable2, false, scopeOrigin);
                        if (variablePath.IsLocal)
                        {
                            scope = context.EngineSessionState.CurrentScope;
                        }
                    }
                    engineSessionState.CurrentActivationRecord.SetVariable(variable2, scope, this._activationRecordSlot);
                    this.UpdateVariable(variable2, value);
                }
            }
        }
Пример #6
0
 public foreachStatementNode(
     Token nodeToken,
     string label,
     Token variable,
     ParseTreeNode expression,
     ParseTreeNode body)
 {
     this.NodeToken = nodeToken;
     this._variable = variable;
     this._label    = label == null ? "" : label;
     if (variable != null)
     {
         this._loopVariablePath = new ScopedItemLookupPath(variable.TokenText);
     }
     this._expression      = expression;
     this._rangeExpression = expression as ExpressionNode;
     if (this._rangeExpression != null && !this._rangeExpression.IsRangeExpression())
     {
         this._rangeExpression = (ExpressionNode)null;
     }
     this._body = body;
 }
Пример #7
0
 protected abstract bool GetScopeItem(
     SessionStateScope scope,
     ScopedItemLookupPath name,
     out T newCurrentItem);