9 |
|
|
10 |
// This header defines data types shared between the VM core implementation |
// This header defines data types shared between the VM core implementation |
11 |
// (inside the current source directory) and other parts of the sampler |
// (inside the current source directory) and other parts of the sampler |
12 |
// (located at other source directories). |
// (located at other source directories). It also acts as public API of the |
13 |
|
// Real-Time script engine for other applications. |
14 |
|
|
15 |
#ifndef LS_INSTR_SCRIPT_PARSER_COMMON_H |
#ifndef LS_INSTR_SCRIPT_PARSER_COMMON_H |
16 |
#define LS_INSTR_SCRIPT_PARSER_COMMON_H |
#define LS_INSTR_SCRIPT_PARSER_COMMON_H |
94 |
class VMStringExpr; |
class VMStringExpr; |
95 |
class VMIntArrayExpr; |
class VMIntArrayExpr; |
96 |
class VMStringArrayExpr; |
class VMStringArrayExpr; |
97 |
|
class VMParserContext; |
98 |
|
|
99 |
/** @brief Virtual machine expression |
/** @brief Virtual machine expression |
100 |
* |
* |
788 |
virtual VMFunction* functionByName(const String& name) = 0; |
virtual VMFunction* functionByName(const String& name) = 0; |
789 |
|
|
790 |
/** |
/** |
791 |
|
* Returns @c true if the passed built-in function is disabled and |
792 |
|
* should be ignored by the parser. This method is called by the |
793 |
|
* parser on preprocessor level for each built-in function call within |
794 |
|
* a script. Accordingly if this method returns @c true, then the |
795 |
|
* respective function call is completely filtered out on preprocessor |
796 |
|
* level, so that built-in function won't make into the result virtual |
797 |
|
* machine representation, nor would expressions of arguments passed to |
798 |
|
* that built-in function call be evaluated, nor would any check |
799 |
|
* regarding correct usage of the built-in function be performed. |
800 |
|
* In other words: a disabled function call ends up as a comment block. |
801 |
|
* |
802 |
|
* @param fn - built-in function to be checked |
803 |
|
* @param ctx - parser context at the position where the built-in |
804 |
|
* function call is located within the script |
805 |
|
*/ |
806 |
|
virtual bool isFunctionDisabled(VMFunction* fn, VMParserContext* ctx) = 0; |
807 |
|
|
808 |
|
/** |
809 |
* Returns a variable name indexed map of all built-in script variables |
* Returns a variable name indexed map of all built-in script variables |
810 |
* which point to native "int" scalar (usually 32 bit) variables. |
* which point to native "int" scalar (usually 32 bit) variables. |
811 |
*/ |
*/ |
899 |
* instance. |
* instance. |
900 |
*/ |
*/ |
901 |
virtual void signalAbort() = 0; |
virtual void signalAbort() = 0; |
902 |
|
|
903 |
|
/** |
904 |
|
* Copies the current entire execution state from this object to the |
905 |
|
* given object. So this can be used to "fork" a new script thread which |
906 |
|
* then may run independently with its own polyphonic data for instance. |
907 |
|
*/ |
908 |
|
virtual void forkTo(VMExecContext* ectx) const = 0; |
909 |
}; |
}; |
910 |
|
|
911 |
/** @brief Script callback for a certain event. |
/** @brief Script callback for a certain event. |
937 |
}; |
}; |
938 |
|
|
939 |
/** |
/** |
940 |
|
* Reflects the precise position and span of a specific code block within |
941 |
|
* a script. This is currently only used for the locations of commented |
942 |
|
* code blocks due to preprocessor statements, and for parser errors and |
943 |
|
* parser warnings. |
944 |
|
* |
945 |
|
* @see ParserIssue for code locations of parser errors and parser warnings |
946 |
|
* |
947 |
|
* @see VMParserContext::preprocessorComments() for locations of code which |
948 |
|
* have been filtered out by preprocessor statements |
949 |
|
*/ |
950 |
|
struct CodeBlock { |
951 |
|
int firstLine; ///< The first line number of this code block within the script (indexed with 1 being the very first line). |
952 |
|
int lastLine; ///< The last line number of this code block within the script. |
953 |
|
int firstColumn; ///< The first column of this code block within the script (indexed with 1 being the very first column). |
954 |
|
int lastColumn; ///< The last column of this code block within the script. |
955 |
|
}; |
956 |
|
|
957 |
|
/** |
958 |
* Encapsulates a noteworty parser issue. This encompasses the type of the |
* Encapsulates a noteworty parser issue. This encompasses the type of the |
959 |
* issue (either a parser error or parser warning), a human readable |
* issue (either a parser error or parser warning), a human readable |
960 |
* explanation text of the error or warning and the location of the |
* explanation text of the error or warning and the location of the |
962 |
* |
* |
963 |
* @see VMSourceToken for processing syntax highlighting instead. |
* @see VMSourceToken for processing syntax highlighting instead. |
964 |
*/ |
*/ |
965 |
struct ParserIssue { |
struct ParserIssue : CodeBlock { |
966 |
String txt; ///< Human readable explanation text of the parser issue. |
String txt; ///< Human readable explanation text of the parser issue. |
|
int firstLine; ///< The first line number within the script where this issue was encountered (indexed with 1 being the very first line). |
|
|
int lastLine; ///< The last line number within the script where this issue was encountered. |
|
|
int firstColumn; ///< The first column within the script where this issue was encountered (indexed with 1 being the very first column). |
|
|
int lastColumn; ///< The last column within the script where this issue was encountered. |
|
967 |
ParserIssueType_t type; ///< Whether this issue is either a parser error or just a parser warning. |
ParserIssueType_t type; ///< Whether this issue is either a parser error or just a parser warning. |
968 |
|
|
969 |
/** |
/** |
1043 |
virtual std::vector<ParserIssue> warnings() const = 0; |
virtual std::vector<ParserIssue> warnings() const = 0; |
1044 |
|
|
1045 |
/** |
/** |
1046 |
|
* Returns all code blocks of the script which were filtered out by the |
1047 |
|
* preprocessor. |
1048 |
|
*/ |
1049 |
|
virtual std::vector<CodeBlock> preprocessorComments() const = 0; |
1050 |
|
|
1051 |
|
/** |
1052 |
* Returns the translated virtual machine representation of an event |
* Returns the translated virtual machine representation of an event |
1053 |
* handler block (i.e. "on note ... end on" code block) within the |
* handler block (i.e. "on note ... end on" code block) within the |
1054 |
* parsed script. This translated representation of the event handler |
* parsed script. This translated representation of the event handler |