Exemple #1
0
        public void GlobalScope_HandleDebugOptions_Configures_Verify()
        {
            List <string> args = new List <string>();

            args.Add("--verify");

            GlobalScope.HandleDebugOptions(args);

            Assert.IsTrue(Validator.IsVerifyEnabled);
        }
            protected override Expression VisitParameter(ParameterExpression node)
            {
                if (!TryLookup(node, out ParameterExpression res))
                {
                    res = GetState(node);
                    GlobalScope.Add(node, res);
                }

                return(res);
            }
Exemple #3
0
        private void WriteUnrefedReport(GlobalScope globalScope)
        {
            if (globalScope.UndefinedReferences != null && globalScope.UndefinedReferences.Count > 0)
            {
                // sort the undefined reference exceptions
                var undefinedList = new List <UndefinedReference>(globalScope.UndefinedReferences);
                undefinedList.Sort((left, right) =>
                {
                    // first do the right thing if one or both are null
                    if (left == null && right == null)
                    {
                        // both null -- equal
                        return(0);
                    }

                    if (left == null)
                    {
                        // left is null, right is not -- left is less
                        return(-1);
                    }

                    if (right == null)
                    {
                        // left is not null, right is -- left is more
                        return(1);
                    }

                    // neither are null
                    int comparison = string.Compare(left.ToString(), right.ToString(), StringComparison.OrdinalIgnoreCase);
                    if (comparison == 0)
                    {
                        comparison = left.Line - right.Line;
                        if (comparison == 0)
                        {
                            comparison = left.Column - right.Column;
                        }
                    }

                    return(comparison);
                });

                // write the report
                WriteProgress();
                WriteProgress(NUglify.UndefinedGlobalHeader);
                foreach (UndefinedReference ex in undefinedList)
                {
                    WriteProgress(NUglify.UndefinedInfo.FormatInvariant(
                                      ex.Name,
                                      ex.Line,
                                      ex.Column,
                                      ex.ReferenceType.ToString()
                                      ));
                }
            }
        }
        public ExpressionEval(IServiceContainer services, IPythonModule module, GlobalScope gs)
        {
            Services = services ?? throw new ArgumentNullException(nameof(services));
            Module   = module ?? throw new ArgumentNullException(nameof(module));
            Ast      = module.GetAst();

            GlobalScope     = gs;
            CurrentScope    = GlobalScope;
            DefaultLocation = new Location(module);
            //Log = services.GetService<ILogger>();
        }
Exemple #5
0
        private void CloseSession()
        {
            if (GlobalScope != null)
            {
                GlobalScope.QuickClose();
                GlobalScope.Dispose();
                GlobalScope = null;

                Logger.Current.Info(() => LedgerSessionEnded);
            }
        }
Exemple #6
0
        private InsertMethodsPass CreatePass(params Function[] functions)
        {
            var scope = GlobalScope.Generate();

            foreach (var fn in functions)
            {
                scope.DeclareFunction(fn);
            }

            return(new InsertMethodsPass(scope.GlobalScope));
        }
Exemple #7
0
        public void GlobalScope_HandleDebugOptions_Configures_Trace()
        {
            List <string> args = new List <string>();

            args.Add("--trace");
            args.Add("23");

            GlobalScope.HandleDebugOptions(args);

            Assert.Equal(LogLevelEnum.LOG_TRACE, Logger.Current.LogLevel);
            Assert.Equal(23, Logger.Current.TraceLevel);
        }
        public ExpressionEval(IServiceContainer services, IPythonModule module, PythonAst ast)
        {
            Services = services ?? throw new ArgumentNullException(nameof(services));
            Module   = module ?? throw new ArgumentNullException(nameof(module));
            Ast      = ast ?? throw new ArgumentNullException(nameof(ast));

            GlobalScope          = new GlobalScope(module);
            CurrentScope         = GlobalScope;
            DefaultLookupOptions = LookupOptions.Normal;

            //Log = services.GetService<ILogger>();
        }
        public void Should_return_root_scope_by_default()
        {
            var globalScope = new GlobalScope <SymbolNode>();
            var node        = new SymbolNode("abc");

            var builder = CreateScopeBuilder(globalScope);
            var scope   = builder.Visit(node);

            scope.ShouldBeOfType <BoundScope <SymbolNode> >();
            scope.TargetScope.ShouldBe(globalScope);
            scope.Node.ShouldBe(node);
        }
Exemple #10
0
 private void Dispose(bool disposing)
 {
     if (_scope != null)
     {
         _scope.engine.Close();
         if (disposing)
         {
             GC.SuppressFinalize(this);
         }
     }
     _scope = null;
 }
Exemple #11
0
        public void GlobalScope_HandleDebugOptions_Configures_Debug()
        {
            List <string> args = new List <string>();

            args.Add("--debug");
            args.Add("debug-category");

            GlobalScope.HandleDebugOptions(args);

            Assert.Equal(LogLevelEnum.LOG_DEBUG, Logger.Current.LogLevel);
            Assert.Equal("debug-category", Logger.Current.LogCategory);
        }
Exemple #12
0
        private ReorderScopeVisitor(JSParser parser)
        {
            // save the mods we care about
            var settings = parser.Settings;

            m_moveVarStatements   = settings.ReorderScopeDeclarations && settings.IsModificationAllowed(TreeModifications.CombineVarStatementsToTopOfScope);
            m_moveFunctionDecls   = settings.ReorderScopeDeclarations && settings.IsModificationAllowed(TreeModifications.MoveFunctionToTopOfScope);
            m_combineAdjacentVars = settings.IsModificationAllowed(TreeModifications.CombineVarStatements);
            //m_localRenaming = settings.LocalRenaming != LocalRenaming.KeepAll && settings.IsModificationAllowed(TreeModifications.LocalRenaming);

            m_globalScope = parser.GlobalScope;
        }
            public PartialTrustEvaluationStrategy(string expression, VsaEngine engine)
                : base(engine)
            {
                //
                // Following is equivalent to declaring a "var" in JScript
                // at the level of the Global object.
                //

                _scope        = (GlobalScope)engine.GetGlobalScope().GetObject();
                _contextField = _scope.AddField("$context");
                _expression   = expression;
            }
Exemple #14
0
        /// <summary>
        /// Gets the list of modules known by the current analysis.
        /// </summary>
        /// <param name="topLevelOnly">Only return top-level modules.</param>
        public MemberResult[] GetModules(bool topLevelOnly = false)
        {
            List <MemberResult> res = new List <MemberResult>(ProjectState.GetModules(topLevelOnly));

            var children = GlobalScope.GetChildrenPackages(InterpreterContext);

            foreach (var child in children)
            {
                res.Add(new MemberResult(child.Key, PythonMemberType.Module));
            }

            return(res.ToArray());
        }
        public void Should_not_scope_atom_nodes()
        {
            var fooNode = new NumberNode("123");
            var body    = new ListNode(fooNode);
            var methodDefinitionNode = new MethodDefinitionNode("sayMessage", new ParameterDefinitionNode[] { new ParameterDefinitionNode("message"), }, body);

            var globalScope = new GlobalScope <SymbolNode>();

            var builder     = CreateScopeBuilder(globalScope);
            var resultScope = builder.GetScope(methodDefinitionNode, globalScope);

            resultScope.Descendants().OfType <BoundScope <SymbolNode> >().Any(scope => scope.Node == fooNode).ShouldBe(false);
        }
Exemple #16
0
        static TemplateContext()
        {
            // Global properties
            GlobalScope.SetValue("empty", NilValue.Empty);
            GlobalScope.SetValue("blank", StringValue.Empty);

            // Initialize Global Filters
            GlobalFilters
            .WithArrayFilters()
            .WithStringFilters()
            .WithNumberFilters()
            .WithMiscFilters();
        }
Exemple #17
0
        public void UpdateScope()
        {
            GlobalScope.Scope.Items.Clear();


            foreach (VBlock vBlock in GlobalScopePanel.Controls)
            {
                AddItemToScope(vBlock);
            }

            GlobalScope.UpdateFunctionNames();
            GlobalScope.Scope.UpdateLocalVariables();
        }
        public void Should_scope_parameters()
        {
            var body = new ListNode();
            var methodDefinitionNode = new MethodDefinitionNode("sayMessage", new ParameterDefinitionNode[] { new ParameterDefinitionNode("message"), }, body);

            var globalScope = new GlobalScope <SymbolNode>();

            var builder     = CreateScopeBuilder(globalScope);
            var resultScope = builder.GetScope(methodDefinitionNode, globalScope);

            resultScope.Resolve("message").ShouldNotBe(null);
            resultScope.Resolve("message").ShouldBeOfType <ParameterDefinitionNode>();
        }
Exemple #19
0
        protected static Scope Scope(params TypeMapping[] locals)
        {
            var globalScope = new GlobalScope();
            var localScope  = new LocalScope(globalScope);

            foreach (var local in locals)
            {
                var item = local(null);
                var name = local.Method.GetParameters()[0].Name;
                localScope.Bind(name, item);
            }

            return(localScope);
        }
Exemple #20
0
        public override void ExitFunctionCallExpression([NotNull] PigeonParser.FunctionCallExpressionContext context)
        {
            var functionName = context.functionCall().ID().GetText();

            if (GlobalScope.TryGetFunction(functionName, out var function))
            {
                Types.Put(context, function.ReturnType);
            }
            else
            {
                Types.Put(context, PigeonType.Error);
                errorBag.ReportUndeclaredFunction(context.GetTextSpan(), functionName);
            }
        }
Exemple #21
0
        private ActivationObject[] GetAllFunctionScopes(GlobalScope globalScope)
        {
            // create a list to hold all the scopes
            List <ActivationObject> scopes = new List <ActivationObject>();

            // recursively add all the function scopes to the list
            AddScopes(scopes, globalScope);

            // sort the scopes by starting line (from the context)
            scopes.Sort(ScopeComparer.Instance);

            // return as an array
            return(scopes.ToArray());
        }
Exemple #22
0
        public void CreateReport(TextWriter writer, GlobalScope globalScope, bool useReferenceCounts)
        {
            if (globalScope != null)
            {
                m_useReferenceCounts = useReferenceCounts;

                // start the global scope
                m_writer = XmlWriter.Create(writer, new XmlWriterSettings()
                {
                    Indent = true, OmitXmlDeclaration = true
                });
                m_writer.WriteStartElement("global");

                // recursively process each child scope
                foreach (var childScope in globalScope.ChildScopes)
                {
                    ProcessScope(childScope);
                }

                // process any undefined references
                if (globalScope.UndefinedReferences != null && globalScope.UndefinedReferences.Count > 0)
                {
                    m_writer.WriteStartElement("undefined");

                    foreach (var undefined in globalScope.UndefinedReferences)
                    {
                        m_writer.WriteStartElement("reference");
                        m_writer.WriteAttributeString("name", undefined.Name);
                        m_writer.WriteAttributeString("type", undefined.ReferenceType.ToString().ToLowerInvariant());
                        if (undefined.LookupNode != null && undefined.LookupNode.Context != null)
                        {
                            OutputContextPosition(undefined.LookupNode.Context);
                        }
                        else
                        {
                            m_writer.WriteAttributeString("srcLine", undefined.Line.ToStringInvariant());
                            m_writer.WriteAttributeString("srcCol", (undefined.Column + 1).ToStringInvariant());
                        }

                        m_writer.WriteEndElement();
                    }

                    m_writer.WriteEndElement();
                }

                m_writer.WriteEndElement();
                m_writer.Flush();
                m_writer = null;
            }
        }
Exemple #23
0
        private void CloseSession()
        {
            if (GlobalScope != null && MainApplicationContext != null)
            {
                using (MainApplicationContext.AcquireCurrentThread())
                {
                    GlobalScope.QuickClose();
                    GlobalScope.Dispose();
                    GlobalScope = null;

                    Logger.Current.Info(() => LedgerSessionEnded);
                }
            }
        }
        public void Should_return_entire_bound_scope_name_as_path_to_root_scope()
        {
            var fakeNode  = A.Fake <INode <AstNode> >();
            var fakeScope = A.Fake <INamedScope <SymbolNode> >();

            A.CallTo(() => fakeScope.Name).Returns("FakeScope");

            var globalScope = new GlobalScope <SymbolNode>();

            A.CallTo(() => fakeScope.OuterScope).Returns(globalScope);

            var boundScope = new BoundScope <SymbolNode>(fakeScope, fakeNode);

            boundScope.Name.ShouldBe("global/FakeScope");
        }
Exemple #25
0
        /// <summary>
        /// Resolves the given element in this scope.
        /// </summary>
        /// <param name="elem">The element.</param>
        /// <param name="isFirst">Is the element the first one in the list.</param>
        /// <returns>Resolved value or null</returns>
        public object ResolveInScopes(object elem, bool isFirst)
        {
            object result;

            // try to access the cached function value (speed optimization)
            LispVariant elemAsVariant = elem as LispVariant;

            if (elemAsVariant != null && elemAsVariant.CachedFunction != null)
            {
                return(elemAsVariant.CachedFunction);
            }

            var       name = elem.ToString();
            LispScope foundClosureScope;

            // first try to resolve in this scope
            if (TryGetValue(name, out result))
            {
                UpdateFunctionCache(elemAsVariant, result, isFirst);
            }
            // then try to resolve in global scope
            else if (GlobalScope != null &&
                     GlobalScope.TryGetValue(name, out result))
            {
                UpdateFunctionCache(elemAsVariant, result, isFirst);
            }
            // then try to resolve in closure chain scope(s)
            else if (IsInClosureChain(name, out foundClosureScope, out result))
            {
                UpdateFunctionCache(elemAsVariant, result, isFirst);
            }
            // then try to resolve in scope of loaded modules
            else if (LispEnvironment.IsInModules(name, GlobalScope))
            {
                result = LispEnvironment.GetFunctionInModules(name, GlobalScope);
            }
            else
            {
                // activate this code if symbols must be resolved in parameter evaluation --> (println blub)
                //if (elemAsVariant != null && elemAsVariant.IsSymbol && name != "fuellib")
                //{
                //    throw new LispException($"Could not resolve symbol {name}");
                //}
                result = elem;
            }

            return(result);
        }
Exemple #26
0
        public void GlobalScope_ReportError_WritesErrorIfNoCancellationReques()
        {
            var globalScope = new GlobalScope();
            var ex          = new Exception("some exception");

            using (var textWriter = new StringWriter())
            {
                MainApplicationContext.Current.SetApplicationServiceProvider(new ApplicationServiceProvider
                                                                                 (virtualConsoleProviderFactory: () => new VirtualConsoleProvider(consoleError: textWriter)));

                globalScope.ReportError(ex);

                textWriter.Flush();
                Assert.Equal("Error: some exception", textWriter.ToString().TrimEnd());
            }
        }
Exemple #27
0
        public void GlobalScope_HandleDebugOptions_Configures_ArgsOnly_VerifyMemory_InitFile()
        {
            List <string> args = new List <string>();

            args.Add("--args-only");
            args.Add("--verify-memory");
            args.Add("--init-file");
            args.Add("filename.ext");

            GlobalScope.HandleDebugOptions(args);

            Assert.True(GlobalScope.ArgsOnly);
            Assert.True(Validator.IsVerifyEnabled);
            Assert.Equal(LogLevelEnum.LOG_DEBUG, Logger.Current.LogLevel);
            Assert.Equal("memory\\.counts", Logger.Current.LogCategory);
        }
Exemple #28
0
        public ExpressionEval(IServiceContainer services, IPythonModule module, PythonAst ast)
        {
            Services = services ?? throw new ArgumentNullException(nameof(services));
            Module   = module ?? throw new ArgumentNullException(nameof(module));
            Ast      = ast ?? throw new ArgumentNullException(nameof(ast));

            GlobalScope          = new GlobalScope(module);
            CurrentScope         = GlobalScope;
            DefaultLookupOptions = LookupOptions.Normal;

            //Log = services.GetService<ILogger>();
            _diagnostics = services.GetService <IDiagnosticsService>();

            UnknownType = Interpreter.UnknownType ??
                          new FallbackBuiltinPythonType(new FallbackBuiltinsModule(Ast.LanguageVersion), BuiltinTypeId.Unknown);
        }
        public MemberResult[] GetModuleMembers(string[] names, bool includeMembers = false)
        {
            var res      = new List <MemberResult>(ProjectState.GetModuleMembers(names, includeMembers));
            var children = GlobalScope.GetChildrenPackages();

            foreach (var child in children)
            {
                var mod       = (ModuleInfo)child.Value;
                var childName = mod.Name.Substring(this.GlobalScope.Name.Length + 1);

                if (childName.StartsWith(names[0]))
                {
                    res.AddRange(JsAnalyzer.GetModuleMembers(names, includeMembers, mod as IModule));
                }
            }

            return(res.ToArray());
        }
Exemple #30
0
        public void DoesNotTModifyVariableInUpperFromDerivedScope()
        {
            var sut = new GlobalScope(null, "root");

            sut.SetVariable("a", new String("bottom"), false);

            var derived = sut.DeriveFunctionScope();

            derived.SetVariable("a", new String("derived"), true);
            var innerAa = derived.GetVariable("a", new Runtime(new Processors())).Get(new Runtime(new Processors())) as String;

            Assert.Equal("derived", innerAa.Value);


            var a = sut.GetVariable("a", new Runtime(new Processors())).Get(new Runtime(new Processors())) as String;

            Assert.Equal("bottom", a.Value);
        }
Exemple #31
0
        public void HasATypeInWhichOnlyGenericTypeVariablesAreFreshenedOnEachScopeLookup()
        {
            using (TypeVariable.TestFactory())
            {
                //Prevent type '1' from being freshened on type lookup by marking it as non-generic:
                var typeVariable0 = TypeVariable.CreateGeneric();
                var typeVariable1 = TypeVariable.CreateNonGeneric();

                var expectedTypeAfterLookup = new NamedType("A", new TypeVariable(4), typeVariable1, new NamedType("B", new TypeVariable(4), typeVariable1));
                var definedType = new NamedType("A", typeVariable0, typeVariable1, new NamedType("B", typeVariable0, typeVariable1));

                var typeChecker = new TypeChecker();
                var globalScope = new GlobalScope();
                var localScope = new LocalScope(globalScope);
                localScope.Bind("foo", definedType);

                Type("foo", localScope, typeChecker).ShouldEqual(expectedTypeAfterLookup);
            }
        }
Exemple #32
0
        /// <summary>Parses the chunk to an function.</summary>
        /// <param name="runtime">Binder</param>
        /// <param name="options">Compile options for the script.</param>
        /// <param name="lHasEnvironment">Creates the _G parameter.</param>
        /// <param name="code">Lexer for the code.</param>
        /// <param name="typeDelegate">Type for the delegate. <c>null</c>, for an automatic type</param>
        /// <param name="returnType">Defines the return type of the chunk.</param>
        /// <param name="args">Arguments of the function.</param>
        /// <returns>Expression-Tree for the code.</returns>
        public static LambdaExpression ParseChunk(Lua runtime, LuaCompileOptions options, bool lHasEnvironment, LuaLexer code, Type typeDelegate, Type returnType, IEnumerable<KeyValuePair<string, Type>> args)
        {
            List<ParameterExpression> parameters = new List<ParameterExpression>();
            if (returnType == null)
                returnType = typeof(LuaResult);
            var globalScope = new GlobalScope(runtime, options, returnType, returnType == typeof(LuaResult) ? Expression.Property(null, Lua.ResultEmptyPropertyInfo) : null);

            // Registers the global LuaTable
            if (lHasEnvironment)
                parameters.Add(globalScope.RegisterParameter(typeof(LuaTable), csEnv));

            if (args != null)
            {
                foreach (var c in args)
                    parameters.Add(globalScope.RegisterParameter(c.Value, c.Key)); // Add alle arguments
            }

            // Get the first token
            if (code.Current == null)
                code.Next();

            // Get the name for the chunk and clean it from all unwanted chars
            string sChunkName = CreateNameFromFile(code.Current.Start.FileName);
              if ((globalScope.EmitDebug & LuaDebugLevel.RegisterMethods) == LuaDebugLevel.RegisterMethods)
                sChunkName = Lua.RegisterUniqueName(sChunkName);

            // Create the block
            ParseBlock(globalScope, code);

            if (code.Current.Typ != LuaToken.Eof)
                throw ParseError(code.Current, Properties.Resources.rsParseEof);

            // Create the function
            return typeDelegate == null ?
                Expression.Lambda(globalScope.ExpressionBlock, sChunkName, parameters) :
                Expression.Lambda(typeDelegate, globalScope.ExpressionBlock, sChunkName, parameters);
        }
        public static Task<IFunctionalNamespace> ParseCompilationUnitAsync(IProjectSourceItem SourceItem, CompilationParameters Parameters, IBinder Binder, IAssembly DeclaringAssembly, MacroProcessor Processor, IMessageSink Sink)
        {
            Parameters.Log.LogEvent(new LogEntry("Status", "Parsing " + SourceItem.SourceIdentifier));
            return Task.Run(() =>
            {
                var code = ProjectHandlerHelpers.GetSourceSafe(SourceItem, Parameters);
                if (code == null)
                {
                    return null;
                }
                var namer = ECSharpTypeNamer.Instance;
                var convRules = DefaultConversionRules.Create(namer.Convert);
                var globalScope = new GlobalScope(new FunctionalBinder(Binder), convRules, Parameters.Log, namer, new Flame.Syntax.MemberProvider(Binder).GetMembers, GetParameters);
                bool isLes = Enumerable.Last(SourceItem.SourceIdentifier.Split('.')).Equals("les", StringComparison.OrdinalIgnoreCase);
                var service = isLes ? (IParsingService)LesLanguageService.Value : EcsLanguageService.Value;
                var nodes = ParseNodes(code.Source, SourceItem.SourceIdentifier, service, Processor, Sink);

                if (Parameters.Log.Options.GetOption<bool>("E", false))
                {
                    var outputService = GetParsingService(Parameters.Log.Options, "syntax-format", service);
                    string newFile = outputService.Print(nodes, Sink, indentString: new string(' ', 4));
                    Parameters.Log.LogMessage(new LogEntry("'" + SourceItem.SourceIdentifier + "' after macro expansion", Environment.NewLine + newFile));
                }

                var unit = ParseCompilationUnit(nodes, globalScope, DeclaringAssembly);
                Parameters.Log.LogEvent(new LogEntry("Status", "Parsed " + SourceItem.SourceIdentifier));
                return unit;
            });
        }
 public static IFunctionalNamespace ParseCompilationUnit(IEnumerable<LNode> Nodes, GlobalScope Scope, IAssembly DeclaringAssembly)
 {
     return converter.ConvertCompilationUnit(Scope, DeclaringAssembly, Nodes);
 }
Exemple #35
0
 protected void InitTypeSystem()
     {
     builtins = new BuiltInScope(this);
     globals  = new GlobalScope(this, builtins);
     //
     // Create the builtin types
     // 
     this.builtins.Define(modelType   = new ModelTypeSymbol());
     this.builtins.Define(strandType  = new StrandTypeSymbol());
     this.builtins.Define(plexType    = new PlexTypeSymbol());
     this.builtins.Define(mixtureType = new MixtureTypeSymbol());
     this.builtins.Define(integerType = new IntegerTypeSymbol());
     this.builtins.Define(floatType   = new FloatTypeSymbol());
     this.builtins.Define(stringType  = new StringTypeSymbol());
     this.builtins.Define(voidType    = new VoidTypeSymbol());
     this.builtins.Define(boolType    = new BoolTypeSymbol());
     this.builtins.Define(objectType  = new ObjectTypeSymbol());
     this.builtins.Define(listOfDomainsType = new ListTypeSymbol(this));
     this.builtins.Define(listOfStrandsType = new ListTypeSymbol(this));
     this.builtins.Define(meltType = new CSharpClassTypeSymbol(typeof(Nadir.User.IMelt)));
     this.builtins.Define(seqDesign = new CSharpClassTypeSymbol(typeof(Nadir.User.ISeqdesign)));
     //
     // Create the builtin properties
     //
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropLengthName,             integerType, fDom: true,  fStr: true,  inheritedByStrand: false, inheritedByComplement: false, inheritedBySubset: false, builtinSequenceProperty: true));
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropPatternName,            stringType,        true,        true,                     false,                        false,                    false,                          true));
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropUndecoratedPatternName, stringType,        true,        true,                     false,                        false,                    false,                          true));
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropDesignSeedName,         stringType,        true,        true,                     false,                        false,                    false,                          true));
     //
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropMeltName,               meltType,          false,       true,                     false,                        false,                    false,                          false));
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropDeltaGName,             floatType,         true,        true,                     false,                        false,                    false,                          false));
     //
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropDistributionName,       stringType,        true,        false,                    false,                        false,                    false,                          false));
     //
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropImportanceName,         floatType,         false,       true,                     false,                        true,                     false,                          false));
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropToeholdName,            boolType,          true,        false,                    false,                        true,                     true,                           false));
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropCountName,              integerType,       false,       false,                    false,                        false,                    false,                          false));
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropNameName,               stringType,        true,        true,                     false,                        false,                    false,                          false));
     //
     this.builtins.Define(domainType = new DomainTypeSymbol(this)); // must be after string, bool, and integer, and the properties (though i can't rememer why)
     //
     ((ListTypeSymbol)this.listOfDomainsType).SetElementType(domainType);
     ((ListTypeSymbol)this.listOfStrandsType).SetElementType(strandType);
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropDomainsName,            listOfDomainsType, false, false, false, false, false, false));
     this.builtins.Define(CreatePropertyDefinition(BuiltIns.PropStrandsName,            listOfStrandsType, false, false, false, false, false, false));
     //
     // Create the definitions of the builtin functions
     // 
     foreach (BuiltIns.FuncShape fn in BuiltIns.Shapes)
         {
         this.builtins.Define(CreateFunctionDef(fn));
         }
     //
     // Create the 'toehold' and 'specificity' typedefs
     //
     this.builtins.Define(CreateTypedef(Constants.ToeholdDomainName,     new DomainTypeSymbol(this, Constants.ToeholdDomainDefaultLength,     true)));
     this.builtins.Define(CreateTypedef(Constants.SpecificityDomainName, new DomainTypeSymbol(this, Constants.SpecificityDomainDefaultLength, false)));
     //
     // Create builtin variables
     //
     this.builtins.Define(CreateInitializedFloatVariable(BuiltIns.VarInfinityName,                        true,  BuiltIns.VarInfinityValue));
     this.builtins.Define(CreateInitializedFloatVariable(BuiltIns.VarNanName,                             true,  BuiltIns.VarNanValue));
     this.builtins.Define(CreateInitializedIntVariable  (BuiltIns.VarHybridizationStabilityThresholdName, false, BuiltIns.VarHybridizationStabilityThresholdValue));
     this.builtins.Define(CreateSeqdesignVariable       (BuiltIns.VarSeqdesignName,                       true,  this.Context));
     //
     // Create the type analysis tables
     //
     this.promotionTable                 = CreatePromotionTable();
     this.arithmeticResultTable          = CreateArithmeticResultTable();
     this.equalityRequiredArgTypeTable   = CreateEqualityRequiredArgTypeTable();
     }
	// Constructors
	public GlobalScope(GlobalScope parent, Microsoft.JScript.Vsa.VsaEngine engine) {}
Exemple #37
0
        private GlobalScope CreateGlobalScope(Vector<Class> classes, Vector<Function> functions)
        {
            var globals = new GlobalScope();

            foreach (var @class in classes)
                if (!globals.TryIncludeUniqueBinding(@class.Name.Identifier, ConstructorType(@class.Name)))
                    LogError(CompilerError.DuplicateIdentifier(@class.Position, @class));

            foreach (var function in functions)
                if (!globals.TryIncludeUniqueBinding(function.Name.Identifier, typeRegistry.DeclaredType(function)))
                    LogError(CompilerError.DuplicateIdentifier(function.Position, function));

            return globals;
        }