2
0

shader_language.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /*************************************************************************/
  2. /* shader_language.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef SHADER_LANGUAGE_H
  31. #define SHADER_LANGUAGE_H
  32. #include "core/list.h"
  33. #include "core/map.h"
  34. #include "core/string_name.h"
  35. #include "core/typedefs.h"
  36. #include "core/ustring.h"
  37. #include "core/variant.h"
  38. class ShaderLanguage {
  39. public:
  40. enum TokenType {
  41. TK_EMPTY,
  42. TK_IDENTIFIER,
  43. TK_TRUE,
  44. TK_FALSE,
  45. TK_REAL_CONSTANT,
  46. TK_INT_CONSTANT,
  47. TK_TYPE_VOID,
  48. TK_TYPE_BOOL,
  49. TK_TYPE_BVEC2,
  50. TK_TYPE_BVEC3,
  51. TK_TYPE_BVEC4,
  52. TK_TYPE_INT,
  53. TK_TYPE_IVEC2,
  54. TK_TYPE_IVEC3,
  55. TK_TYPE_IVEC4,
  56. TK_TYPE_UINT,
  57. TK_TYPE_UVEC2,
  58. TK_TYPE_UVEC3,
  59. TK_TYPE_UVEC4,
  60. TK_TYPE_FLOAT,
  61. TK_TYPE_VEC2,
  62. TK_TYPE_VEC3,
  63. TK_TYPE_VEC4,
  64. TK_TYPE_MAT2,
  65. TK_TYPE_MAT3,
  66. TK_TYPE_MAT4,
  67. TK_TYPE_SAMPLER2D,
  68. TK_TYPE_ISAMPLER2D,
  69. TK_TYPE_USAMPLER2D,
  70. TK_TYPE_SAMPLER2DARRAY,
  71. TK_TYPE_ISAMPLER2DARRAY,
  72. TK_TYPE_USAMPLER2DARRAY,
  73. TK_TYPE_SAMPLER3D,
  74. TK_TYPE_ISAMPLER3D,
  75. TK_TYPE_USAMPLER3D,
  76. TK_TYPE_SAMPLERCUBE,
  77. TK_INTERPOLATION_FLAT,
  78. TK_INTERPOLATION_SMOOTH,
  79. TK_PRECISION_LOW,
  80. TK_PRECISION_MID,
  81. TK_PRECISION_HIGH,
  82. TK_OP_EQUAL,
  83. TK_OP_NOT_EQUAL,
  84. TK_OP_LESS,
  85. TK_OP_LESS_EQUAL,
  86. TK_OP_GREATER,
  87. TK_OP_GREATER_EQUAL,
  88. TK_OP_AND,
  89. TK_OP_OR,
  90. TK_OP_NOT,
  91. TK_OP_ADD,
  92. TK_OP_SUB,
  93. TK_OP_MUL,
  94. TK_OP_DIV,
  95. TK_OP_MOD,
  96. TK_OP_SHIFT_LEFT,
  97. TK_OP_SHIFT_RIGHT,
  98. TK_OP_ASSIGN,
  99. TK_OP_ASSIGN_ADD,
  100. TK_OP_ASSIGN_SUB,
  101. TK_OP_ASSIGN_MUL,
  102. TK_OP_ASSIGN_DIV,
  103. TK_OP_ASSIGN_MOD,
  104. TK_OP_ASSIGN_SHIFT_LEFT,
  105. TK_OP_ASSIGN_SHIFT_RIGHT,
  106. TK_OP_ASSIGN_BIT_AND,
  107. TK_OP_ASSIGN_BIT_OR,
  108. TK_OP_ASSIGN_BIT_XOR,
  109. TK_OP_BIT_AND,
  110. TK_OP_BIT_OR,
  111. TK_OP_BIT_XOR,
  112. TK_OP_BIT_INVERT,
  113. TK_OP_INCREMENT,
  114. TK_OP_DECREMENT,
  115. TK_CF_IF,
  116. TK_CF_ELSE,
  117. TK_CF_FOR,
  118. TK_CF_WHILE,
  119. TK_CF_DO,
  120. TK_CF_SWITCH,
  121. TK_CF_CASE,
  122. TK_CF_BREAK,
  123. TK_CF_CONTINUE,
  124. TK_CF_RETURN,
  125. TK_CF_DISCARD,
  126. TK_BRACKET_OPEN,
  127. TK_BRACKET_CLOSE,
  128. TK_CURLY_BRACKET_OPEN,
  129. TK_CURLY_BRACKET_CLOSE,
  130. TK_PARENTHESIS_OPEN,
  131. TK_PARENTHESIS_CLOSE,
  132. TK_QUESTION,
  133. TK_COMMA,
  134. TK_COLON,
  135. TK_SEMICOLON,
  136. TK_PERIOD,
  137. TK_UNIFORM,
  138. TK_VARYING,
  139. TK_ARG_IN,
  140. TK_ARG_OUT,
  141. TK_ARG_INOUT,
  142. TK_RENDER_MODE,
  143. TK_HINT_WHITE_TEXTURE,
  144. TK_HINT_BLACK_TEXTURE,
  145. TK_HINT_NORMAL_TEXTURE,
  146. TK_HINT_ANISO_TEXTURE,
  147. TK_HINT_ALBEDO_TEXTURE,
  148. TK_HINT_BLACK_ALBEDO_TEXTURE,
  149. TK_HINT_COLOR,
  150. TK_HINT_RANGE,
  151. TK_SHADER_TYPE,
  152. TK_CURSOR,
  153. TK_ERROR,
  154. TK_EOF,
  155. TK_MAX
  156. };
  157. /* COMPILER */
  158. // lame work around to Apple defining this as a macro in 10.12 SDK
  159. #ifdef TYPE_BOOL
  160. #undef TYPE_BOOL
  161. #endif
  162. enum DataType {
  163. TYPE_VOID,
  164. TYPE_BOOL,
  165. TYPE_BVEC2,
  166. TYPE_BVEC3,
  167. TYPE_BVEC4,
  168. TYPE_INT,
  169. TYPE_IVEC2,
  170. TYPE_IVEC3,
  171. TYPE_IVEC4,
  172. TYPE_UINT,
  173. TYPE_UVEC2,
  174. TYPE_UVEC3,
  175. TYPE_UVEC4,
  176. TYPE_FLOAT,
  177. TYPE_VEC2,
  178. TYPE_VEC3,
  179. TYPE_VEC4,
  180. TYPE_MAT2,
  181. TYPE_MAT3,
  182. TYPE_MAT4,
  183. TYPE_SAMPLER2D,
  184. TYPE_ISAMPLER2D,
  185. TYPE_USAMPLER2D,
  186. TYPE_SAMPLER2DARRAY,
  187. TYPE_ISAMPLER2DARRAY,
  188. TYPE_USAMPLER2DARRAY,
  189. TYPE_SAMPLER3D,
  190. TYPE_ISAMPLER3D,
  191. TYPE_USAMPLER3D,
  192. TYPE_SAMPLERCUBE,
  193. };
  194. enum DataPrecision {
  195. PRECISION_LOWP,
  196. PRECISION_MEDIUMP,
  197. PRECISION_HIGHP,
  198. PRECISION_DEFAULT,
  199. };
  200. enum DataInterpolation {
  201. INTERPOLATION_FLAT,
  202. INTERPOLATION_SMOOTH,
  203. };
  204. enum Operator {
  205. OP_EQUAL,
  206. OP_NOT_EQUAL,
  207. OP_LESS,
  208. OP_LESS_EQUAL,
  209. OP_GREATER,
  210. OP_GREATER_EQUAL,
  211. OP_AND,
  212. OP_OR,
  213. OP_NOT,
  214. OP_NEGATE,
  215. OP_ADD,
  216. OP_SUB,
  217. OP_MUL,
  218. OP_DIV,
  219. OP_MOD,
  220. OP_SHIFT_LEFT,
  221. OP_SHIFT_RIGHT,
  222. OP_ASSIGN,
  223. OP_ASSIGN_ADD,
  224. OP_ASSIGN_SUB,
  225. OP_ASSIGN_MUL,
  226. OP_ASSIGN_DIV,
  227. OP_ASSIGN_MOD,
  228. OP_ASSIGN_SHIFT_LEFT,
  229. OP_ASSIGN_SHIFT_RIGHT,
  230. OP_ASSIGN_BIT_AND,
  231. OP_ASSIGN_BIT_OR,
  232. OP_ASSIGN_BIT_XOR,
  233. OP_BIT_AND,
  234. OP_BIT_OR,
  235. OP_BIT_XOR,
  236. OP_BIT_INVERT,
  237. OP_INCREMENT,
  238. OP_DECREMENT,
  239. OP_SELECT_IF,
  240. OP_SELECT_ELSE, //used only internally, then only IF appears with 3 arguments
  241. OP_POST_INCREMENT,
  242. OP_POST_DECREMENT,
  243. OP_CALL,
  244. OP_CONSTRUCT,
  245. OP_INDEX,
  246. OP_MAX
  247. };
  248. enum FlowOperation {
  249. FLOW_OP_IF,
  250. FLOW_OP_RETURN,
  251. FLOW_OP_FOR,
  252. FLOW_OP_WHILE,
  253. FLOW_OP_DO,
  254. FLOW_OP_BREAK,
  255. FLOW_OP_SWITCH,
  256. FLOW_OP_CONTINUE,
  257. FLOW_OP_DISCARD
  258. };
  259. enum ArgumentQualifier {
  260. ARGUMENT_QUALIFIER_IN,
  261. ARGUMENT_QUALIFIER_OUT,
  262. ARGUMENT_QUALIFIER_INOUT,
  263. };
  264. struct Node {
  265. Node *next;
  266. enum Type {
  267. TYPE_SHADER,
  268. TYPE_FUNCTION,
  269. TYPE_BLOCK,
  270. TYPE_VARIABLE,
  271. TYPE_VARIABLE_DECLARATION,
  272. TYPE_CONSTANT,
  273. TYPE_OPERATOR,
  274. TYPE_CONTROL_FLOW,
  275. TYPE_MEMBER
  276. };
  277. Type type;
  278. virtual DataType get_datatype() const { return TYPE_VOID; }
  279. Node(Type t) :
  280. next(NULL),
  281. type(t) {}
  282. virtual ~Node() {}
  283. };
  284. template <class T>
  285. T *alloc_node() {
  286. T *node = memnew(T);
  287. node->next = nodes;
  288. nodes = node;
  289. return node;
  290. }
  291. Node *nodes;
  292. struct OperatorNode : public Node {
  293. DataType return_cache;
  294. DataPrecision return_precision_cache;
  295. Operator op;
  296. Vector<Node *> arguments;
  297. virtual DataType get_datatype() const { return return_cache; }
  298. OperatorNode() :
  299. Node(TYPE_OPERATOR),
  300. return_cache(TYPE_VOID),
  301. return_precision_cache(PRECISION_DEFAULT),
  302. op(OP_EQUAL) {}
  303. };
  304. struct VariableNode : public Node {
  305. DataType datatype_cache;
  306. StringName name;
  307. virtual DataType get_datatype() const { return datatype_cache; }
  308. VariableNode() :
  309. Node(TYPE_VARIABLE),
  310. datatype_cache(TYPE_VOID) {}
  311. };
  312. struct VariableDeclarationNode : public Node {
  313. DataPrecision precision;
  314. DataType datatype;
  315. struct Declaration {
  316. StringName name;
  317. Node *initializer;
  318. };
  319. Vector<Declaration> declarations;
  320. virtual DataType get_datatype() const { return datatype; }
  321. VariableDeclarationNode() :
  322. Node(TYPE_VARIABLE_DECLARATION),
  323. precision(PRECISION_DEFAULT),
  324. datatype(TYPE_VOID) {}
  325. };
  326. struct ConstantNode : public Node {
  327. DataType datatype;
  328. union Value {
  329. bool boolean;
  330. float real;
  331. int32_t sint;
  332. uint32_t uint;
  333. };
  334. Vector<Value> values;
  335. virtual DataType get_datatype() const { return datatype; }
  336. ConstantNode() :
  337. Node(TYPE_CONSTANT),
  338. datatype(TYPE_VOID) {}
  339. };
  340. struct FunctionNode;
  341. struct BlockNode : public Node {
  342. FunctionNode *parent_function;
  343. BlockNode *parent_block;
  344. struct Variable {
  345. DataType type;
  346. DataPrecision precision;
  347. int line; //for completion
  348. };
  349. Map<StringName, Variable> variables;
  350. List<Node *> statements;
  351. bool single_statement;
  352. BlockNode() :
  353. Node(TYPE_BLOCK),
  354. parent_function(NULL),
  355. parent_block(NULL),
  356. single_statement(false) {}
  357. };
  358. struct ControlFlowNode : public Node {
  359. FlowOperation flow_op;
  360. Vector<Node *> expressions;
  361. Vector<BlockNode *> blocks;
  362. ControlFlowNode() :
  363. Node(TYPE_CONTROL_FLOW),
  364. flow_op(FLOW_OP_IF) {}
  365. };
  366. struct MemberNode : public Node {
  367. DataType basetype;
  368. DataType datatype;
  369. StringName name;
  370. Node *owner;
  371. virtual DataType get_datatype() const { return datatype; }
  372. MemberNode() :
  373. Node(TYPE_MEMBER),
  374. basetype(TYPE_VOID),
  375. datatype(TYPE_VOID),
  376. owner(NULL) {}
  377. };
  378. struct FunctionNode : public Node {
  379. struct Argument {
  380. ArgumentQualifier qualifier;
  381. StringName name;
  382. DataType type;
  383. DataPrecision precision;
  384. };
  385. StringName name;
  386. DataType return_type;
  387. DataPrecision return_precision;
  388. Vector<Argument> arguments;
  389. BlockNode *body;
  390. bool can_discard;
  391. FunctionNode() :
  392. Node(TYPE_FUNCTION),
  393. return_type(TYPE_VOID),
  394. return_precision(PRECISION_DEFAULT),
  395. body(NULL),
  396. can_discard(false) {}
  397. };
  398. struct ShaderNode : public Node {
  399. struct Function {
  400. StringName name;
  401. FunctionNode *function;
  402. Set<StringName> uses_function;
  403. bool callable;
  404. };
  405. struct Varying {
  406. DataType type;
  407. DataInterpolation interpolation;
  408. DataPrecision precision;
  409. Varying() :
  410. type(TYPE_VOID),
  411. interpolation(INTERPOLATION_FLAT),
  412. precision(PRECISION_DEFAULT) {}
  413. };
  414. struct Uniform {
  415. enum Hint {
  416. HINT_NONE,
  417. HINT_COLOR,
  418. HINT_RANGE,
  419. HINT_ALBEDO,
  420. HINT_BLACK_ALBEDO,
  421. HINT_NORMAL,
  422. HINT_BLACK,
  423. HINT_WHITE,
  424. HINT_ANISO,
  425. HINT_MAX
  426. };
  427. int order;
  428. int texture_order;
  429. DataType type;
  430. DataPrecision precision;
  431. Vector<ConstantNode::Value> default_value;
  432. Hint hint;
  433. float hint_range[3];
  434. Uniform() :
  435. order(0),
  436. texture_order(0),
  437. type(TYPE_VOID),
  438. precision(PRECISION_DEFAULT),
  439. hint(HINT_NONE) {
  440. hint_range[0] = 0.0f;
  441. hint_range[1] = 1.0f;
  442. hint_range[2] = 0.001f;
  443. }
  444. };
  445. Map<StringName, Varying> varyings;
  446. Map<StringName, Uniform> uniforms;
  447. Vector<StringName> render_modes;
  448. Vector<Function> functions;
  449. ShaderNode() :
  450. Node(TYPE_SHADER) {}
  451. };
  452. struct Expression {
  453. bool is_op;
  454. union {
  455. Operator op;
  456. Node *node;
  457. };
  458. };
  459. struct VarInfo {
  460. StringName name;
  461. DataType type;
  462. };
  463. enum CompletionType {
  464. COMPLETION_NONE,
  465. COMPLETION_RENDER_MODE,
  466. COMPLETION_MAIN_FUNCTION,
  467. COMPLETION_IDENTIFIER,
  468. COMPLETION_FUNCTION_CALL,
  469. COMPLETION_CALL_ARGUMENTS,
  470. COMPLETION_INDEX,
  471. };
  472. struct Token {
  473. TokenType type;
  474. StringName text;
  475. double constant;
  476. uint16_t line;
  477. };
  478. static String get_operator_text(Operator p_op);
  479. static String get_token_text(Token p_token);
  480. static bool is_token_datatype(TokenType p_type);
  481. static bool is_token_variable_datatype(TokenType p_type);
  482. static DataType get_token_datatype(TokenType p_type);
  483. static bool is_token_interpolation(TokenType p_type);
  484. static DataInterpolation get_token_interpolation(TokenType p_type);
  485. static bool is_token_precision(TokenType p_type);
  486. static DataPrecision get_token_precision(TokenType p_type);
  487. static String get_datatype_name(DataType p_type);
  488. static bool is_token_nonvoid_datatype(TokenType p_type);
  489. static bool is_token_operator(TokenType p_type);
  490. static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value = NULL);
  491. static DataType get_scalar_type(DataType p_type);
  492. static int get_cardinality(DataType p_type);
  493. static bool is_scalar_type(DataType p_type);
  494. static bool is_sampler_type(DataType p_type);
  495. static Variant constant_value_to_variant(const Vector<ShaderLanguage::ConstantNode::Value> &p_value, DataType p_type, ShaderLanguage::ShaderNode::Uniform::Hint p_hint = ShaderLanguage::ShaderNode::Uniform::HINT_NONE);
  496. static void get_keyword_list(List<String> *r_keywords);
  497. static void get_builtin_funcs(List<String> *r_keywords);
  498. struct BuiltInInfo {
  499. DataType type;
  500. bool constant;
  501. BuiltInInfo() :
  502. type(TYPE_VOID),
  503. constant(false) {}
  504. BuiltInInfo(DataType p_type, bool p_constant = false) :
  505. type(p_type),
  506. constant(p_constant) {}
  507. };
  508. struct FunctionInfo {
  509. Map<StringName, BuiltInInfo> built_ins;
  510. bool can_discard;
  511. };
  512. private:
  513. struct KeyWord {
  514. TokenType token;
  515. const char *text;
  516. };
  517. static const KeyWord keyword_list[];
  518. bool error_set;
  519. String error_str;
  520. int error_line;
  521. String code;
  522. int char_idx;
  523. int tk_line;
  524. StringName current_function;
  525. struct TkPos {
  526. int char_idx;
  527. int tk_line;
  528. };
  529. TkPos _get_tkpos() {
  530. TkPos tkp;
  531. tkp.char_idx = char_idx;
  532. tkp.tk_line = tk_line;
  533. return tkp;
  534. }
  535. void _set_tkpos(TkPos p_pos) {
  536. char_idx = p_pos.char_idx;
  537. tk_line = p_pos.tk_line;
  538. }
  539. void _set_error(const String &p_str) {
  540. if (error_set)
  541. return;
  542. error_line = tk_line;
  543. error_set = true;
  544. error_str = p_str;
  545. }
  546. static const char *token_names[TK_MAX];
  547. Token _make_token(TokenType p_type, const StringName &p_text = StringName());
  548. Token _get_token();
  549. ShaderNode *shader;
  550. enum IdentifierType {
  551. IDENTIFIER_FUNCTION,
  552. IDENTIFIER_UNIFORM,
  553. IDENTIFIER_VARYING,
  554. IDENTIFIER_FUNCTION_ARGUMENT,
  555. IDENTIFIER_LOCAL_VAR,
  556. IDENTIFIER_BUILTIN_VAR,
  557. };
  558. bool _find_identifier(const BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type = NULL, IdentifierType *r_type = NULL);
  559. bool _is_operator_assign(Operator p_op) const;
  560. bool _validate_assign(Node *p_node, const Map<StringName, BuiltInInfo> &p_builtin_types, String *r_message = NULL);
  561. bool _validate_operator(OperatorNode *p_op, DataType *r_ret_type = NULL);
  562. struct BuiltinFuncDef {
  563. enum { MAX_ARGS = 5 };
  564. const char *name;
  565. DataType rettype;
  566. const DataType args[MAX_ARGS];
  567. };
  568. struct BuiltinFuncOutArgs { //arguments used as out in built in functions
  569. const char *name;
  570. int argument;
  571. };
  572. CompletionType completion_type;
  573. int completion_line;
  574. BlockNode *completion_block;
  575. DataType completion_base;
  576. StringName completion_function;
  577. int completion_argument;
  578. bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier);
  579. static const BuiltinFuncDef builtin_func_defs[];
  580. static const BuiltinFuncOutArgs builtin_func_out_args[];
  581. bool _validate_function_call(BlockNode *p_block, OperatorNode *p_func, DataType *r_ret_type);
  582. bool _parse_function_arguments(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg = NULL);
  583. Node *_parse_expression(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types);
  584. ShaderLanguage::Node *_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node);
  585. Node *_parse_and_reduce_expression(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types);
  586. Error _parse_block(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, bool p_just_one = false, bool p_can_break = false, bool p_can_continue = false);
  587. Error _parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types);
  588. public:
  589. //static void get_keyword_list(ShaderType p_type,List<String> *p_keywords);
  590. void clear();
  591. static String get_shader_type(const String &p_code);
  592. Error compile(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types);
  593. Error complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, List<String> *r_options, String &r_call_hint);
  594. String get_error_text();
  595. int get_error_line();
  596. ShaderNode *get_shader();
  597. String token_debug(const String &p_code);
  598. ShaderLanguage();
  599. ~ShaderLanguage();
  600. };
  601. #endif // SHADER_LANGUAGE_H