當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。