/// <nodoc /> public ModuleRegistry(SymbolTable symbolTable) { PrimitiveTypes = new PrimitiveTypes(symbolTable.StringTable); GlobalLiteral = new GlobalModuleLiteral(symbolTable); PredefinedTypes = new Ambients.PredefinedTypes(PrimitiveTypes); PredefinedTypes.Register(GlobalLiteral); }
/// <inheritdoc /> public override void Initialize(GlobalModuleLiteral globalModuleLiteral) { Register(globalModuleLiteral); m_callableMembers = CreateMembers(); // Every type in DScript should implement toString method. m_callableMembers.Add(NameId(Constants.Names.ToStringFunction), CreateToStringMember()); m_callableMembersFast = m_callableMembers.ToDictionary(kvp => kvp.Key.Value, kvp => kvp.Value); }
/// <nodoc /> public GlobalConstants(SymbolTable symbolTable) { Contract.Requires(symbolTable != null); KnownTypes = new PrimitiveTypes(symbolTable.StringTable); Global = new GlobalModuleLiteral(symbolTable); PredefinedTypes = new Ambients.PredefinedTypes(KnownTypes); PredefinedTypes.Register(Global); // TODO: We are relying on the entire codebase pinky-swearing they won't mutate global. Ideally we want to force this. }
/// <summary> /// Registers ambient to the global module literal. /// </summary> protected virtual void Register(GlobalModuleLiteral globalModuleLiteral) { Contract.Requires(globalModuleLiteral != null); var namespaceDefinition = GetNamespaceDefinition(); if (namespaceDefinition != null) { RegisterNamespaceDefinition(globalModuleLiteral, namespaceDefinition.Value); } }
/// <nodoc /> public static SourceFileParseResult Read(BuildXLReader reader, GlobalModuleLiteral outerScope, ModuleRegistry moduleRegistry, PathTable pathTable) { var moduleLiteral = FileModuleLiteral.Read(reader, pathTable, outerScope, moduleRegistry); var context = new DeserializationContext(moduleLiteral, reader, pathTable, moduleLiteral.LineMap); var sourceFile = new SourceFile(AbsolutePath.Invalid, CollectionUtilities.EmptyArray <Declaration>()); var qualifierSpaceId = context.Reader.ReadQualifierSpaceId(); return(new SourceFileParseResult(sourceFile, moduleLiteral, qualifierSpaceId)); }
/// <nodoc /> protected void RegisterNamespaceDefinition( GlobalModuleLiteral globalModuleLiteral, AmbientNamespaceDefinition namespaceDefinition) { Contract.Requires(globalModuleLiteral != null); globalModuleLiteral.AddNamespace( FullSymbol.Create(globalModuleLiteral.SymbolTable, namespaceDefinition.Name), default(UniversalLocation), null, out TypeOrNamespaceModuleLiteral registeredModule); RegisterFunctionDefinitions(registeredModule, namespaceDefinition.FunctionDefinitions); }
/// <summary> /// Registers all ambients to the global module literal. /// </summary> /// <param name="global">The global module literal.</param> public void Register(GlobalModuleLiteral global) { Contract.Requires(global != null); AmbientArray.Initialize(global); m_ambientContext.Initialize(global); m_ambientDebug.Initialize(global); m_ambientContract.Initialize(global); m_ambientDirectory.Initialize(global); m_ambientEnum.Initialize(global); m_ambientFile.Initialize(global); m_ambientGlobal.Initialize(global); m_ambientMath.Initialize(global); AmbientObject.Initialize(global); m_ambientPath.Initialize(global); m_ambientStaticDirectory.Initialize(global); m_ambientString.Initialize(global); m_ambientStringBuilder.Initialize(global); m_ambientTransformerOriginal.Initialize(global); m_ambientTransformerHack.Initialize(global); m_ambientNumber.Initialize(global); m_ambientBoolean.Initialize(global); m_ambientUnit.Initialize(global); m_ambientEnvironment.Initialize(global); m_ambientArgumentKind.Initialize(global); m_ambientArtifactKind.Initialize(global); m_ambientMap.Initialize(global); m_ambientSet.Initialize(global); m_ambientMutableSet.Initialize(global); m_ambientKeyForm.Initialize(global); m_ambientPathAtom.Initialize(global); m_ambientRelativePath.Initialize(global); m_ambientTextEncoding.Initialize(global); m_ambientNameResolutionSemantics.Initialize(global); m_ambientSealSourceDirectoryOption.Initialize(global); m_ambientHashHelper.Initialize(global); m_ambientValueCacheHelper.Initialize(global); m_ambientJsonHelper.Initialize(global); m_ambientXmlHelper.Initialize(global); m_ambientContainerIsolationLevel.Initialize(global); m_ambientUnsafe.Initialize(global); }
/// <nodoc /> public RuntimeModelContext( FrontEndHost frontEndHost, FrontEndContext frontEndContext, Logger logger, Package package, GlobalModuleLiteral globals = null, ModuleRegistry moduleRegistry = null, LocationData origin = default(LocationData)) { Contract.Requires(frontEndHost != null); Contract.Requires(frontEndContext != null); Contract.Requires(package != null); FrontEndHost = frontEndHost; m_frontEndContext = frontEndContext; Package = package; RootPath = package.Path.GetParent(frontEndContext.PathTable); Globals = globals; ModuleRegistry = moduleRegistry ?? new ModuleRegistry(); Origin = origin; Logger = logger; }
/// <nodoc /> public ModuleRegistrySerializer(GlobalModuleLiteral globalModule, PathTable pathTable) { m_globalModule = globalModule; m_pathTable = pathTable; }
public void TestGlobalModuleLiteral() { GlobalModuleLiteral node = GlobalModuleLiteral; // Assert.Throws<System.Diagnostics.Contracts.ContractException>(() => CheckSerializationRoundTrip(node)); }
/// <nodoc /> public virtual void Initialize(GlobalModuleLiteral globalModuleLiteral) { Register(globalModuleLiteral); }
/// <inheritdoc /> protected override void Register(GlobalModuleLiteral globalModuleLiteral) { // Need to override Register method because global functions are a bit different from namespace level functions: // they should be registered directly in the global module, but not in the nested one. RegisterFunctionDefinitions(globalModuleLiteral, GetGlobalFunctionDefinitions()); }