• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CompilerContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: MakeScriptCode

        public override ScriptCode/*!*/ MakeScriptCode(MSAst.Expression/*!*/ body, CompilerContext/*!*/ context, PythonAst/*!*/ ast) {            
            MSAst.Expression finalBody = Ast.Block(
                new[] { _globalCtx },
                Ast.Assign(
                    _globalCtx,
                    Ast.Call(typeof(PythonOps).GetMethod("CreateTopLevelCodeContext"),
                        _globalScope,
                        _language
                    )
                ),
                body
            );

            PythonCompilerOptions pco = ((PythonCompilerOptions)context.Options);
            string name = pco.ModuleName ?? "<unnamed>";
            var lambda = Ast.Lambda<Func<Scope, LanguageContext, object>>(
                finalBody, 
                name,
                new[] { _globalScope, _language } 
            );


            Func<Scope, LanguageContext, object> func;
            // TODO: adaptive compilation should be eanbled
            /*PythonContext pc = (PythonContext)context.SourceUnit.LanguageContext;
            if (pc.ShouldInterpret(pco, context.SourceUnit)) {
                func = CompilerHelpers.LightCompile(lambda);
            } else*/ {
                func = lambda.Compile(context.SourceUnit.EmitDebugSymbols);
            }

            return new PythonScriptCode(func, context.SourceUnit);
        }
开发者ID:toddb,项目名称:ironruby,代码行数:33,代码来源:DictionaryGlobalAllocator.cs


示例17: MakeScriptCode

        public override ScriptCode/*!*/ MakeScriptCode(MSAst.Expression/*!*/ body, CompilerContext/*!*/ context, PythonAst/*!*/ ast) {
            MSAst.ParameterExpression scope = Ast.Parameter(typeof(Scope), "$scope");
            MSAst.ParameterExpression language = Ast.Parameter(typeof(LanguageContext), "$language ");

            // finally build the funcion that's closed over the array and
            var func = Ast.Lambda<Func<Scope, LanguageContext, object>>(
                Ast.Block(
                    new[] { GlobalArray },
                    Ast.Assign(
                        GlobalArray, 
                        Ast.Call(
                            null,
                            typeof(PythonOps).GetMethod("GetGlobalArray"),
                            scope
                        )
                    ),
                    Utils.Convert(body, typeof(object))
                ),
                ((PythonCompilerOptions)context.Options).ModuleName,
                new MSAst.ParameterExpression[] { scope, language }
            );

            PythonCompilerOptions pco = context.Options as PythonCompilerOptions;

            return new SavableScriptCode(func, context.SourceUnit, GetNames(), pco.ModuleName);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:26,代码来源:SavableGlobalAllocator.cs


示例18: GetContent

        /// <summary>
        /// Gets the content of an UpdateStatement.
        /// </summary>
        /// <param name="context">CompilerContext of Irony.</param>
        /// <param name="parseNode">The current ParseNode.</param>
        /// <param name="typeManager">The TypeManager of the GraphDB.</param>
        public override void GetContent(CompilerContext myCompilerContext, ParseTreeNode myParseTreeNode)
        {
            #region get Type

            _TypeName = (myParseTreeNode.ChildNodes[1].AstNode as ATypeNode).ReferenceAndType.TypeName;

            #endregion

            #region get myAttributes

            if (myParseTreeNode.ChildNodes[3].HasChildNodes())
            {
                var AttrUpdateOrAssign = (AttrUpdateOrAssignListNode)myParseTreeNode.ChildNodes[3].AstNode;
                _listOfUpdates = AttrUpdateOrAssign.ListOfUpdate;
                base.ParsingResult.PushIExceptional(AttrUpdateOrAssign.ParsingResult);
            }

            #endregion

            #region whereClauseOpt

            if (myParseTreeNode.ChildNodes[4].HasChildNodes())
            {
                var tempWhereNode = (WhereExpressionNode) myParseTreeNode.ChildNodes[4].AstNode;
                _WhereExpression = tempWhereNode.BinaryExpressionDefinition;

            }

            #endregion
        }
开发者ID:TheByte,项目名称:sones,代码行数:36,代码来源:UpdateNode.cs


示例19: MakeScriptCode

        public override ScriptCode/*!*/ MakeScriptCode(MSAst.Expression/*!*/ body, CompilerContext/*!*/ context, PythonAst/*!*/ ast) {
            // create the CodeContext
            PythonGlobal[] globalArray = new PythonGlobal[_globals.Count];

            // now fill in the dictionary and create the array
            foreach (var global in _globals) {
                SymbolId globalName = SymbolTable.StringToId(global.Key);
                
                globalArray[global.Value.Index] = _globalVals[globalName];
            }
            
            _array.Array = globalArray;

            // finally build the funcion that's closed over the array and
            string name = ((PythonCompilerOptions)context.Options).ModuleName ?? "<unnamed>";
            var func = Ast.Lambda<Func<object>>(
                Ast.Block(
                    new[] { _globalArray, _globalContext },
                    Ast.Assign(_globalArray, Ast.Constant(globalArray)),
                    Ast.Assign(_globalContext, Ast.Constant(_context)),
                    body
                ),
                name,
                new MSAst.ParameterExpression[0]
            );

            return new RuntimeScriptCode(context, func, ast, _context);
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:28,代码来源:ArrayGlobalAllocator.cs


示例20: GetContent

        public void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            var aSelectNode = (SelectNode)parseNode.ChildNodes[0].AstNode;

            SelectDefinition = new Managers.Structures.SelectDefinition(aSelectNode.TypeList, aSelectNode.SelectedElements, aSelectNode.WhereExpressionDefinition,
                aSelectNode.GroupByIDs, aSelectNode.Having, aSelectNode.Limit, aSelectNode.Offset, aSelectNode.OrderByDefinition, aSelectNode.ResolutionDepth);
        }
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:PartialSelectStmtNode.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CompilerOptions类代码示例发布时间:2022-05-24
下一篇:
C# Compiler类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap