mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-30 21:21:10 +00:00 
			
		
		
		
	Allow declaring multiple members in one expression in shader structs
This commit is contained in:
		
							parent
							
								
									c03a5ba09c
								
							
						
					
					
						commit
						31cc6ba622
					
				
					 1 changed files with 54 additions and 40 deletions
				
			
		|  | @ -7648,22 +7648,31 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct | ||||||
| 							_set_error("void datatype not allowed here"); | 							_set_error("void datatype not allowed here"); | ||||||
| 							return ERR_PARSE_ERROR; | 							return ERR_PARSE_ERROR; | ||||||
| 						} | 						} | ||||||
|  | 
 | ||||||
|  | 						bool first = true; | ||||||
|  | 						bool fixed_array_size = false; | ||||||
|  | 						int array_size = 0; | ||||||
|  | 
 | ||||||
|  | 						do { | ||||||
| 							tk = _get_token(); | 							tk = _get_token(); | ||||||
| 
 | 
 | ||||||
|  | 							if (first) { | ||||||
|  | 								first = false; | ||||||
|  | 
 | ||||||
| 								if (tk.type != TK_IDENTIFIER && tk.type != TK_BRACKET_OPEN) { | 								if (tk.type != TK_IDENTIFIER && tk.type != TK_BRACKET_OPEN) { | ||||||
| 									_set_error("Expected identifier or '['."); | 									_set_error("Expected identifier or '['."); | ||||||
| 									return ERR_PARSE_ERROR; | 									return ERR_PARSE_ERROR; | ||||||
| 								} | 								} | ||||||
| 
 | 
 | ||||||
| 						int array_size = 0; |  | ||||||
| 
 |  | ||||||
| 								if (tk.type == TK_BRACKET_OPEN) { | 								if (tk.type == TK_BRACKET_OPEN) { | ||||||
| 									Error error = _parse_global_array_size(array_size, constants); | 									Error error = _parse_global_array_size(array_size, constants); | ||||||
| 									if (error != OK) { | 									if (error != OK) { | ||||||
| 										return error; | 										return error; | ||||||
| 									} | 									} | ||||||
|  | 									fixed_array_size = true; | ||||||
| 									tk = _get_token(); | 									tk = _get_token(); | ||||||
| 								} | 								} | ||||||
|  | 							} | ||||||
| 
 | 
 | ||||||
| 							if (tk.type != TK_IDENTIFIER) { | 							if (tk.type != TK_IDENTIFIER) { | ||||||
| 								_set_error("Expected identifier!"); | 								_set_error("Expected identifier!"); | ||||||
|  | @ -7692,13 +7701,18 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct | ||||||
| 								tk = _get_token(); | 								tk = _get_token(); | ||||||
| 							} | 							} | ||||||
| 
 | 
 | ||||||
| 						if (tk.type != TK_SEMICOLON) { | 							if (!fixed_array_size) { | ||||||
| 							_set_error("Expected ';'"); | 								array_size = 0; | ||||||
|  | 							} | ||||||
|  | 
 | ||||||
|  | 							if (tk.type != TK_SEMICOLON && tk.type != TK_COMMA) { | ||||||
|  | 								_set_error("Expected ',' or ';' after struct member."); | ||||||
| 								return ERR_PARSE_ERROR; | 								return ERR_PARSE_ERROR; | ||||||
| 							} | 							} | ||||||
| 
 | 
 | ||||||
| 							st_node->members.push_back(member); | 							st_node->members.push_back(member); | ||||||
| 							member_count++; | 							member_count++; | ||||||
|  | 						} while (tk.type == TK_COMMA); // another member
 | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				if (member_count == 0) { | 				if (member_count == 0) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yuri Roubinsky
						Yuri Roubinsky