You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Replace NULL with nullptr
This commit is contained in:
@@ -328,7 +328,7 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = {
|
||||
{ TK_REPEAT_ENABLE, "repeat_enable" },
|
||||
{ TK_REPEAT_DISABLE, "repeat_disable" },
|
||||
{ TK_SHADER_TYPE, "shader_type" },
|
||||
{ TK_ERROR, NULL }
|
||||
{ TK_ERROR, nullptr }
|
||||
};
|
||||
|
||||
ShaderLanguage::Token ShaderLanguage::_get_token() {
|
||||
@@ -879,7 +879,7 @@ void ShaderLanguage::clear() {
|
||||
current_function = StringName();
|
||||
|
||||
completion_type = COMPLETION_NONE;
|
||||
completion_block = NULL;
|
||||
completion_block = nullptr;
|
||||
completion_function = StringName();
|
||||
completion_class = SubClassTag::TAG_GLOBAL;
|
||||
completion_struct = StringName();
|
||||
@@ -913,7 +913,7 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea
|
||||
return true;
|
||||
}
|
||||
|
||||
FunctionNode *function = NULL;
|
||||
FunctionNode *function = nullptr;
|
||||
|
||||
while (p_block) {
|
||||
|
||||
@@ -2107,14 +2107,14 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = {
|
||||
//array
|
||||
{ "length", TYPE_INT, { TYPE_VOID }, TAG_ARRAY, true },
|
||||
|
||||
{ NULL, TYPE_VOID, { TYPE_VOID }, TAG_GLOBAL, false }
|
||||
{ nullptr, TYPE_VOID, { TYPE_VOID }, TAG_GLOBAL, false }
|
||||
|
||||
};
|
||||
|
||||
const ShaderLanguage::BuiltinFuncOutArgs ShaderLanguage::builtin_func_out_args[] = {
|
||||
//constructors
|
||||
{ "modf", 1 },
|
||||
{ NULL, 0 }
|
||||
{ nullptr, 0 }
|
||||
};
|
||||
|
||||
bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str) {
|
||||
@@ -3150,7 +3150,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
while (true) {
|
||||
|
||||
Node *expr = NULL;
|
||||
Node *expr = nullptr;
|
||||
TkPos prepos = _get_tkpos();
|
||||
Token tk = _get_token();
|
||||
TkPos pos = _get_tkpos();
|
||||
@@ -3162,14 +3162,14 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
expr = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
if (!expr)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
tk = _get_token();
|
||||
|
||||
if (tk.type != TK_PARENTHESIS_CLOSE) {
|
||||
|
||||
_set_error("Expected ')' in expression");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} else if (tk.type == TK_REAL_CONSTANT) {
|
||||
@@ -3214,7 +3214,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
//make sure void is not used in expression
|
||||
_set_error("Void value not allowed in Expression");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else if (is_token_nonvoid_datatype(tk.type)) {
|
||||
//basic type constructor
|
||||
|
||||
@@ -3234,7 +3234,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
tk = _get_token();
|
||||
if (tk.type != TK_PARENTHESIS_OPEN) {
|
||||
_set_error("Expected '(' after type name");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int carg = -1;
|
||||
@@ -3250,11 +3250,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (!_validate_function_call(p_block, p_builtin_types, func, &func->return_cache, &func->struct_name)) {
|
||||
_set_error("No matching constructor found for: '" + String(funcname->name) + "'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
expr = _reduce_expression(p_block, func);
|
||||
@@ -3265,7 +3265,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
StringName identifier;
|
||||
|
||||
StructNode *pstruct = NULL;
|
||||
StructNode *pstruct = nullptr;
|
||||
bool struct_init = false;
|
||||
|
||||
_get_completable_identifier(p_block, COMPLETION_IDENTIFIER, identifier);
|
||||
@@ -3317,7 +3317,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
} else {
|
||||
if (!is_token_variable_datatype(tk.type)) {
|
||||
_set_error("Invalid data type for array");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
type2 = get_token_datatype(tk.type);
|
||||
}
|
||||
@@ -3335,7 +3335,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
if (!n || n->type != Node::TYPE_CONSTANT || n->get_datatype() != TYPE_INT) {
|
||||
_set_error("Expected single integer constant > 0");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ConstantNode *cnode = (ConstantNode *)n;
|
||||
@@ -3343,24 +3343,24 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
array_size2 = cnode->values[0].sint;
|
||||
if (array_size2 <= 0) {
|
||||
_set_error("Expected single integer constant > 0");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
_set_error("Expected single integer constant > 0");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tk = _get_token();
|
||||
if (tk.type != TK_BRACKET_CLOSE) {
|
||||
_set_error("Expected ']'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
tk = _get_token();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_set_error("Expected '['");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (type != type2 || struct_name != struct_name2 || array_size != array_size2) {
|
||||
@@ -3383,7 +3383,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
error_str += itos(array_size);
|
||||
error_str += "]'";
|
||||
_set_error(error_str);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3396,12 +3396,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
if (!n) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (type != n->get_datatype() || struct_name != n->get_datatype_name()) {
|
||||
_set_error("Invalid assignment of '" + (n->get_datatype() == TYPE_STRUCT ? n->get_datatype_name() : get_datatype_name(n->get_datatype())) + "' to '" + (type == TYPE_STRUCT ? struct_name : get_datatype_name(type)) + "'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tk = _get_token();
|
||||
@@ -3419,30 +3419,30 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
_set_error("Expected '}' or ','");
|
||||
else
|
||||
_set_error("Expected ')' or ','");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (an->initializer.size() != array_size) {
|
||||
_set_error("Array size mismatch");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
_set_error("Expected array initialization!");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nexpr = an;
|
||||
} else {
|
||||
nexpr = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
if (!nexpr) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Node *node = pstruct->members[i];
|
||||
if (!_compare_datatypes_in_nodes(pstruct->members[i], nexpr)) {
|
||||
String type_name = nexpr->get_datatype() == TYPE_STRUCT ? nexpr->get_datatype_name() : get_datatype_name(nexpr->get_datatype());
|
||||
String type_name2 = node->get_datatype() == TYPE_STRUCT ? node->get_datatype_name() : get_datatype_name(node->get_datatype());
|
||||
_set_error("Invalid assignment of '" + type_name + "' to '" + type_name2 + "'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3450,7 +3450,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
tk = _get_token();
|
||||
if (tk.type != TK_COMMA) {
|
||||
_set_error("Expected ','");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
func->arguments.push_back(nexpr);
|
||||
@@ -3458,7 +3458,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
tk = _get_token();
|
||||
if (tk.type != TK_PARENTHESIS_CLOSE) {
|
||||
_set_error("Expected ')'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
expr = func;
|
||||
@@ -3482,7 +3482,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
while (bnode) {
|
||||
if (bnode->variables.has(name)) {
|
||||
_set_error("Expected function name");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
bnode = bnode->parent_block;
|
||||
}
|
||||
@@ -3514,11 +3514,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (!_validate_function_call(p_block, p_builtin_types, func, &func->return_cache, &func->struct_name)) {
|
||||
_set_error("No matching function found for: '" + String(funcname->name) + "'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
completion_class = TAG_GLOBAL; // reset sub-class
|
||||
if (function_index >= 0) {
|
||||
@@ -3529,7 +3529,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
if (call_function) {
|
||||
|
||||
//get current base function
|
||||
FunctionNode *base_function = NULL;
|
||||
FunctionNode *base_function = nullptr;
|
||||
{
|
||||
BlockNode *b = p_block;
|
||||
|
||||
@@ -3544,7 +3544,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!base_function, NULL); //bug, wtf
|
||||
ERR_FAIL_COND_V(!base_function, nullptr); //bug, wtf
|
||||
|
||||
for (int i = 0; i < call_function->arguments.size(); i++) {
|
||||
int argidx = i + 1;
|
||||
@@ -3556,7 +3556,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
error = true;
|
||||
} else if (n->type == Node::TYPE_ARRAY) {
|
||||
ArrayNode *an = static_cast<ArrayNode *>(n);
|
||||
if (an->call_expression != NULL) {
|
||||
if (an->call_expression != nullptr) {
|
||||
error = true;
|
||||
}
|
||||
} else if (n->type == Node::TYPE_VARIABLE) {
|
||||
@@ -3584,7 +3584,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
if (error) {
|
||||
_set_error(vformat("Constant value cannot be passed for '%s' parameter!", _get_qualifier_str(call_function->arguments[i].qualifier)));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (is_sampler_type(call_function->arguments[i].type)) {
|
||||
@@ -3599,12 +3599,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
ERR_CONTINUE(u->type != call_function->arguments[i].type); //this should have been validated previously
|
||||
//propagate
|
||||
if (!_propagate_function_call_sampler_uniform_settings(name, i, u->filter, u->repeat)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
} else if (p_builtin_types.has(varname)) {
|
||||
//a built-in
|
||||
if (!_propagate_function_call_sampler_builtin_reference(name, i, varname)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
//or this comes from an argument, but nothing else can be a sampler
|
||||
@@ -3653,30 +3653,30 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
if (!found) {
|
||||
_set_error("Unknown identifier in expression: " + String(identifier));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!_find_identifier(p_block, false, p_builtin_types, identifier, &data_type, &ident_type, &is_const, &array_size, &struct_name)) {
|
||||
_set_error("Unknown identifier in expression: " + String(identifier));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (ident_type == IDENTIFIER_FUNCTION) {
|
||||
_set_error("Can't use function as identifier: " + String(identifier));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Node *index_expression = NULL;
|
||||
Node *call_expression = NULL;
|
||||
Node *index_expression = nullptr;
|
||||
Node *call_expression = nullptr;
|
||||
|
||||
if (array_size > 0) {
|
||||
tk = _get_token();
|
||||
|
||||
if (tk.type != TK_BRACKET_OPEN && tk.type != TK_PERIOD) {
|
||||
_set_error("Expected '[' or '.'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (tk.type == TK_PERIOD) {
|
||||
@@ -3685,17 +3685,17 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
call_expression = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
p_block->block_tag = SubClassTag::TAG_GLOBAL;
|
||||
if (!call_expression)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
data_type = call_expression->get_datatype();
|
||||
} else { // indexing
|
||||
|
||||
index_expression = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
if (!index_expression)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (index_expression->get_datatype() != TYPE_INT && index_expression->get_datatype() != TYPE_UINT) {
|
||||
_set_error("Only integer expressions are allowed for indexing");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (index_expression->type == Node::TYPE_CONSTANT) {
|
||||
@@ -3705,7 +3705,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
int value = cnode->values[0].sint;
|
||||
if (value < 0 || value >= array_size) {
|
||||
_set_error(vformat("Index [%s] out of range [%s..%s]", value, 0, array_size - 1));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3714,7 +3714,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
tk = _get_token();
|
||||
if (tk.type != TK_BRACKET_CLOSE) {
|
||||
_set_error("Expected ']'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3750,18 +3750,18 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
case TK_OP_BIT_INVERT: e.op = OP_BIT_INVERT; break;
|
||||
case TK_OP_INCREMENT: e.op = OP_INCREMENT; break;
|
||||
case TK_OP_DECREMENT: e.op = OP_DECREMENT; break;
|
||||
default: ERR_FAIL_V(NULL);
|
||||
default: ERR_FAIL_V(nullptr);
|
||||
}
|
||||
|
||||
expression.push_back(e);
|
||||
continue;
|
||||
} else {
|
||||
_set_error("Expected expression, found: " + get_token_text(tk));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
//nothing
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!expr, NULL);
|
||||
ERR_FAIL_COND_V(!expr, nullptr);
|
||||
|
||||
/* OK now see what's NEXT to the operator.. */
|
||||
/* OK now see what's NEXT to the operator.. */
|
||||
@@ -3791,7 +3791,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
if (identifier == StringName()) {
|
||||
_set_error("Expected identifier as member");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
String ident = identifier;
|
||||
|
||||
@@ -4042,12 +4042,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
if (mix_error) {
|
||||
_set_error("Cannot combine symbols from different sets in expression ." + ident);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
_set_error("Invalid member for " + (dt == TYPE_STRUCT ? st : get_datatype_name(dt)) + " expression: ." + ident);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MemberNode *mn = alloc_node<MemberNode>();
|
||||
@@ -4066,16 +4066,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
tk = _get_token();
|
||||
if (tk.type == TK_PERIOD) {
|
||||
_set_error("Nested array length() is not yet implemented");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else if (tk.type == TK_BRACKET_OPEN) {
|
||||
|
||||
Node *index_expression = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
if (!index_expression)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (index_expression->get_datatype() != TYPE_INT && index_expression->get_datatype() != TYPE_UINT) {
|
||||
_set_error("Only integer expressions are allowed for indexing");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (index_expression->type == Node::TYPE_CONSTANT) {
|
||||
@@ -4085,7 +4085,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
int value = cnode->values[0].sint;
|
||||
if (value < 0 || value >= array_size) {
|
||||
_set_error(vformat("Index [%s] out of range [%s..%s]", value, 0, array_size - 1));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4094,13 +4094,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
tk = _get_token();
|
||||
if (tk.type != TK_BRACKET_CLOSE) {
|
||||
_set_error("Expected ']'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
mn->index_expression = index_expression;
|
||||
|
||||
} else {
|
||||
_set_error("Expected '[' or '.'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4120,11 +4120,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
Node *index = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
if (!index)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (index->get_datatype() != TYPE_INT && index->get_datatype() != TYPE_UINT) {
|
||||
_set_error("Only integer datatypes are allowed for indexing");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DataType member_type = TYPE_VOID;
|
||||
@@ -4139,7 +4139,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
|
||||
if (index_constant >= 2) {
|
||||
_set_error("Index out of range (0-1)");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4162,7 +4162,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
|
||||
if (index_constant >= 3) {
|
||||
_set_error("Index out of range (0-2)");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4184,7 +4184,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
|
||||
if (index_constant >= 4) {
|
||||
_set_error("Index out of range (0-3)");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4199,7 +4199,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
break;
|
||||
default: {
|
||||
_set_error("Object of type '" + (expr->get_datatype() == TYPE_STRUCT ? expr->get_datatype_name() : get_datatype_name(expr->get_datatype())) + "' can't be indexed");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4213,7 +4213,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
tk = _get_token();
|
||||
if (tk.type != TK_BRACKET_CLOSE) {
|
||||
_set_error("Expected ']' after indexing expression");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} else if (tk.type == TK_OP_INCREMENT || tk.type == TK_OP_DECREMENT) {
|
||||
@@ -4224,12 +4224,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
if (!_validate_operator(op, &op->return_cache)) {
|
||||
_set_error("Invalid base type for increment/decrement operator");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!_validate_assign(expr, p_builtin_types)) {
|
||||
_set_error("Invalid use of increment/decrement operator in constant expression.");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
expr = op;
|
||||
} else {
|
||||
@@ -4287,7 +4287,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
case TK_COLON: o.op = OP_SELECT_ELSE; break;
|
||||
default: {
|
||||
_set_error("Invalid token for operator: " + get_token_text(tk));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4379,7 +4379,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
break;
|
||||
|
||||
default:
|
||||
ERR_FAIL_V(NULL); //unexpected operator
|
||||
ERR_FAIL_V(nullptr); //unexpected operator
|
||||
}
|
||||
|
||||
if (priority < min_priority) {
|
||||
@@ -4392,7 +4392,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(next_op == -1, NULL);
|
||||
ERR_FAIL_COND_V(next_op == -1, nullptr);
|
||||
|
||||
// OK! create operator..
|
||||
// OK! create operator..
|
||||
@@ -4405,7 +4405,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
if (expr_pos == expression.size()) {
|
||||
//can happen..
|
||||
_set_error("Unexpected end of expression...");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4417,7 +4417,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
if ((op->op == OP_INCREMENT || op->op == OP_DECREMENT) && !_validate_assign(expression[i + 1].node, p_builtin_types)) {
|
||||
|
||||
_set_error("Can't use increment/decrement operator in constant expression.");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
op->arguments.push_back(expression[i + 1].node);
|
||||
|
||||
@@ -4433,7 +4433,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
at += get_datatype_name(op->arguments[j]->get_datatype());
|
||||
}
|
||||
_set_error("Invalid arguments to unary operator '" + get_operator_text(op->op) + "' :" + at);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
expression.remove(i + 1);
|
||||
}
|
||||
@@ -4442,12 +4442,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
if (next_op < 1 || next_op >= (expression.size() - 1)) {
|
||||
_set_error("Parser bug...");
|
||||
ERR_FAIL_V(NULL);
|
||||
ERR_FAIL_V(nullptr);
|
||||
}
|
||||
|
||||
if (next_op + 2 >= expression.size() || !expression[next_op + 2].is_op || expression[next_op + 2].op != OP_SELECT_ELSE) {
|
||||
_set_error("Missing matching ':' for select operator");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OperatorNode *op = alloc_node<OperatorNode>();
|
||||
@@ -4467,7 +4467,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
at += get_datatype_name(op->arguments[i]->get_datatype());
|
||||
}
|
||||
_set_error("Invalid argument to ternary ?: operator: " + at);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@@ -4478,7 +4478,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
|
||||
if (next_op < 1 || next_op >= (expression.size() - 1)) {
|
||||
_set_error("Parser bug...");
|
||||
ERR_FAIL_V(NULL);
|
||||
ERR_FAIL_V(nullptr);
|
||||
}
|
||||
|
||||
OperatorNode *op = alloc_node<OperatorNode>();
|
||||
@@ -4487,7 +4487,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
if (expression[next_op - 1].is_op) {
|
||||
|
||||
_set_error("Parser bug...");
|
||||
ERR_FAIL_V(NULL);
|
||||
ERR_FAIL_V(nullptr);
|
||||
}
|
||||
|
||||
if (_is_operator_assign(op->op)) {
|
||||
@@ -4496,7 +4496,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
if (!_validate_assign(expression[next_op - 1].node, p_builtin_types, &assign_message)) {
|
||||
|
||||
_set_error(assign_message);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4528,7 +4528,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
}
|
||||
_set_error("Invalid arguments to operator '" + get_operator_text(op->op) + "' :" + at);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
expression.remove(next_op);
|
||||
@@ -4658,7 +4658,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_and_reduce_expression(BlockNode *p_
|
||||
|
||||
ShaderLanguage::Node *expr = _parse_expression(p_block, p_builtin_types);
|
||||
if (!expr) //errored
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
expr = _reduce_expression(p_block, expr);
|
||||
|
||||
@@ -4741,7 +4741,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
||||
|
||||
tk = _get_token();
|
||||
|
||||
Node *vardecl = NULL;
|
||||
Node *vardecl = nullptr;
|
||||
|
||||
while (true) {
|
||||
|
||||
@@ -4752,7 +4752,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
||||
|
||||
StringName name = tk.text;
|
||||
ShaderLanguage::IdentifierType itype;
|
||||
if (_find_identifier(p_block, true, p_builtin_types, name, (ShaderLanguage::DataType *)0, &itype)) {
|
||||
if (_find_identifier(p_block, true, p_builtin_types, name, (ShaderLanguage::DataType *)nullptr, &itype)) {
|
||||
if (itype != IDENTIFIER_FUNCTION) {
|
||||
_set_error("Redefinition of '" + String(name) + "'");
|
||||
return ERR_PARSE_ERROR;
|
||||
@@ -5025,7 +5025,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
||||
|
||||
VariableDeclarationNode::Declaration decl;
|
||||
decl.name = name;
|
||||
decl.initializer = NULL;
|
||||
decl.initializer = nullptr;
|
||||
|
||||
//variable created with assignment! must parse an expression
|
||||
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||
@@ -5061,7 +5061,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
||||
|
||||
VariableDeclarationNode::Declaration decl;
|
||||
decl.name = name;
|
||||
decl.initializer = NULL;
|
||||
decl.initializer = nullptr;
|
||||
node->declarations.push_back(decl);
|
||||
}
|
||||
|
||||
@@ -5326,7 +5326,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
||||
// while() {}
|
||||
bool is_do = tk.type == TK_CF_DO;
|
||||
|
||||
BlockNode *do_block = NULL;
|
||||
BlockNode *do_block = nullptr;
|
||||
if (is_do) {
|
||||
|
||||
do_block = alloc_node<BlockNode>();
|
||||
@@ -5694,7 +5694,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||
while (true) {
|
||||
|
||||
StringName mode;
|
||||
_get_completable_identifier(NULL, COMPLETION_RENDER_MODE, mode);
|
||||
_get_completable_identifier(nullptr, COMPLETION_RENDER_MODE, mode);
|
||||
|
||||
if (mode == StringName()) {
|
||||
_set_error("Expected identifier for render mode");
|
||||
@@ -5898,7 +5898,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||
|
||||
name = tk.text;
|
||||
|
||||
if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) {
|
||||
if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) {
|
||||
_set_error("Redefinition of '" + String(name) + "'");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
@@ -6074,7 +6074,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||
|
||||
if (tk.type == TK_OP_ASSIGN) {
|
||||
|
||||
Node *expr = _parse_and_reduce_expression(NULL, Map<StringName, BuiltInInfo>());
|
||||
Node *expr = _parse_and_reduce_expression(nullptr, Map<StringName, BuiltInInfo>());
|
||||
if (!expr)
|
||||
return ERR_PARSE_ERROR;
|
||||
if (expr->type != Node::TYPE_CONSTANT) {
|
||||
@@ -6191,14 +6191,14 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||
}
|
||||
_set_tkpos(prev_pos);
|
||||
|
||||
_get_completable_identifier(NULL, COMPLETION_MAIN_FUNCTION, name);
|
||||
_get_completable_identifier(nullptr, COMPLETION_MAIN_FUNCTION, name);
|
||||
|
||||
if (name == StringName()) {
|
||||
_set_error("Expected function name after datatype");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) {
|
||||
if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) {
|
||||
_set_error("Redefinition of '" + String(name) + "'");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
@@ -6222,7 +6222,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||
constant.type = is_struct ? TYPE_STRUCT : type;
|
||||
constant.type_str = struct_name;
|
||||
constant.precision = precision;
|
||||
constant.initializer = NULL;
|
||||
constant.initializer = nullptr;
|
||||
|
||||
if (tk.type == TK_OP_ASSIGN) {
|
||||
|
||||
@@ -6232,7 +6232,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||
}
|
||||
|
||||
//variable created with assignment! must parse an expression
|
||||
Node *expr = _parse_and_reduce_expression(NULL, Map<StringName, BuiltInInfo>());
|
||||
Node *expr = _parse_and_reduce_expression(nullptr, Map<StringName, BuiltInInfo>());
|
||||
if (!expr)
|
||||
return ERR_PARSE_ERROR;
|
||||
if (expr->type == Node::TYPE_OPERATOR && ((OperatorNode *)expr)->op == OP_CALL) {
|
||||
@@ -6266,7 +6266,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||
}
|
||||
|
||||
name = tk.text;
|
||||
if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) {
|
||||
if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) {
|
||||
_set_error("Redefinition of '" + String(name) + "'");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
@@ -6405,7 +6405,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||
pname = tk.text;
|
||||
|
||||
ShaderLanguage::IdentifierType itype;
|
||||
if (_find_identifier(func_node->body, false, builtin_types, pname, (ShaderLanguage::DataType *)0, &itype)) {
|
||||
if (_find_identifier(func_node->body, false, builtin_types, pname, (ShaderLanguage::DataType *)nullptr, &itype)) {
|
||||
if (itype != IDENTIFIER_FUNCTION) {
|
||||
_set_error("Redefinition of '" + String(pname) + "'");
|
||||
return ERR_PARSE_ERROR;
|
||||
@@ -6645,7 +6645,7 @@ Error ShaderLanguage::compile(const String &p_code, const Map<StringName, Functi
|
||||
|
||||
code = p_code;
|
||||
|
||||
nodes = NULL;
|
||||
nodes = nullptr;
|
||||
|
||||
shader = alloc_node<ShaderNode>();
|
||||
Error err = _parse_shader(p_functions, p_render_modes, p_shader_types);
|
||||
@@ -6662,7 +6662,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
|
||||
|
||||
code = p_code;
|
||||
|
||||
nodes = NULL;
|
||||
nodes = nullptr;
|
||||
|
||||
shader = alloc_node<ShaderNode>();
|
||||
_parse_shader(p_functions, p_render_modes, p_shader_types);
|
||||
@@ -7001,7 +7001,7 @@ ShaderLanguage::ShaderNode *ShaderLanguage::get_shader() {
|
||||
|
||||
ShaderLanguage::ShaderLanguage() {
|
||||
|
||||
nodes = NULL;
|
||||
nodes = nullptr;
|
||||
completion_class = TAG_GLOBAL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user