Ejemplo n.º 1
0
        WamMachine(Program program, Query query)
        {
            if (program == null)
            {
                throw new ArgumentNullException("program");
            }
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            Program = program;
            Query   = query;

            _contextStack  = new Stack <WamContext>();
            CurrentContext = null;

            _performanceStatistics = new PerformanceStatistics();
        }
Ejemplo n.º 2
0
        WamMachine(Program program, Query query)
        {
            if (program == null)
            {
                throw new ArgumentNullException("program");
            }
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            Program = program;
            Query = query;

            _contextStack = new Stack<WamContext>();
            CurrentContext = null;

            _performanceStatistics = new PerformanceStatistics();
        }
Ejemplo n.º 3
0
        ExecutionResults Execute(WamInstruction instruction)
        {
            PerformanceStatistics.IncrementInstructionCount();

            switch (instruction.OpCode)
            {
            // Control Flow
            //
            case WamInstructionOpCodes.Allocate: return(OnAllocate(instruction));

            case WamInstructionOpCodes.Call: return(OnCall(instruction));

            case WamInstructionOpCodes.Cut: return(OnCut(instruction));

            case WamInstructionOpCodes.Execute: return(OnExecute(instruction));

            case WamInstructionOpCodes.Deallocate: return(OnDeallocate(instruction));

            case WamInstructionOpCodes.LibraryCall: return(OnLibraryCall(instruction));

            case WamInstructionOpCodes.Noop: return(OnNoop(instruction));

            case WamInstructionOpCodes.Proceed: return(OnProceed(instruction));

            case WamInstructionOpCodes.RetryMeElse: return(OnRetryMeElse(instruction));

            case WamInstructionOpCodes.Success: return(OnSuccess(instruction));

            case WamInstructionOpCodes.Failure: return(OnFailure(instruction));

            case WamInstructionOpCodes.TrustMe: return(OnTrustMe(instruction));

            case WamInstructionOpCodes.TryMeElse: return(OnTryMeElse(instruction));

            // Put/Set
            //
            case WamInstructionOpCodes.PutBoundVariable: return(OnPutBoundVariable(instruction));

            case WamInstructionOpCodes.PutStructure: return(OnPutStructure(instruction));

            case WamInstructionOpCodes.PutUnboundVariable: return(OnPutUnboundVariable(instruction));

            case WamInstructionOpCodes.PutValue: return(OnPutValue(instruction));

            case WamInstructionOpCodes.SetBoundVariable: return(OnSetBoundVariable(instruction));

            case WamInstructionOpCodes.SetUnboundVariable: return(OnSetUnboundVariable(instruction));

            case WamInstructionOpCodes.SetValue: return(OnSetValue(instruction));

            // Get/Unify
            //
            case WamInstructionOpCodes.GetBoundVariable: return(OnGetBoundVariable(instruction));

            case WamInstructionOpCodes.GetStructure: return(OnGetStructure(instruction));

            case WamInstructionOpCodes.GetUnboundVariable: return(OnGetUnboundVariable(instruction));

            case WamInstructionOpCodes.GetValue: return(OnGetValue(instruction));

            case WamInstructionOpCodes.UnifyBoundVariable: return(OnUnifyBoundVariable(instruction));

            case WamInstructionOpCodes.UnifyUnboundVariable: return(OnUnifyUnboundVariable(instruction));

            case WamInstructionOpCodes.UnifyValue: return(OnUnifyValue(instruction));

            default:
                throw new InvalidOperationException(string.Format("Unknown opcode {0}.", instruction.OpCode));
            }
        }