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

C# Ast.MacroStatement类代码示例

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

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



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

示例1: Expand

        /// <summary>
        /// Expands the specified macro.
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        public override Statement Expand(MacroStatement macro)
        {
            Property property = new Property(propertyName);
            property.LexicalInfo = macro.LexicalInfo;
            property.Getter = new Method();
            if(macro.Arguments.Count==1)
            {
                property.Getter.Body.Add(
                    new ReturnStatement(macro.Arguments[0])
                    );
            }
            else if(
                macro.Arguments.Count == 0 &&
                macro.Body != null &&
				macro.Body.IsEmpty == false)//use the macro block
            {
				property.Getter.Body = macro.Body;
            }
            else
            {
                CompilerErrorFactory.CustomError(macro.LexicalInfo,
                                                 macro.Name + " must have a single expression argument or a block");
                return null;
            }

            ClassDefinition clazz = (ClassDefinition) macro.GetAncestor(NodeType.ClassDefinition);
            clazz.Members.Add(property);

            return null;
        }
开发者ID:JackWangCUMT,项目名称:rhino-dsl,代码行数:35,代码来源:GeneratePropertyMacro.cs


示例2: PromoteExtensions

 protected static void PromoteExtensions(MacroStatement macro, MacroStatement parent)
 {
     ApplyExtensions(macro, delegate(Expression extension)
                 {
                     RegisterExtension(parent, extension);
                 });
 }
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:7,代码来源:AbstractBinsorMacro.cs


示例3: OnMacroStatement

 public override void OnMacroStatement(MacroStatement node)
 {
     using (enter()){
         defaultProcess(node);
         base.OnMacroStatement(node);    
     }
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:7,代码来源:BooxmlXmlCollector.cs


示例4: MacroCompilerIsTakenFromTheEnvironment

		public void MacroCompilerIsTakenFromTheEnvironment()
		{
			var compiler = new Mock<MacroCompiler>(MockBehavior.Strict);

			ActiveEnvironment.With(CompilerContextEnvironmentWith(compiler), ()=>
			{
				var module = CreateModule();
				var macroApplication = new MacroStatement(new LexicalInfo("file.boo", 1, 1), "foo");
				module.Globals.Add(macroApplication);

				var macroDefinition = CreateClassOn(module, "FooMacro");

				compiler.Setup(o => o.AlreadyCompiled(macroDefinition)).Returns(false);
				compiler.Setup(o => o.Compile(macroDefinition)).Returns((Type)null);

				var expander = My<MacroExpander>.Instance;
				Assert.IsFalse(expander.ExpandAll());

				var errors = CompilerErrors();
				Assert.AreEqual(1, errors.Count);
				Assert.AreEqual(CompilerErrorFactory.AstMacroMustBeExternal(macroApplication, (IType) macroDefinition.Entity).ToString(), errors[0].ToString());
			});

			compiler.VerifyAll();
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:25,代码来源:MacroExpanderTest.cs


示例5: UnescapeInitialAndClosingDoubleQuotes

 private static void UnescapeInitialAndClosingDoubleQuotes(MacroStatement macro){
     var value = macro.Arguments[0] as StringLiteralExpression;
     if (value == null){
         return;
     }
     value.Value = BrailPreProcessor.UnescapeInitialAndClosingDoubleQuotes(value.Value);
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:7,代码来源:OutputMacro.cs


示例6: ExpandImpl

        protected override Statement ExpandImpl(MacroStatement macro){
            if (macro.Arguments.Count == 0){
                Context.Errors.Add(new CompilerError(macro.LexicalInfo,
                                                     "sub macro requires at least one reference or string attribute for subview name"));
            }

            var call = new MethodInvocationExpression(AstUtil.CreateReferenceExpression("OutputSubView"));
            int i = 0;
            foreach (Expression argument in macro.Arguments){
                i++;
                Expression exp = argument;
                if (i == 1){
//action and contrller parameters
                    if (argument is ReferenceExpression && !(argument is MemberReferenceExpression)){
                        if (argument.ToCodeString().StartsWith("@") || argument.ToCodeString().Contains(".")){
                            exp = AstUtil.CreateReferenceExpression(argument.ToCodeString().Substring(1));
                        }
                        else{
                            exp = new StringLiteralExpression(argument.ToCodeString());
                        }
                    }
                }
                call.Arguments.Add(exp);
            }
            return new ExpressionStatement(call);
        }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:26,代码来源:SubMacro.cs


示例7: ExpandIncludeMacro

        void ExpandIncludeMacro(MacroStatement macro)
        {
            if (macro.Arguments.Count != 1)
                throw new ScriptParsingException("include requires a single literal string argument ('filename').");

            var include = macro.Arguments[0] as StringLiteralExpression;
            if (include == null)
                throw new ScriptParsingException("include argument should be a literal string ('filename').");

            var fullPath = Path.Combine(
                Path.GetDirectoryName(macro.LexicalInfo.FullPath),
                include.Value
                );

            var compiled = compiler.CompileInclude(fullPath).CompileUnit.Modules[0];

            var module = macro.GetAncestor<Module>();
            foreach (var import in compiled.Imports) {
                module.Imports.Add(import);
            }

            var type = macro.GetAncestor<TypeDefinition>();
            foreach (var member in compiled.Members) {
                type.Members.Add(member);
            }

            var parent = (Block) macro.ParentNode;
            var currentPosition = parent.Statements.IndexOf(macro);

            RemoveCurrentNode();
            foreach (var global in compiled.Globals.Statements.Reverse()) {
                parent.Insert(currentPosition, global);
            }
        }
开发者ID:JeremySkinner,项目名称:Phantom,代码行数:34,代码来源:IncludeSupportStep.cs


示例8: ExpandImpl

            protected override Statement ExpandImpl(MacroStatement macro){
                string tagname = macro.Arguments[0].ToCodeString();

                
                bool useend = macro.Arguments.Contains(x=>x.ToCodeString()=="___end");
                bool usestart = macro.Arguments.Contains(x => x.ToCodeString() == "___start");
                bool wastagmodifiers = useend||usestart;
        
                if(!wastagmodifiers){
                    useend = true;
                    usestart = true;
                }

                IEnumerable<Expression> argsource = macro.Arguments.Skip(1).Where(x=>!(x.ToCodeString().StartsWith("___")));
                StatementCollection statements = macro.Body.Statements;
                
                
                Statement result = tryResolveTemplate(macro, tagname, argsource);
                if (null == result){

                    result = expandBmlElement(tagname, argsource, statements, usestart,useend);
                }
                return result;
            
            }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:25,代码来源:BmlElementMacro.cs


示例9: DoExpand

        /// <summary>
        /// Perform the actual expansion of the macro
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        protected override Statement DoExpand(MacroStatement macro)
        {
            if (macro.Arguments.Count != 0)
            {
                Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo,"No arguments allowed for action statement"));
                return null;
            }

            Method mergeRowsMethod = new Method("MergeRows");
            mergeRowsMethod.Modifiers = TypeMemberModifiers.Override;
            mergeRowsMethod.Parameters.Add(new ParameterDeclaration("left", new SimpleTypeReference(typeof(Row).FullName)));
            mergeRowsMethod.Parameters.Add(new ParameterDeclaration("right", new SimpleTypeReference(typeof(Row).FullName)));
            CodeBuilder.DeclareLocal(mergeRowsMethod, "row", TypeSystemServices.Map(typeof(Row)));
            mergeRowsMethod.Body.Add(
                new BinaryExpression(BinaryOperatorType.Assign,
                                     new ReferenceExpression("row"),
                                     new MethodInvocationExpression(
                                         AstUtil.CreateReferenceExpression(typeof(Row).FullName))
                    )
                );
            mergeRowsMethod.Body.Add(macro.Body);
            mergeRowsMethod.Body.Add(new ReturnStatement(new ReferenceExpression("row")));

            ParentMethods.Add(mergeRowsMethod);
            return null;
        }
开发者ID:f4i2u1,项目名称:rhino-etl,代码行数:31,代码来源:ActionMacro.cs


示例10: OnMacroStatement

        public override void OnMacroStatement(MacroStatement node)
        {
            base.OnMacroStatement(node);

            if (node.Name == "include")
                ExpandIncludeMacro(node);
        }
开发者ID:JeremySkinner,项目名称:Phantom,代码行数:7,代码来源:IncludeSupportStep.cs


示例11: ExpandImpl

 protected override Statement ExpandImpl(MacroStatement macro){
     if (macro.Arguments.Count == 0){
         throw new Exception("output must be called with arguemnts");
     }
     UnescapeInitialAndClosingDoubleQuotes(macro);
     return PrintMacroModule.expandPrintMacro(macro, output, output);
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:7,代码来源:OutputMacro.cs


示例12: DoExpand

        /// <summary>
        /// Perform the actual expansion of the macro
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        protected override Statement DoExpand(MacroStatement macro)
        {
            List<string> columns = new List<string>();

            if(macro.Block.HasStatements)
            {
                Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "GroupBy cannot contain statements"));
                return null;
            }
            foreach (Expression argument in macro.Arguments)
            {
                ReferenceExpression expr = argument as ReferenceExpression;
                if(expr==null)
                {
                    Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "GroupBy arguments must be refernce expressions. Example: groupBy name, surname"));
                    return null;
                }
                columns.Add(expr.Name);
            }

            Method method = CreateGetColumnsToGroupByMethod(macro, columns);

            ParentMethods.Add(method);

            return null;
        }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:31,代码来源:GroupByMacro.cs


示例13: ForCoverage

        public void ForCoverage()
        {
            var statement = new MacroStatement();
            statement.Block.Statements.Add(new MacroStatement());

            CodeBuilderHelper.CreateCallableFromMacroBody(new BooCodeBuilder(new TypeSystemServices()), statement);
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:7,代码来源:CodeBuilderHelperTester.cs


示例14: Expand

        /// <summary>
        /// Expands the specified macro, validate that the parent is a valid parent, 
        /// leave the actual processing to a base class
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        public override Statement Expand(MacroStatement macro)
        {
            if (ValidateParent(macro, out parent) == false)
                return null;

            return DoExpand(macro);
        }
开发者ID:f4i2u1,项目名称:rhino-etl,代码行数:13,代码来源:AbstractChildMacro.cs


示例15: Expand

		public override Statement Expand(MacroStatement macro)
		{
			if (macro.Arguments.Count == 0)
				throw new RailsException("output must be called with arguemnts");
			UnescapeInitialAndClosingDoubleQuotes(macro);
			return Expand(macro, output, output);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:7,代码来源:OutputMacro.cs


示例16: ExpandImpl

        protected override Statement ExpandImpl(MacroStatement macro){
            var result = new Block();
            foreach (Statement st in macro.Body.Statements){
                var decl = st as DeclarationStatement;
                var refer = st as ExpressionStatement;
                if(null==decl){
                    var ex = refer.Expression;
                    if (ex is MethodInvocationExpression){
                        decl =
                            new DeclarationStatement(
                                new Declaration(((MethodInvocationExpression) refer.Expression).Target.ToCodeString(),
                                                null), null);
                    }
                    if(ex is BinaryExpression){
                        var b = ex as BinaryExpression;
                        decl = new DeclarationStatement(
                            new Declaration(b.Left.ToCodeString(),null),b.Right
                            );
                    }
                }

                var bin = new BinaryExpression(BinaryOperatorType.Assign,
                                               new TryCastExpression(new ReferenceExpression(decl.Declaration.Name),
                                                                     decl.Declaration.Type),
                                               decl.Initializer);
                var def = new MacroStatement("definebrailproperty");
                def.Arguments.Add(bin);
                result.Add(def);
            }
            return result;
        }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:31,代码来源:DefinesMacro.cs


示例17: Expand

 public override Statement Expand(MacroStatement macro)
 {
     var instance = macro.Arguments[0] as ReferenceExpression;
     var transformer = new WithExpander(instance);
     transformer.Visit(macro.Body);
     return macro.Body;
 }
开发者ID:JulianBirch,项目名称:Solution-Transform,代码行数:7,代码来源:WithMacro.cs


示例18: ExpandGeneratorImpl

 protected override IEnumerable<Node> ExpandGeneratorImpl(MacroStatement macro){
     var method = new Method("_key"){
                                        ReturnType = new SimpleTypeReference("string"),
                                        Modifiers = TypeMemberModifiers.Public | TypeMemberModifiers.Override,
                                        Body = macro.extractMethodBody()
                                    };
     yield return method;
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:8,代码来源:CachekeyMacro.cs


示例19: ExpandGeneratorImpl

 protected override IEnumerable<Node> ExpandGeneratorImpl(MacroStatement macro){
     string typename = macro.Arguments[0].ToCodeString() + ", " + macro.Arguments[1].ToCodeString();
     //for normalizing nested classes parsed as add operators
     typename = typename.Replace(" ", "");
     var type = Type.GetType(typename);
     var generator = (IAstIncludeSource)type.GetConstructor(Type.EmptyTypes).Invoke(null);
     return generator.Substitute(macro);
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:8,代码来源:IncludeastMacro.cs


示例20: ExpandImpl

 protected override Statement ExpandImpl(MacroStatement macro){
     var call = new MethodInvocationExpression(
         new ReferenceExpression("__Export")
         );
     call.Arguments.Add(new StringLiteralExpression(macro.Arguments[0].ToCodeString()));
     if(macro.Arguments.Count==2){
         call.Arguments.Add(macro.Arguments[1]);
     }
     return new ExpressionStatement(call);
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:10,代码来源:ExportMacro.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Ast.MemberReferenceExpression类代码示例发布时间:2022-05-24
下一篇:
C# Ast.InterfaceDefinition类代码示例发布时间: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