 |
Gorgon Game Engine
|
Go to the documentation of this file.
18 namespace Gorgon {
namespace Scripting {
59 auto par=this->parameters.begin();
65 Array *repeater=
nullptr;
66 while(par!=this->parameters.end()) {
70 ASSERT(par->IsOptional(),
"Non-optional parameter is ignored");
71 if(par==this->parameters.end()-1 &&
repeatlast) {
72 repeater=
new Array(par->GetType());
73 vm.References.Register(repeater);
77 v=par->GetDefaultValue();
81 if(par==this->parameters.end()-1 &&
repeatlast) {
82 repeater=
new Array(par->GetType());
83 vm.References.Register(repeater);
92 if(v.
GetType()==Types::Variant()) {
108 if(v.GetType()==Types::Variant()) {
109 v=v.GetValue<
Data>();
111 if(v.IsReference() && par->IsConstant()) {
124 auto ret=scope->ReturnValue;
126 if(ismethod && ret.IsValid()) {
127 vm.GetOutput()<<ret<<std::endl<<std::endl;
void SetVariable(const std::string &name, const Data &data)
Definition: Scope.h:151
std::shared_ptr< ScopeInstance > Instantiate(ScopeInstance ¤t) const
Definition: RuntimeFunction.h:49
void SaveInstruction(Instruction inst, long pline)
Definition: RuntimeFunction.h:41
Scope & GetParentScope()
Definition: RuntimeFunction.h:37
This is an instantiation of a scope.
Definition: Scope.h:223
Overload(const Type *returntype, ParameterList parameters, P_ ...tags)
Regular constructor that can take as many tags as needed.
Definition: Reflection.h:593
A new scope is created automatically when a new input source or a function like construct is created.
Definition: Scope.h:62
std::enable_if<!std::is_pointer< T_ >::value, const typename std::remove_reference< T_ >::type & >::type GetValue() const
Returns the value of this data in the requested format.
Definition: Data.h:57
const Type * returntype
Return type of this function variant. If nullptr this function does not return a value.
Definition: Reflection.h:739
bool implicit
If the parent function is constructor, marks this variant as an implicit type conversion.
Definition: Reflection.h:766
Data describes a piece of data.
Definition: Data.h:22
std::vector< Parameter > ParameterList
Definition: Reflection.h:308
void SaveInstructions(const std::vector< Instruction > &instructions)
Definition: RuntimeFunction.h:45
void SaveInstruction(Instruction inst, long pline)
Saves an instruction to the scope.
Definition: Scope.h:102
std::shared_ptr< ScopeInstance > Instantiate()
Definition: Scope.cpp:80
bool IsMember() const
Returns if this function is a member function of a type.
Definition: Reflection.h:863
bool accessible
Only meaningful in class member functions.
Definition: Reflection.h:751
static VirtualMachine & Get()
Returns the current VM for this thread.
Definition: VirtualMachine.h:109
const Type & GetType() const
Returns the type of the data.
Definition: Data.h:173
void SetName(const std::string &name)
In rare cases where scope name cannot be determined at the construction, this function can be used to...
Definition: Scope.h:179
void MakeConstant()
Makes this data a constant.
Definition: Data.cpp:199
This class stores information about types.
Definition: Reflection.h:1165
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
virtual void dochecks(bool ismethod) override
This function should perform validity checks on the variant.
Definition: RuntimeFunction.h:137
bool IsReference() const
Returns if this data contains a reference.
Definition: Data.cpp:212
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
static Data Invalid()
Constructs an invalid data object.
Definition: Data.h:27
Function * parent
The parent function of this variant.
Definition: Reflection.h:763
void PushData(Data elm)
Definition: Array.h:52
Represents a function overload.
Definition: Reflection.h:588
bool stretchlast
If true, in console dialect, spaces in the last parameter are not treated as parameter separator as i...
Definition: Reflection.h:743
bool repeatlast
If true last parameter can be specified any number of times.
Definition: Reflection.h:747
void SaveInstructions(const std::vector< Instruction > &insts)
Saves a list of instructions to this scope.
Definition: Scope.h:107
ParameterList parameters
Modifiable parameters of this overload.
Definition: Reflection.h:736
RuntimeOverload(Scope &parent, const Type *returntype, ParameterList parameters, bool stretchlast, bool repeatlast, bool accessible, bool constant, bool returnsref, bool returnsconst, bool implicit)
Definition: RuntimeFunction.h:22
Type * ArrayType()
Definition: Array.cpp:74
bool returnsref
This function variant returns a reference.
Definition: Reflection.h:757
Definition: RuntimeFunction.h:20
bool returnsconst
This function variant returns a constant, useful with references.
Definition: Reflection.h:760
bool constant
Makes this function constant. Only works on member functions.
Definition: Reflection.h:754
virtual Data Call(bool ismethod, const std::vector< Data > ¶meters) const override
Class the stub for this function.
Definition: RuntimeFunction.h:53
Represents a function.
Definition: Reflection.h:557
A single instruction.
Definition: Instruction.h:150
void NotImplemented(const std::string &what="This feature")
Definition: Assert.h:187
Scope & GetParent() const
Definition: Scope.h:138
std::string GetName() const
Returns the name of this member.
Definition: Reflection.h:325