TorqueScript  0.2
function.hpp
1 
15 #pragma once
16 
17 #include <string>
18 #include <vector>
19 #include <memory>
20 
21 #include <torquescript/instructionsequence.hpp>
22 
23 namespace TorqueScript
24 {
26  class Interpreter;
27  class Instruction;
28  class CodeBlock;
29  class ExecutionScope;
30  class StoredValue;
31  class StoredValueStack;
32  class ExecutionState;
33  class ConsoleObject;
34 
39  class Function
40  {
41  public:
42  Function(const std::string& package, const std::string& space, const std::string& name);
43  Function(const std::string& package, const std::string& space, const std::string& name, const std::vector<std::string>& parameterNames);
44 
45  void addInstructions(const InstructionSequence& instructions);
46 
51  virtual void execute(std::shared_ptr<ConsoleObject> thisObject, std::shared_ptr<ExecutionState> state, const std::size_t argumentCount);
52 
57  const std::string& getDeclaredName();
58 
63  const std::string& getDeclaredNameSpace();
64 
69  const std::string& getDeclaredPackage();
70 
71  private:
73  std::string mPackage;
74 
76  std::string mNameSpace;
77 
79  std::string mName;
80 
82  InstructionSequence mInstructions;
83 
84  std::vector<std::string> mParameterNames;
85  };
86 }
A function is callable subroutine from anywhere in the language, defined by a script....
Definition: function.hpp:40
virtual void execute(std::shared_ptr< ConsoleObject > thisObject, std::shared_ptr< ExecutionState > state, const std::size_t argumentCount)
Default implementation will execute virtual instructions but can be overriden to implement native fun...
const std::string & getDeclaredNameSpace()
Retrieves the declared namespace of this function.
const std::string & getDeclaredPackage()
Retrieves the declared package of this function.
const std::string & getDeclaredName()
Retrieves the declared name of this function.
Storage class for a sequence of instructions to be executed. Also implements the primary execution co...
Definition: instructionsequence.hpp:39
Definition: ast.hpp:28