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


C# CodeBlock类代码示例

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


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


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