當前位置: 首頁>>代碼示例>>C#>>正文


C# SimpleForth.Forth類代碼示例

本文整理匯總了C#中SimpleForth.Forth的典型用法代碼示例。如果您正苦於以下問題:C# Forth類的具體用法?C# Forth怎麽用?C# Forth使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Forth類屬於SimpleForth命名空間,在下文中一共展示了Forth類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Hex

 public static void Hex(Forth f)
 {
     f.numericBase = 16;
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:4,代碼來源:Forth.cs

示例3: Run

 public void Run(Forth f)
 {
     f.rStack.Push(0);
     while(true)
     {
         int pos = f.rStack.Pop();
         if (pos < 0 || pos >= components.Count) break;
         int posNext = pos + 1;
         f.rStack.Push(posNext);
         components[pos](f);
     }
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:12,代碼來源:Forth.cs

示例4: Allot

 public static void Allot(Forth f)
 {
     long amt = f.PopInt64();
     if (amt > (long)(f.memory.Length - f.here)) throw new ArgumentOutOfRangeException("Attempt to allot more memory than is available");
     f.here += (int)amt;
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例5: Comma

 public static void Comma(Forth f)
 {
     object v = f.dStack.Pop();
     f.memory[f.here] = v;
     f.here++;
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例6: Bang

 public static void Bang(Forth f)
 {
     long index = f.PopInt64();
     object v = f.dStack.Pop();
     f.memory[(int)index] = v;
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例7: Unused

 public static void Unused(Forth f)
 {
     f.PushInt64((long)(f.memory.Length - f.here));
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:4,代碼來源:Forth.cs

示例8: IsExecutionToken

 public static void IsExecutionToken(Forth f)
 {
     bool b = (f.dStack.Top is ExecutionToken);
     f.dStack.Pop();
     f.PushBool(b);
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例9: Not

 public static void Not(Forth f)
 {
     bool b = f.PopBool();
     f.PushBool(!b);
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:5,代碼來源:Forth.cs

示例10: IsNotLessThanUnsigned

 public static void IsNotLessThanUnsigned(Forth f)
 {
     ulong b = f.PopUInt64();
     ulong a = f.PopUInt64();
     f.PushBool(a >= b);
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例11: IsNotGreaterThanUnsigned

 public static void IsNotGreaterThanUnsigned(Forth f)
 {
     ulong b = f.PopUInt64();
     ulong a = f.PopUInt64();
     f.PushBool(a <= b);
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例12: IsNotLessThan

 public static void IsNotLessThan(Forth f)
 {
     long b = f.PopInt64();
     long a = f.PopInt64();
     f.PushBool(a >= b);
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例13: IsNotGreaterThan

 public static void IsNotGreaterThan(Forth f)
 {
     long b = f.PopInt64();
     long a = f.PopInt64();
     f.PushBool(a <= b);
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例14: DoesNotEqual

 public static void DoesNotEqual(Forth f)
 {
     ulong b = f.PopUInt64();
     ulong a = f.PopUInt64();
     f.PushBool(a != b);
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs

示例15: Equals

 public static void Equals(Forth f)
 {
     ulong b = f.PopUInt64();
     ulong a = f.PopUInt64();
     f.PushBool(a == b);
 }
開發者ID:Sunlighter,項目名稱:SimpleForth,代碼行數:6,代碼來源:Forth.cs


注:本文中的SimpleForth.Forth類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。