Fleet  0.0.9
Inference in the LOT
Program.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Instruction.h"
4 #include "Stack.h"
5 
6 template<typename VirtualMachineState_t> class Program;
7 
16 template<typename VirtualMachineState_t>
18 public:
19 
20  // we have a variable that is set to true each time we call push_program
21  // this is useful for tracking recursion etc., if we want to make sure
22  // that a lexicon calls every factor or something
23  bool was_called;
24 
25  // This is a bit of hack -- we need a line here for each kind of key we might want to a lexicon.
26  // For reasons I don't fully understand, the linker will not find this if templated.
27 
29  virtual void push_program(Program<VirtualMachineState_t>& s, const short a) { throw NotImplementedError(); }
30  virtual void push_program(Program<VirtualMachineState_t>& s, const int a) { throw NotImplementedError(); }
31  virtual void push_program(Program<VirtualMachineState_t>& s, const std::string k) { throw NotImplementedError(); }
32 
33 };
34 
35 
44 template<typename VirtualMachineState_t>
45 class Program : public Stack<Instruction> {
46 public:
47 
49 
50  Program(ProgramLoader<VirtualMachineState_t>* pl=nullptr) : loader(pl) {
51  // This is chosen with a little experimentation, designed to prevent us from having to reallocate too often
52  // when we linearize, and also save us from having to compute program_size() when we linearize (since thats slow)
53  this->reserve(64);
54  }
55 };
56 
Definition: Stack.h:22
virtual void push_program(Program< VirtualMachineState_t > &s, const std::string k)
Definition: Program.h:31
virtual void push_program(Program< VirtualMachineState_t > &s)
Definition: Program.h:28
Definition: Program.h:17
f here is a point to a void(VirtualMachineState_t* vms, int arg), where arg is just a supplemental ar...
ProgramLoader< VirtualMachineState_t > * loader
Definition: Program.h:48
virtual void push_program(Program< VirtualMachineState_t > &s, const int a)
Definition: Program.h:30
virtual void push_program(Program< VirtualMachineState_t > &s, const short a)
Definition: Program.h:29
Definition: Errors.h:7
Definition: Program.h:6
bool was_called
Definition: Program.h:23
Program(ProgramLoader< VirtualMachineState_t > *pl=nullptr)
Definition: Program.h:50
Many things in Fleet are stacks and this is designed to allow for rapid changse to the stack type in ...