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

C# CodeBlock类代码示例

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

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



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

示例1: Generate

        public override Expression Generate(object args, CodeBlock cb)
        {
            Cons c = (Cons)args;

              var an = c.car;

              if (an is Annotation)
              {
            var anno = (Annotation)an;
            if (anno.source is Cons)
            {
              Cons src = anno.source as Cons;
              string filename = src.car as string;
              object location = src.cdr;

              //LocationHint = filename;
              if (cb.Filename == null)
              {
            cb.Filename = filename;
              }

              if (location is string)
              {
            var SpanHint = ExtractLocation(location as string);
            return Apply(cb, c, SpanHint);
              }
              else if (location is SourceSpan)
              {
            return Apply(cb, c, (SourceSpan)location);
              }
            }
              }

              return GetAst(c.cdr, cb);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:35,代码来源:AnnotatedCallGenerator.cs


示例2: Parse

        public static SyntaxNode Parse(CobaltParser parser)
        {
            if (parser.Match(TokenClass.IDENTIFIER, "if", TokenClass.OPEN_PARAN, "("))
            {
                Statement ret = new Statement();
                parser.Match(TokenClass.IDENTIFIER, TokenClass.OPEN_PARAN, typeof(Expression),
                    TokenClass.CLOSE_PARAN, typeof(Statement));
                return ret;
            }
            else if (parser.Match(TokenClass.IDENTIFIER, "while", TokenClass.OPEN_PARAN, "("))
            {
                Statement ret = new Statement();
                parser.Match(TokenClass.IDENTIFIER, TokenClass.OPEN_PARAN, typeof(Expression),
                    TokenClass.CLOSE_PARAN, typeof(Statement));
                return ret;
            }
            else if (parser.Match(TokenClass.IDENTIFIER, TokenClass.ASSIGN))
            {
                Statement stn = new Statement();
                parser.Term(stn, typeof(Identifier), TokenClass.ASSIGN, typeof(Expression), TokenClass.SEMI_COLON);
                return stn;
            }
            else if (parser.Match(TokenClass.OPEN_BRACKET))
            {
                CodeBlock block = new CodeBlock();
                parser.ReadToken();
                while (parser.PeekToken() != null && parser.PeekToken().Class != TokenClass.CLOSE_BRACKET)
                    block.AddLeave(Statement.Parse(parser));
                parser.ReadToken();
                return block;

            }
            return null;
        }
开发者ID:hbarve1,项目名称:Cobalt,代码行数:34,代码来源:Statement.cs


示例3: ScriptCode

 internal ScriptCode(CodeBlock code, LanguageContext languageContext, CompilerContext compilerContext) {
     Assert.NotNull(code, languageContext, compilerContext);
     
     _code = code;
     _languageContext = languageContext;
     _compilerContext = compilerContext;
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:ScriptCode.cs


示例4: Perform

 public void Perform(
     CodeBlock block,
     Stack<DmlObject> stack,
     Dictionary<string, DmlObject> locals,
     DmlObject bullet, DmlSystem system)
 {
     switch (property)
     {
         case DmlTokens.INTRINSIC_ORIGIN:
             stack.Push(new DmlObject(DmlType.Vector, ((DmlBullet)bullet.Value).Origin));
             break;
         case DmlTokens.INTRINSIC_POSITION:
             stack.Push(new DmlObject(DmlType.Vector, ((DmlBullet)bullet.Value).Position));
             break;
         case DmlTokens.INTRINSIC_DIRECTION:
             stack.Push(new DmlObject(DmlType.Vector, ((DmlBullet)bullet.Value).Direction));
             break;
         case DmlTokens.INTRINSIC_SPEED:
             stack.Push(new DmlObject(DmlType.Vector, ((DmlBullet)bullet.Value).Speed));
             break;
         case DmlTokens.INTRINSIC_COLOUR:
             stack.Push(new DmlObject(DmlType.Colour, ((DmlBullet)bullet.Value).Colour));
             break;
         case DmlTokens.INTRINSIC_TIME:
             stack.Push(new DmlObject(DmlType.Number, ((DmlBullet)bullet.Value).LocalTime));
             break;
         case DmlTokens.INTRINSIC_VELOCITY:
             DmlBullet b = (DmlBullet)bullet.Value;
             stack.Push(new DmlObject(DmlType.Vector, b.Direction * (float)b.Speed));
             break;
         default:
             throw new DmlSyntaxError(String.Format("Unknown bullet property \"{0}\"", property));
     }
 }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:34,代码来源:LoadIntrinsicBulletProperty.cs


示例5: Perform

 public void Perform(
     CodeBlock block,
     Stack<DmlObject> stack,
     Dictionary<string, DmlObject> locals,
     DmlObject bullet, DmlSystem system)
 {
     switch (property)
     {
         case DmlTokens.INTRINSIC_DIRECTION:
             ((DmlBullet)bullet.Value).Direction = (Vector2)(stack.Pop().Value);
             break;
         case DmlTokens.INTRINSIC_SPEED:
             ((DmlBullet)bullet.Value).Speed = (double)(stack.Pop().Value);
             break;
         case DmlTokens.INTRINSIC_COLOUR:
             ((DmlBullet)bullet.Value).Colour = (Color)(stack.Pop().Value);
             break;
         case DmlTokens.INTRINSIC_SPRITE:
             string name = (string)(stack.Pop().Value);
             ((DmlBullet)bullet.Value).SetSprite(name.Substring(1, name.Length - 2));
             break;
         default:
             throw new DmlSyntaxError(String.Format("Unknown intrinsic property \"{0}\"", property));
     }
 }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:25,代码来源:AssignIntrinsicBulletProperty.cs


示例6: Generate

        //(import (ironscheme clr))
        //(define f (ffi-callout int32 (void* uint16)))
        public override Expression Generate(object args, CodeBlock cb)
        {
            Cons c = args as Cons;
              Type returntype = GetFFIType(Unquote(c.car));
              c = c.cdr as Cons;

              List<Type> paramtypes = new List<Type>();

              while (c != null)
              {
            paramtypes.Add(GetFFIType(Unquote(c.car)));
            c = c.cdr as Cons;
              }

              CodeBlock outer = Ast.CodeBlock("outer");
              outer.Parent = cb;

              Variable ptr = Variable.Parameter(outer, SymbolTable.StringToId("ptr"), typeof(object));
              outer.AddParameter(ptr);

              CodeBlock inner = GenerateInvoke("ffi-callout",
            a => MakePointerCall(ptr, returntype, paramtypes, a),
            returntype,
            paramtypes,
            outer);

              outer.Body = Ast.Return(MakeClosure(inner, false));

              return MakeClosure(outer, false);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:32,代码来源:FFICallGenerator.cs


示例7: CleanCode

 /// <summary>
 /// The clean code.
 /// </summary>
 /// <param name="code">
 /// The code.
 /// </param>
 /// <returns>
 /// The System.String.
 /// </returns>
 public static string CleanCode(string code)
 {
     CodeBlock codeBlock = new CodeBlock(code);
     codeBlock.GetSnippets();
     codeBlock.ReplaceSnippets();
     return codeBlock.HighlightedText;
 }
开发者ID:pickup,项目名称:PickupBlog,代码行数:16,代码来源:CodeCleaner.cs


示例8: Times

 public static void Times(this int value, CodeBlock codeBlock)
 {
     for (int i = 0; i < value; i++)
     {
         codeBlock();
     }
 }
开发者ID:shantanusinghal,项目名称:grepo,代码行数:7,代码来源:IntExtension.cs


示例9: Perform

 public void Perform(
     CodeBlock block,
     Stack<DmlObject> stack, 
     Dictionary<string, DmlObject> locals,
     DmlObject bullet, DmlSystem system)
 {
 }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:7,代码来源:Label.cs


示例10: GetCode

        public CodeBlock GetCode()
        {
            CodeBlock block = new CodeBlock();
            block.Code = GetCurrentInput();

            return block;
        }
开发者ID:BenHall,项目名称:ironeditor,代码行数:7,代码来源:FileManager.cs


示例11: Main

        static void Main(string[] args)
        {
            var root = XDocument.Load("frames.xml").Root;

            var FrameDescriptions = root.Elements("Frame").Select(XFrame => FrameDescription.GetFrameDescription(XFrame));

            //var props = frame.Elements("Property").Select(XProperty => PropertyDescription.GetProperty(XProperty)).ToList();

            //foreach (var p in props.Where(pp => pp != null))
            //    Console.WriteLine(p.PropertyDecoder.Text);

            var Code = new CodeBlock()
            {
                new CodeLine("using System;"),
                new CodeLine("using System.Collections.Generic;"),
                new CodeLine("using System.Linq;"),
                new CodeLine("using System.Text;"),
                new CodeLine(),
                new CodeHeaderedBlock("namespace BlokFrames")
                {
                    FrameDescriptions.Select(fd => fd.GetCode())
                }
            };

            using (TextWriter tw = new StreamWriter("Frames.cs"))
            {
                tw.WriteLine(Code.Text);
            }

            Console.WriteLine(Code.Text);

            Console.Read();
        }
开发者ID:NpoSaut,项目名称:netCanLib,代码行数:33,代码来源:Program.cs


示例12: Generate

        public override Expression Generate(object args, CodeBlock c)
        {
            var refs = ClrGenerator.SaveReferences();

              CodeBlock cb = Ast.CodeBlock(SpanHint, GetLambdaName(c));
              NameHint = SymbolId.Empty;
              cb.Filename = LocationHint;
              cb.Parent = c;
              cb.Source = new Cons(SymbolTable.StringToObject("lambda"), args);

              object arg = Builtins.First(args);

              Cons body = Builtins.Cdr(args) as Cons;

              bool isrest = AssignParameters(cb, arg);

              cb.IsRest = isrest;

              List<Statement> stmts = new List<Statement>();
              FillBody(cb, stmts, body, true);

              Expression ex = MakeClosure(cb, isrest);

              ClrGenerator.ResetReferences(refs);

              return ex;
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:27,代码来源:LambdaGenerator.cs


示例13: Generate

        public override Expression Generate(object args, CodeBlock cb)
        {
            if (args == null)
              {
            return Ast.ReadField(null, Unspecified);
              }
              else
              {
            // discard effectfree
            List<Expression> newargs = new List<Expression>();
            Expression[] aa = GetAstList(args as Cons, cb);
            if (aa.Length == 1)
            {
              return aa[0];
            }
            for (int i = 0; i < aa.Length - 1; i++)
            {
              Expression a = aa[i];
              Expression uwa = Unwrap(a);
              if (uwa is ConstantExpression)
              {
            continue;
              }
              if (uwa is MemberExpression)
              {
            MemberExpression me = uwa as MemberExpression;
            if (me.Member == Unspecified)
            {
              continue;
            }
              }
              if (uwa is CommaExpression)
              {
            newargs.AddRange(((CommaExpression)uwa).Expressions);
              }
              else
              {
            newargs.Add(a);
              }
            }
            if (newargs.Count == 0)
            {
              return aa[aa.Length - 1];
            }
            else
            {
              Expression uwa = aa[aa.Length - 1];
              if (uwa is CommaExpression)
              {
            newargs.AddRange(((CommaExpression)uwa).Expressions);
              }
              else
              {
            newargs.Add(uwa);
              }

              return Ast.Comma(newargs);
            }
              }
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:60,代码来源:BeginGenerator.cs


示例14: Perform

 public void Perform(
     CodeBlock block,
     Stack<DmlObject> stack,
     Dictionary<string, DmlObject> locals,
     DmlObject bullet, DmlSystem system)
 {
     ((DmlBullet)bullet.Value).Dead = true;
 }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:8,代码来源:Kill.cs


示例15: Else

 public Value Else(Value previous, CodeBlock block)
 {
     if (previous.Type == ValueType.IfFalse)
     {
         return block.Execute(Interpreter);
     }
     return previous;
 }
开发者ID:LukaHorvat,项目名称:Hype,代码行数:8,代码来源:BasicFunctions.cs


示例16: Perform

 public void Perform(
     CodeBlock block,
     Stack<DmlObject> stack, 
     Dictionary<string, DmlObject> locals, 
     DmlObject bullet, DmlSystem system)
 {
     bullet.BoundVars[name] = stack.Pop();
 }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:8,代码来源:AssignBulletBound.cs


示例17: Perform

 public void Perform(
     CodeBlock block,
     Stack<DmlObject> stack, 
     Dictionary<string, DmlObject> locals, 
     DmlObject bullet, DmlSystem system)
 {
     system.GlobalVars.Add(name, stack.Pop());
 }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:8,代码来源:AssignGlobal.cs


示例18: Perform

 public void Perform(
     CodeBlock block,
     Stack<DmlObject> stack,
     Dictionary<string, DmlObject> locals,
     DmlObject bullet, DmlSystem system)
 {
     stack.Push(system.GlobalVars[name]);
 }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:8,代码来源:LoadGlobal.cs


示例19: Perform

        public void Perform(
            CodeBlock block,
            Stack<DmlObject> stack,
            Dictionary<string, DmlObject> locals,
            DmlObject bullet, DmlSystem system)
        {
            var paramNames = new string[paramCount];
            var values = new DmlObject[paramCount];

            DmlObject top;
            List<DmlObject> param;

            for (int i = 0; i < paramCount; i++)
            {
                top = stack.Pop();
                param = (List<DmlObject>)top.Value;
                paramNames[i] = (string)(param[0].Value);
                values[i] = param[1];
            }

            var currentAngle = 0d;
            if (hasAngleOffset)
                currentAngle = (double)(stack.Pop().Value);
            if (hasAngleOffsetD)
                currentAngle = Math.PI / 180 * (double)(stack.Pop().Value);

            var speed = (double)(stack.Pop().Value);
            var streams = (int)(double)(stack.Pop().Value);
            var factory = (DmlBulletFactory)(stack.Pop().Value);
            var oldBullet = (DmlBullet)(bullet.Value);

            var angleIncrement = 2*Math.PI/streams;

            DmlObject newBulletObj;
            DmlBullet newBullet;
            Vector2 direction;

            bool local = bullet != null;

            for (int i = 0; i < streams; i++)
            {
                newBulletObj = factory.Instantiate(oldBullet.Origin, system);
                newBullet = (DmlBullet)(newBulletObj.Value);
                direction = new Vector2((float)Math.Cos(currentAngle), (float)Math.Sin(currentAngle));

                newBullet.Direction = direction;
                newBullet.Speed = speed;

                for (int j = 0; j < paramCount; j++)
                    newBulletObj.SetVar(paramNames[j], values[j]);

                if (local)
                    oldBullet.Children.Add(newBullet);
                system.AddBullet(newBullet);

                currentAngle += angleIncrement;
            }
        }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:58,代码来源:RadialSpawn.cs


示例20: Perform

        public void Perform(
            CodeBlock block,
            Stack<DmlObject> stack,
            Dictionary<string, DmlObject> locals,
            DmlObject bullet, DmlSystem system)
        {
            var local = bullet != null;
            DmlBullet parent = null;
            Vector2 origin = Vector2.Zero;
            if (local)
            {
                parent = (DmlBullet)(bullet.Value);
                origin = parent.Position;
            }
            if (hasOrigin)
                origin = (Vector2)(stack.Pop().Value);

            double angleMin = 0, angleMax = 2 * Math.PI, speedMin, speedMax;
            if (hasAngleRange)
            {
                var angleRange = (List<DmlObject>)(stack.Pop().Value);
                angleMin = (double)angleRange[0].Value;
                angleMax = (double)angleRange[1].Value;
                if (degrees)
                {
                    angleMin *= Math.PI / 180;
                    angleMax *= Math.PI / 180;
                }
            }
            var speedRange = (List<DmlObject>)(stack.Pop().Value);
            speedMin = (double)speedRange[0].Value;
            speedMax = (double)speedRange[1].Value;

            var count = (double)(stack.Pop().Value);
            var factory = (DmlBulletFactory)(stack.Pop().Value);

            double crntAngle, crntSpeed;
            Vector2 direction;
            DmlObject newObj;
            DmlBullet newBullet;

            for (int i = 0; i < count; i++)
            {
                crntAngle = (angleMax - angleMin) * Globals.randGen.NextDouble() + angleMin;
                crntSpeed = (speedMax - speedMin) * Globals.randGen.NextDouble() + speedMin;
                direction = new Vector2((float)Math.Cos(crntAngle), (float)Math.Sin(crntAngle));

                newObj = factory.Instantiate(origin, system);
                newBullet = (DmlBullet)(newObj.Value);
                newBullet.Direction = direction;
                newBullet.Speed = crntSpeed;

                if (local)
                    parent.Children.Add(newBullet);
                system.AddBullet(newBullet);
            }
        }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:57,代码来源:BurstSpawn.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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