当前位置: 首页>>代码示例>>C#>>正文


C# CompilerContext类代码示例

本文整理汇总了C#中CompilerContext的典型用法代码示例。如果您正苦于以下问题:C# CompilerContext类的具体用法?C# CompilerContext怎么用?C# CompilerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompilerContext类属于命名空间,在下文中一共展示了CompilerContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetContent

 public void GetContent(CompilerContext context, ParseTreeNode parseNode)
 {
     if (parseNode.HasChildNodes())
     {
         ParallelTasks = Convert.ToUInt32(parseNode.ChildNodes[1].Token.Value);
     }
 }
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:ParallelTasksNode.cs

示例2: BeginFiltering

 public override IEnumerable<Token> BeginFiltering(CompilerContext context, IEnumerable<Token> tokens)
 {
     foreach (Token token in tokens) {
     if (!token.Terminal.IsSet(TermOptions.IsBrace)) {
       yield return token;
       continue;
     }
     //open brace symbol
     if (token.Terminal.IsSet(TermOptions.IsOpenBrace)) {
       _braces.Push(token);
       yield return token;
       continue;
     }
     //We have closing brace
     if (_braces.Count == 0) {
       yield return context.CreateErrorTokenAndReportError( token.Location, token.Text, "Unmatched closing brace '{0}'", token.Text);
       continue;
     }
     //check match
     Token last = _braces.Pop();
     if (last.AsSymbol.IsPairFor != token.AsSymbol) {
       yield return context.CreateErrorTokenAndReportError(token.Location, token.Text,
       "Unmatched closing brace '{0}' - expected '{1}'", last.AsSymbol.IsPairFor.Name);
       continue;
     }
     //everything is ok, there's matching brace on top of the stack
     Token.LinkMatchingBraces(last, token);
     context.CurrentParseTree.OpenBraces.Add(last);
     yield return token; //return this token
       }//foreach token
       yield break;
 }
开发者ID:TheByte,项目名称:sones,代码行数:32,代码来源:BraceMatchFilter.cs

示例3: Execute

        public ScriptResult Execute(string code, string[] scriptArgs, AssemblyReferences references, IEnumerable<string> namespaces,
            ScriptPackSession scriptPackSession)
        {
            Guard.AgainstNullArgument("references", references);
            Guard.AgainstNullArgument("scriptPackSession", scriptPackSession);

            references.PathReferences.UnionWith(scriptPackSession.References);

            SessionState<Evaluator> sessionState;
            if (!scriptPackSession.State.ContainsKey(SessionKey))
            {
                Logger.Debug("Creating session");
                var context = new CompilerContext(new CompilerSettings
                {
                    AssemblyReferences = references.PathReferences.ToList()
                }, new ConsoleReportPrinter());

                var evaluator = new Evaluator(context);
                var allNamespaces = namespaces.Union(scriptPackSession.Namespaces).Distinct();

                var host = _scriptHostFactory.CreateScriptHost(new ScriptPackManager(scriptPackSession.Contexts), scriptArgs);
                MonoHost.SetHost((ScriptHost)host);

                evaluator.ReferenceAssembly(typeof(MonoHost).Assembly);
                evaluator.InteractiveBaseClass = typeof(MonoHost);

                sessionState = new SessionState<Evaluator>
                {
                    References = new AssemblyReferences(references.PathReferences, references.Assemblies),
                    Namespaces = new HashSet<string>(),
                    Session = evaluator
                };

                ImportNamespaces(allNamespaces, sessionState);

                scriptPackSession.State[SessionKey] = sessionState;
            }
            else
            {
                Logger.Debug("Reusing existing session");
                sessionState = (SessionState<Evaluator>)scriptPackSession.State[SessionKey];

                var newReferences = sessionState.References == null ? references : references.Except(sessionState.References);
                foreach (var reference in newReferences.PathReferences)
                {
                    Logger.DebugFormat("Adding reference to {0}", reference);
                    sessionState.Session.LoadAssembly(reference);
                }

                sessionState.References = new AssemblyReferences(references.PathReferences, references.Assemblies);

                var newNamespaces = sessionState.Namespaces == null ? namespaces : namespaces.Except(sessionState.Namespaces);
                ImportNamespaces(newNamespaces, sessionState);
            }

            Logger.Debug("Starting execution");
            var result = Execute(code, sessionState.Session);
            Logger.Debug("Finished execution");
            return result;
        }
开发者ID:selony,项目名称:scriptcs,代码行数:60,代码来源:MonoScriptEngine.cs

示例4: GetContent

        public override void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            #region Get the optional type list

            if (parseNode.ChildNodes[1].HasChildNodes())
            {
                _TypesToDump = ((parseNode.ChildNodes[1].ChildNodes[1].AstNode as TypeListNode).Types).Select(tlnode => tlnode.TypeName).ToList();
            }

            #endregion

            _DumpType           = (parseNode.ChildNodes[2].AstNode as DumpTypeNode).DumpType;
            _DumpFormat         = (parseNode.ChildNodes[3].AstNode as DumpFormatNode).DumpFormat;
            _DumpableGrammar    = context.Compiler.Language.Grammar as IDumpable;

            if (_DumpableGrammar == null)
            {
                throw new GraphDBException(new Error_NotADumpableGrammar(context.Compiler.Language.Grammar.GetType().ToString()));
            }

            if (parseNode.ChildNodes[4].HasChildNodes())
            {
                _DumpDestination = parseNode.ChildNodes[4].ChildNodes[1].Token.ValueString;
            }
        }
开发者ID:TheByte,项目名称:sones,代码行数:25,代码来源:DumpNode.cs

示例5: GetContent

        public override void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            if (parseNode.HasChildNodes())
            {

                //get type
                if (parseNode.ChildNodes[1] != null && parseNode.ChildNodes[1].AstNode != null)
                {
                    _Type = ((ATypeNode)(parseNode.ChildNodes[1].AstNode)).ReferenceAndType.TypeName;
                }
                else
                {
                    throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                }

                if (parseNode.ChildNodes[3] != null && parseNode.ChildNodes[3].HasChildNodes())
                {

                    _AttributeAssignList = new List<AAttributeAssignOrUpdate>((parseNode.ChildNodes[3].AstNode as AttrUpdateOrAssignListNode).ListOfUpdate.Select(e => e as AAttributeAssignOrUpdate));

                }

                if (parseNode.ChildNodes[4] != null && ((WhereExpressionNode)parseNode.ChildNodes[4].AstNode).BinaryExpressionDefinition != null)
                {
                    _WhereExpression = ((WhereExpressionNode)parseNode.ChildNodes[4].AstNode).BinaryExpressionDefinition;
                }

            }
        }
开发者ID:Vadi,项目名称:sones,代码行数:29,代码来源:InsertOrUpdateNode.cs

示例6: GetContent

 /// <summary>
 /// This handles the Where Expression Node with all the
 /// </summary>
 /// <param name="context"></param>
 /// <param name="parseNode"></param>
 /// <param name="typeManager"></param>
 public void GetContent(CompilerContext context, ParseTreeNode parseNode)
 {
     if (parseNode.HasChildNodes())
     {
         BinExprNode = (BinaryExpressionNode)parseNode.ChildNodes[1].AstNode;
     }
 }
开发者ID:TheByte,项目名称:sones,代码行数:13,代码来源:HavingExpressionNode.cs

示例7: GetContent

        public void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            var content = parseNode.FirstChild.AstNode as RemoveFromListAttrUpdateNode;

            AttributeRemoveList = content.AttributeRemoveList;
            base.ParsingResult.PushIExceptional(content.ParsingResult);
        }
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:RemoveFromListAttrUpdateNode.cs

示例8: RuntimeScriptCode

 public RuntimeScriptCode(CompilerContext/*!*/ context, MSAst.Expression<Func<object>>/*!*/ expression, PythonAst/*!*/ ast, CodeContext/*!*/ codeContext)
     : base(context.SourceUnit) {
     _code = expression;
     _ast = ast;
     _context = context;
     _optimizedContext = codeContext;
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:7,代码来源:RuntimeScriptCode.cs

示例9: TotemAst

        public TotemAst(bool isModule, ModuleOptions languageFeatures, bool printExpressions, CompilerContext context)
        {
            _isModule = isModule;
            _printExpressions = printExpressions;
            _languageFeatures = languageFeatures;
            _mode = ((TotemCompilerOptions)context.Options).CompilationMode ?? GetCompilationMode(context);
            _compilerContext = context;
            FuncCodeExpr = _functionCode;

            TotemCompilerOptions tco = context.Options as TotemCompilerOptions;
            Debug.Assert(tco != null);

            string name;
            if (!context.SourceUnit.HasPath || (tco.Module & ModuleOptions.ExecOrEvalCode) != 0)
            {
                name = "<module>";
            }
            else
            {
                name = context.SourceUnit.Path;
            }

            _name = name;
            Debug.Assert(_name != null);
            TotemOptions to = ((TotemContext)context.SourceUnit.LanguageContext).TotemOptions;

            _document = context.SourceUnit.Document ?? Expression.SymbolDocument(name, TotemContext.LanguageGuid, TotemContext.VendorGuid);
        }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:28,代码来源:TotemAst.cs

示例10: GetRequiredFiles

        public static IEnumerable<RequiredFile> GetRequiredFiles(CompilerContext context, string script)
        {
            var matches = Regex.Matches(script, RequireMatchPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase);
            var result = new List<RequiredFile>();
            foreach (Match match in matches)
            {
                var location = match.Groups["requiredFile"].Value.Trim();
                var protocolString = match.Groups["protocol"].Value ?? string.Empty;
                var isEmbedded = location.EndsWith("`") && location.StartsWith("`");
                location = isEmbedded ? location.Substring(1, location.Length - 2) : location;

                var file = new RequiredFile
                {
                    IsEmbedded = isEmbedded,
                    Location = location,
                    Protocol = FileProtocol.LocalFile,
                    RegexMatch = match,
                    Context = context
                };

                if (!string.IsNullOrEmpty(protocolString)) {
                    FileProtocol protocol;
                    Enum.TryParse<FileProtocol>(protocolString.Replace("://", string.Empty), true, out protocol);
                    file.Protocol = protocol;
                }

                if (file.Protocol == FileProtocol.LocalFile)
                    if (!new FileInfo(file.Location).Exists)
                        file.Location = Path.Combine(context.WorkingDirectory, file.Location);

                result.Add(file);
            }
            return result;
        }
开发者ID:creamdog,项目名称:JurassicCoffee,代码行数:34,代码来源:RequiredCoffeeFiles.cs

示例11: BindAst

        internal static void BindAst(TotemAst ast, CompilerContext context)
        {
            Assert.NotNull(ast, context);

            TotemNameBinder binder = new TotemNameBinder(context);
            binder.Bind(ast);
        }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:7,代码来源:TotemNameBinder.cs

示例12: Initialize

		public virtual void Initialize(CompilerContext context)
		{
			_context = context;
			_codeBuilder = new EnvironmentProvision<BooCodeBuilder>();
			_typeSystemServices = new EnvironmentProvision<TypeSystemServices>();
			_nameResolutionService = new EnvironmentProvision<NameResolutionService>();
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:AbstractFastVisitorCompilerStep.cs

示例13: GetContent

 public void GetContent(CompilerContext context, ParseTreeNode parseNode)
 {
     var idChain = ((IDNode)parseNode.ChildNodes[0].AstNode).IDChainDefinition;
     var AttrName = parseNode.ChildNodes[0].FirstChild.FirstChild.Token.ValueString;
     var tupleDefinition = ((TupleNode)parseNode.ChildNodes[2].AstNode).TupleDefinition;
     AttributeRemoveList = new Managers.Structures.AttributeRemoveList(idChain, AttrName, tupleDefinition);
 }
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:RemoveFromListAttrUpdateAddToOperatorNode.cs

示例14: GetContent

        public void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            _Settings = new Dictionary<String, String>();

            foreach (var _ParseTreeNode1 in parseNode.ChildNodes)
            {

                if (_ParseTreeNode1.HasChildNodes())
                {

                    switch (_ParseTreeNode1.ChildNodes[0].Token.Text.ToUpper())
                    {
                        case "GET":
                            _OperationType = TypesOfSettingOperation.GET;
                            break;
                        case "SET":
                            _OperationType = TypesOfSettingOperation.SET;
                            break;
                        case "REMOVE":
                            _OperationType = TypesOfSettingOperation.REMOVE;
                            break;
                    }

                    foreach (var _ParseTreeNode2 in _ParseTreeNode1.ChildNodes[1].ChildNodes)
                    {

                        if (_ParseTreeNode2 != null)
                        {
                            if (_ParseTreeNode2.HasChildNodes())
                            {
                                if (_ParseTreeNode2.ChildNodes[0] != null)
                                {
                                    if (_ParseTreeNode2.ChildNodes[2] != null)
                                    {
                                        if (_ParseTreeNode2.ChildNodes[0].Token != null && _ParseTreeNode2.ChildNodes[2].Token != null)
                                        {
                                            var Temp = _ParseTreeNode2.ChildNodes[2].Token.Text.ToUpper();

                                            if (Temp.Contains("DEFAULT"))
                                                _Settings.Add(_ParseTreeNode2.ChildNodes[0].Token.ValueString.ToUpper(), Temp);
                                            else
                                                _Settings.Add(_ParseTreeNode2.ChildNodes[0].Token.ValueString.ToUpper(), _ParseTreeNode2.ChildNodes[2].Token.ValueString.ToUpper());
                                        }
                                    }
                                }
                            }

                            else
                            {
                                if (_ParseTreeNode2.Token != null)
                                    _Settings.Add(_ParseTreeNode2.Token.ValueString, "");
                            }
                        }

                    }

                }

            }
        }
开发者ID:TheByte,项目名称:sones,代码行数:60,代码来源:SettingOperationNode.cs

示例15: CreateParserWorker

        private static Parser CreateParserWorker(CompilerContext context, PythonOptions options, bool verbatim) {
            ContractUtils.RequiresNotNull(context, "context");
            ContractUtils.RequiresNotNull(options, "options");

            PythonCompilerOptions compilerOptions = context.Options as PythonCompilerOptions;
            if (options == null) {
                throw new ArgumentException(Resources.PythonContextRequired);
            }

            SourceCodeReader reader;

            try {
                reader = context.SourceUnit.GetReader();

                if (compilerOptions.SkipFirstLine) {
                    reader.ReadLine();
                }
            } catch (IOException e) {
                context.Errors.Add(context.SourceUnit, e.Message, SourceSpan.Invalid, 0, Severity.Error);
                throw;
            }

            Tokenizer tokenizer = new Tokenizer(context.Errors, compilerOptions, verbatim);
            tokenizer.Initialize(null, reader, context.SourceUnit, SourceLocation.MinValue);
            tokenizer.IndentationInconsistencySeverity = options.IndentationInconsistencySeverity;

            Parser result = new Parser(tokenizer, context.Errors, context.ParserSink, compilerOptions.LanguageFeatures);
            result._sourceReader = reader;
            return result;
        }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:30,代码来源:Parser.cs


注:本文中的CompilerContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。