internal static void ResolveSymbols(Parser parser, ScriptBlockAst scriptBlockAst)
        {
            Diagnostics.Assert(scriptBlockAst.Parent == null, "Can only resolve starting from the root");

            var usingState = scriptBlockAst.UsingStatements.Count > 0
                ? new TypeResolutionState(TypeOps.GetNamespacesForTypeResolutionState(scriptBlockAst.UsingStatements), TypeResolutionState.emptyAssemblies)
                : TypeResolutionState.GetDefaultUsingState(null);
            var resolver = new SymbolResolver(parser, usingState);

            resolver._symbolTable.EnterScope(scriptBlockAst, ScopeType.ScriptBlock);
            scriptBlockAst.Visit(resolver);
            resolver._symbolTable.LeaveScope();

            Diagnostics.Assert(resolver._symbolTable._scopes.Count == 0, "Somebody missed removing a scope");
        }
Beispiel #2
0
        internal void AddTypeFromUsingModule(Parser parser, TypeDefinitionAst typeDefinitionAst, PSModuleInfo moduleInfo)
        {
            TypeLookupResult result;

            if (_typeTable.TryGetValue(typeDefinitionAst.Name, out result))
            {
                if (result.ExternalNamespaces != null)
                {
                    // override external type by the type defined in the current namespace
                    result.ExternalNamespaces.Add(moduleInfo.Name);
                }
            }
            else
            {
                var newLookupEntry = new TypeLookupResult(typeDefinitionAst)
                {
                    ExternalNamespaces = new List <string>()
                };
                newLookupEntry.ExternalNamespaces.Add(moduleInfo.Name);
                _typeTable.Add(typeDefinitionAst.Name, newLookupEntry);
            }

            string fullName = SymbolResolver.GetModuleQualifiedName(moduleInfo.Name, typeDefinitionAst.Name);

            if (_typeTable.TryGetValue(fullName, out result))
            {
                parser.ReportError(typeDefinitionAst.Extent,
                                   nameof(ParserStrings.MemberAlreadyDefined),
                                   ParserStrings.MemberAlreadyDefined,
                                   fullName);
            }
            else
            {
                _typeTable.Add(fullName, new TypeLookupResult(typeDefinitionAst));
            }
        }
Beispiel #3
0
        internal static void ResolveSymbols(Parser parser, ScriptBlockAst scriptBlockAst)
        {
            Diagnostics.Assert(scriptBlockAst.Parent == null, "Can only resolve starting from the root");

            var usingState = scriptBlockAst.UsingStatements.Count > 0
                ? new TypeResolutionState(TypeOps.GetNamespacesForTypeResolutionState(scriptBlockAst.UsingStatements), TypeResolutionState.emptyAssemblies)
                : TypeResolutionState.GetDefaultUsingState(null);
            var resolver = new SymbolResolver(parser, usingState);
            resolver._symbolTable.EnterScope(scriptBlockAst, ScopeType.ScriptBlock);
            scriptBlockAst.Visit(resolver);
            resolver._symbolTable.LeaveScope();

            Diagnostics.Assert(resolver._symbolTable._scopes.Count == 0, "Somebody missed removing a scope");
        }
		private void ConfigureAllExtensions()
		{
			this.workflowApplication.InstanceStore = this._stores.CreateInstanceStore();
			PersistenceIOParticipant persistenceIOParticipant = this._stores.CreatePersistenceIOParticipant();
			if (persistenceIOParticipant != null)
			{
				this.workflowApplication.Extensions.Add(persistenceIOParticipant);
			}
			this.workflowApplication.Extensions.Add(this.GetTrackingParticipant());
			IEnumerable<object> objs = base.Runtime.Configuration.CreateWorkflowExtensions();
			if (objs != null)
			{
				foreach (object obj in objs)
				{
					this.workflowApplication.Extensions.Add(obj);
				}
			}
			IEnumerable<Func<object>> funcs = base.Runtime.Configuration.CreateWorkflowExtensionCreationFunctions<object>();
			if (funcs != null)
			{
				foreach (Func<object> func in funcs)
				{
					this.workflowApplication.Extensions.Add<object>(func);
				}
			}
			this._paramDefaults = new HostParameterDefaults();
			if (this.PSWorkflowContext.PSWorkflowCommonParameters != null)
			{
				foreach (KeyValuePair<string, object> pSWorkflowCommonParameter in this.PSWorkflowContext.PSWorkflowCommonParameters)
				{
					if (!(pSWorkflowCommonParameter.Key != "PSRunningTimeoutSec") || !(pSWorkflowCommonParameter.Key != "PSElapsedTimeoutSec"))
					{
						continue;
					}
					this._paramDefaults.Parameters.Add(pSWorkflowCommonParameter.Key, pSWorkflowCommonParameter.Value);
				}
			}
			if (this.PSWorkflowContext.PrivateMetadata != null)
			{
				this._paramDefaults.Parameters["PSPrivateMetadata"] = this.PSWorkflowContext.PrivateMetadata;
			}
			if (this.PSWorkflowContext.JobMetadata.ContainsKey("Name"))
			{
				this._paramDefaults.Parameters["JobName"] = this.PSWorkflowContext.JobMetadata["Name"];
			}
			if (this.PSWorkflowContext.JobMetadata.ContainsKey("InstanceId"))
			{
				this._paramDefaults.Parameters["JobInstanceId"] = this.PSWorkflowContext.JobMetadata["InstanceId"];
			}
			if (this.PSWorkflowContext.JobMetadata.ContainsKey("Id"))
			{
				this._paramDefaults.Parameters["JobId"] = this.PSWorkflowContext.JobMetadata["Id"];
			}
			if (this.PSWorkflowContext.JobMetadata.ContainsKey("Command"))
			{
				this._paramDefaults.Parameters["JobCommandName"] = this.PSWorkflowContext.JobMetadata["Command"];
			}
			if (this.PSWorkflowContext.JobMetadata.ContainsKey("ParentName"))
			{
				this._paramDefaults.Parameters["ParentJobName"] = this.PSWorkflowContext.JobMetadata["ParentName"];
			}
			if (this.PSWorkflowContext.JobMetadata.ContainsKey("ParentInstanceId"))
			{
				this._paramDefaults.Parameters["ParentJobInstanceId"] = this.PSWorkflowContext.JobMetadata["ParentInstanceId"];
			}
			if (this.PSWorkflowContext.JobMetadata.ContainsKey("ParentSessionId"))
			{
				this._paramDefaults.Parameters["ParentJobId"] = this.PSWorkflowContext.JobMetadata["ParentSessionId"];
			}
			if (this.PSWorkflowContext.JobMetadata.ContainsKey("ParentCommand"))
			{
				this._paramDefaults.Parameters["ParentCommandName"] = this.PSWorkflowContext.JobMetadata["ParentCommand"];
			}
			this._paramDefaults.Parameters["WorkflowInstanceId"] = this.InstanceId;
			this._paramDefaults.Parameters["Input"] = this.Streams.InputStream;
			this._paramDefaults.Parameters["Result"] = this.Streams.OutputStream;
			this._paramDefaults.Parameters["PSError"] = this.Streams.ErrorStream;
			this._paramDefaults.Parameters["PSWarning"] = this.Streams.WarningStream;
			this._paramDefaults.Parameters["PSProgress"] = this.Streams.ProgressStream;
			this._paramDefaults.Parameters["PSVerbose"] = this.Streams.VerboseStream;
			this._paramDefaults.Parameters["PSDebug"] = this.Streams.DebugStream;
			this._paramDefaults.Runtime = base.Runtime;
			this._paramDefaults.JobInstanceId = this._job.InstanceId;
			Func<bool> func1 = new Func<bool>(this.CheckForPersistenceAfterPSActivity);
			this._paramDefaults.HostPersistenceDelegate = func1;
			Action<object> action = new Action<object>(this.ReactivateWorkflow);
			this._paramDefaults.ActivateDelegate = action;
			this._paramDefaults.AsyncExecutionCollection = this.asyncExecutionCollection;
			SymbolResolver symbolResolvers = new SymbolResolver();
			symbolResolvers.Add("ParameterDefaults", this._paramDefaults);
			this.workflowApplication.Extensions.Add(symbolResolvers);
			this.workflowApplication.Extensions.Add(this._paramDefaults);
		}