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


C# Forth.Define方法代码示例

本文整理汇总了C#中SimpleForth.Forth.Define方法的典型用法代码示例。如果您正苦于以下问题:C# Forth.Define方法的具体用法?C# Forth.Define怎么用?C# Forth.Define使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleForth.Forth的用法示例。


在下文中一共展示了Forth.Define方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            try
            {
#if false
                using (MemoryBlock mb = new MemoryBlock((UIntPtr)0x20000))
                {
                    Console.WriteLine("Is64Bit = " + MemoryBlock.Is64Bit);
                    Console.WriteLine("mb.Location = " + mb.Location);
                    Console.WriteLine("mb.Size = " + mb.Size);

                    Marshal.WriteByte(mb.Location, (byte)32);
                    byte b = Marshal.ReadByte(mb.Location);
                    System.Diagnostics.Debug.Assert(b == (byte)32);

                    mb.Security = MemoryBlockSecurity.ReadOnly;

                    byte b2 = Marshal.ReadByte(mb.Location);
                    Marshal.WriteByte(mb.Location, (byte)64);
                }
#endif
                Console.SetBufferSize(120, 60);
                Console.SetWindowSize(120, 60);
                Console.WriteLine("Sunlit World Forth in C#");
                Console.WriteLine("Copyright (c) 2007 by Edward Kiser");
                Console.WriteLine("All Rights Reserved");
                if (MemoryBlock.Is64Bit) Console.WriteLine("[Running in 64-bit Mode]");
                using (MemoryBlock mb = new MemoryBlock((UIntPtr)0x20000))
                {
                    mb.Security = MemoryBlockSecurity.ExecuteReadWrite;
                    Forth f = new Forth();
                    f.ByteMemory = new MemoryAccessor(mb.Location, mb.Size);
                    f.LoadX86Asm();
                    bool done = false;
                    f.Execute("also forth definitions previous");
                    f.Define("bye", delegate(Forth g) { done = true; });
                    f.Execute("vocabulary user  also user definitions");
                    while (!done)
                    {
                        if (f.IsCompiling) Console.WriteLine("ok (compiling)"); else Console.WriteLine("ok");
                        string x = Console.ReadLine();
                        f.Execute(x);
                    }
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine();
                Console.WriteLine("***** Exception! *****");
                Console.WriteLine();
                Console.WriteLine(exc);
            }
            Console.WriteLine("Press a key...");
            Console.ReadKey();
        }
开发者ID:Sunlighter,项目名称:SimpleForth,代码行数:55,代码来源:Program.cs

示例2: Create

 public static void Create(Forth f)
 {
     string word = f.getWord(' ');
     f.Define(word, MakeLiteralOp((long)f.here));
 }
开发者ID:Sunlighter,项目名称:SimpleForth,代码行数:5,代码来源:Forth.cs

示例3: Define

 public static void Define(Forth f)
 {
     if (!f.compileStack.IsEmpty) throw new InvalidOperationException("Nested definitions are not permitted");
     f.isCompiling = true;
     string localWordBeingCompiled = f.getWord(' ');
     f.compileStack.Push
     (
         new CompileState
         (
             new CompositeWord(),
             delegate(CompositeWord finishedWord)
             {
                 f.Define(localWordBeingCompiled, new ExecutionToken(finishedWord.Run));
             }
         )
     );
 }
开发者ID:Sunlighter,项目名称:SimpleForth,代码行数:17,代码来源:Forth.cs


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