Ejemplo n.º 1
0
        public IEngine Create(Root root)
        {
            ValidateThread();
            Handler handler = EngineInternals.DriverApplication_New(RootDriver.ContextPtr);

            return(new Engine(handler, RootDriver));
        }
 public void AtomVsVariableBoundToSameAtom()
 {
     Assert.IsTrue(EngineInternals.AreEqual(
                       new Variable("X")
     {
         BoundTo = new Atom("X")
     },
                       new Atom("X")));
 }
Ejemplo n.º 3
0
        static void Main(string [] args)
        {
            Compiled.Program program = GetProgram(args[0]);

            var externalPredicates = new [] { Concat.GetConcat(), Lexer.GetLexer(new StringReader("ордена ленина полк")) };

            program.SetExternalPredicateCallbacks(externalPredicates);

            var engine = new EngineInternals();

            var events = engine.Run(program);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1(events));
        }
// ReSharper disable ParameterTypeCanBeEnumerable.Local
        private static bool AreEqual(List lhs, List rhs)
// ReSharper restore ParameterTypeCanBeEnumerable.Local
        {
            var e1 = lhs.GetEnumerator();
            var e2 = rhs.GetEnumerator();

            while (true)
            {
                bool more1 = e1.MoveNext();
                bool more2 = e2.MoveNext();

                if (more1 && more2)
                {
                    if (!EngineInternals.AreEqual(e1.Current, e2.Current))
                    {
                        return(false);
                    }
                }
                else
                {
                    return(more1 == more2); // lists are of same length
                }
            }
        }
 public void UnboundVariableVsAtom()
 {
     Assert.IsFalse(EngineInternals.AreEqual(
                        new Variable("X"),
                        new Atom("X")));
 }
 public void TwoEmptyLists()
 {
     Assert.IsTrue(EngineInternals.AreEqual(
                       new List(new IValue [] {}),
                       new List(new IValue [] {})));
 }
 public void TwoListsOfLengthTwoThatAreEqual()
 {
     Assert.IsTrue(EngineInternals.AreEqual(
                       new List(new IValue [] { new Atom("x"), new Atom("y") }),
                       new List(new IValue [] { new Atom("x"), new Atom("y") })));
 }
 public void ListVsAtom()
 {
     Assert.IsFalse(EngineInternals.AreEqual(
                        new List(new IValue [] { new Atom("x") }),
                        new Atom("y")));
 }
 public void TwoAtomsThatAreNotEqual()
 {
     Assert.IsFalse(EngineInternals.AreEqual(new Atom("x"), new Atom("y")));
 }
Ejemplo n.º 10
0
 public void Stop(IEngine engine)
 {
     ValidateThread();
     EngineInternals.DriverApplication_Stop(GetPointerFromObj(engine));
 }
Ejemplo n.º 11
0
 public void RunNextFrame(IEngine engine)
 {
     ValidateThread();
     EngineInternals.DriverApplication_NextFrame(GetPointerFromObj(engine));
 }
Ejemplo n.º 12
0
 public void Initialize(IEngine engine)
 {
     ValidateThread();
     EngineInternals.DriverApplication_Initialize(GetPointerFromObj(engine));
 }