mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Bug Fixes
-=-=-=-=- -Fixed problem with scaling shapes (#827), related to not taking scale in consideration for calculating the moment of inertia -Added support for multiline strings (or comments) using """ -Save subscene bug, properties not being saved in root node (#806) -Fix Crash in CollisionPolygon2DEditor (#814) -Restored Ability to compile without 3D (#795) -Fix InterpolatedCamera (#803) -Fix UV Import for OBJ Meshes (#771) -Fixed issue with modifier gizmos (#794) -Fixed CapsuleShape gizmo handle (#50) -Fixed Import Button (not properly working in 3D) (#733) -Many misc fixes (though no new features)
This commit is contained in:
@@ -65,18 +65,18 @@ bool GDCompiler::_create_unary_operator(CodeGen& codegen,const GDParser::Operato
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GDCompiler::_create_binary_operator(CodeGen& codegen,const GDParser::OperatorNode *on,Variant::Operator op, int p_stack_level) {
|
||||
bool GDCompiler::_create_binary_operator(CodeGen& codegen,const GDParser::OperatorNode *on,Variant::Operator op, int p_stack_level,bool p_initializer) {
|
||||
|
||||
ERR_FAIL_COND_V(on->arguments.size()!=2,false);
|
||||
|
||||
|
||||
int src_address_a = _parse_expression(codegen,on->arguments[0],p_stack_level);
|
||||
int src_address_a = _parse_expression(codegen,on->arguments[0],p_stack_level,false,p_initializer);
|
||||
if (src_address_a<0)
|
||||
return false;
|
||||
if (src_address_a&GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS)
|
||||
p_stack_level++; //uses stack for return, increase stack
|
||||
|
||||
int src_address_b = _parse_expression(codegen,on->arguments[1],p_stack_level);
|
||||
int src_address_b = _parse_expression(codegen,on->arguments[1],p_stack_level,false,p_initializer);
|
||||
if (src_address_b<0)
|
||||
return false;
|
||||
|
||||
@@ -111,6 +111,7 @@ int GDCompiler::_parse_assign_right_expression(CodeGen& codegen,const GDParser::
|
||||
|
||||
Variant::Operator var_op=Variant::OP_MAX;
|
||||
|
||||
|
||||
switch(p_expression->op) {
|
||||
|
||||
case GDParser::OperatorNode::OP_ASSIGN_ADD: var_op=Variant::OP_ADD; break;
|
||||
@@ -123,6 +124,7 @@ int GDCompiler::_parse_assign_right_expression(CodeGen& codegen,const GDParser::
|
||||
case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: var_op=Variant::OP_BIT_AND; break;
|
||||
case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: var_op=Variant::OP_BIT_OR; break;
|
||||
case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: var_op=Variant::OP_BIT_XOR; break;
|
||||
case GDParser::OperatorNode::OP_INIT_ASSIGN:
|
||||
case GDParser::OperatorNode::OP_ASSIGN: {
|
||||
|
||||
//none
|
||||
@@ -133,12 +135,14 @@ int GDCompiler::_parse_assign_right_expression(CodeGen& codegen,const GDParser::
|
||||
}
|
||||
}
|
||||
|
||||
bool initializer = p_expression->op==GDParser::OperatorNode::OP_INIT_ASSIGN;
|
||||
|
||||
if (var_op==Variant::OP_MAX) {
|
||||
|
||||
return _parse_expression(codegen,p_expression->arguments[1],p_stack_level);
|
||||
return _parse_expression(codegen,p_expression->arguments[1],p_stack_level,false,initializer);
|
||||
}
|
||||
|
||||
if (!_create_binary_operator(codegen,p_expression,var_op,p_stack_level))
|
||||
if (!_create_binary_operator(codegen,p_expression,var_op,p_stack_level,initializer))
|
||||
return -1;
|
||||
|
||||
int dst_addr=(p_stack_level)|(GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS);
|
||||
@@ -148,7 +152,7 @@ int GDCompiler::_parse_assign_right_expression(CodeGen& codegen,const GDParser::
|
||||
|
||||
}
|
||||
|
||||
int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expression, int p_stack_level,bool p_root) {
|
||||
int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expression, int p_stack_level,bool p_root,bool p_initializer) {
|
||||
|
||||
|
||||
switch(p_expression->type) {
|
||||
@@ -165,17 +169,16 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
|
||||
StringName identifier = in->name;
|
||||
|
||||
// TRY STACK!
|
||||
if (codegen.stack_identifiers.has(identifier)) {
|
||||
if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
|
||||
|
||||
int pos = codegen.stack_identifiers[identifier];
|
||||
return pos|(GDFunction::ADDR_TYPE_STACK_VARIABLE<<GDFunction::ADDR_BITS);
|
||||
|
||||
}
|
||||
//TRY ARGUMENTS!
|
||||
//TRY MEMBERS!
|
||||
if (!codegen.function_node || !codegen.function_node->_static) {
|
||||
|
||||
// TRY MEMBER VARIABLES!
|
||||
|
||||
//static function
|
||||
if (codegen.script->member_indices.has(identifier)) {
|
||||
|
||||
@@ -686,6 +689,7 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
|
||||
case GDParser::OperatorNode::OP_ASSIGN_BIT_AND:
|
||||
case GDParser::OperatorNode::OP_ASSIGN_BIT_OR:
|
||||
case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR:
|
||||
case GDParser::OperatorNode::OP_INIT_ASSIGN:
|
||||
case GDParser::OperatorNode::OP_ASSIGN: {
|
||||
|
||||
ERR_FAIL_COND_V(on->arguments.size()!=2,-1);
|
||||
@@ -843,7 +847,7 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
|
||||
|
||||
int slevel = p_stack_level;
|
||||
|
||||
int dst_address_a = _parse_expression(codegen,on->arguments[0],slevel);
|
||||
int dst_address_a = _parse_expression(codegen,on->arguments[0],slevel,false,on->op==GDParser::OperatorNode::OP_INIT_ASSIGN);
|
||||
if (dst_address_a<0)
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -153,11 +153,11 @@ class GDCompiler {
|
||||
void _set_error(const String& p_error,const GDParser::Node *p_node);
|
||||
|
||||
bool _create_unary_operator(CodeGen& codegen,const GDParser::OperatorNode *on,Variant::Operator op, int p_stack_level);
|
||||
bool _create_binary_operator(CodeGen& codegen,const GDParser::OperatorNode *on,Variant::Operator op, int p_stack_level);
|
||||
bool _create_binary_operator(CodeGen& codegen,const GDParser::OperatorNode *on,Variant::Operator op, int p_stack_level,bool p_initializer=false);
|
||||
|
||||
//int _parse_subexpression(CodeGen& codegen,const GDParser::BlockNode *p_block,const GDParser::Node *p_expression);
|
||||
int _parse_assign_right_expression(CodeGen& codegen,const GDParser::OperatorNode *p_expression, int p_stack_level);
|
||||
int _parse_expression(CodeGen& codegen,const GDParser::Node *p_expression, int p_stack_level,bool p_root=false);
|
||||
int _parse_expression(CodeGen& codegen,const GDParser::Node *p_expression, int p_stack_level,bool p_root=false,bool p_initializer=false);
|
||||
Error _parse_block(CodeGen& codegen,const GDParser::BlockNode *p_block,int p_stack_level=0,int p_break_addr=-1,int p_continue_addr=-1);
|
||||
Error _parse_function(GDScript *p_script,const GDParser::ClassNode *p_class,const GDParser::FunctionNode *p_func);
|
||||
Error _parse_class(GDScript *p_script,GDScript *p_owner,const GDParser::ClassNode *p_class);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
|
||||
|
||||
p_delimiters->push_back("#");
|
||||
p_delimiters->push_back("\"\"\"");
|
||||
|
||||
}
|
||||
void GDScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
|
||||
|
||||
@@ -2429,7 +2429,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
||||
id->name=member.identifier;
|
||||
|
||||
OperatorNode *op = alloc_node<OperatorNode>();
|
||||
op->op=OperatorNode::OP_ASSIGN;
|
||||
op->op=OperatorNode::OP_INIT_ASSIGN;
|
||||
op->arguments.push_back(id);
|
||||
op->arguments.push_back(subexpr);
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ public:
|
||||
OP_MOD,
|
||||
OP_SHIFT_LEFT,
|
||||
OP_SHIFT_RIGHT,
|
||||
OP_INIT_ASSIGN,
|
||||
OP_ASSIGN,
|
||||
OP_ASSIGN_ADD,
|
||||
OP_ASSIGN_SUB,
|
||||
|
||||
@@ -2448,6 +2448,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
|
||||
"if" ,
|
||||
"in" ,
|
||||
"null" ,
|
||||
"not" ,
|
||||
"return" ,
|
||||
"self" ,
|
||||
"while" ,
|
||||
|
||||
@@ -239,8 +239,7 @@ void GDTokenizerText::_advance() {
|
||||
|
||||
|
||||
bool is_node_path = false;
|
||||
bool is_string = false;
|
||||
bool is_string_alt = false;
|
||||
StringMode string_mode=STRING_DOUBLE_QUOTE;
|
||||
|
||||
switch(GETCHAR(0)) {
|
||||
case 0:
|
||||
@@ -538,22 +537,35 @@ void GDTokenizerText::_advance() {
|
||||
is_node_path=true;
|
||||
|
||||
case '\'':
|
||||
is_string_alt = true;
|
||||
string_mode=STRING_SINGLE_QUOTE;
|
||||
case '"': {
|
||||
is_string = is_string_alt ? false : true;
|
||||
|
||||
int i=1;
|
||||
if (string_mode==STRING_DOUBLE_QUOTE && GETCHAR(i)=='"' && GETCHAR(i+1)=='"') {
|
||||
i+=2;
|
||||
string_mode=STRING_MULTILINE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
String str;
|
||||
while(true) {
|
||||
if (CharType(GETCHAR(i)==0)) {
|
||||
if (CharType(GETCHAR(i))==0) {
|
||||
|
||||
_make_error("Unterminated String");
|
||||
return;
|
||||
} else if( CharType(GETCHAR(i)=='"') && is_string ) {
|
||||
} else if( string_mode==STRING_DOUBLE_QUOTE && CharType(GETCHAR(i))=='"' ) {
|
||||
break;
|
||||
} else if( CharType(GETCHAR(i)=='\'') && is_string_alt ) {
|
||||
break;
|
||||
} else if (CharType(GETCHAR(i)=='\\')) {
|
||||
} else if( string_mode==STRING_SINGLE_QUOTE && CharType(GETCHAR(i))=='\'' ) {
|
||||
break;
|
||||
} else if( string_mode==STRING_MULTILINE && CharType(GETCHAR(i))=='\"' && CharType(GETCHAR(i+1))=='\"' && CharType(GETCHAR(i+2))=='\"') {
|
||||
i+=2;
|
||||
break;
|
||||
} else if( string_mode!=STRING_MULTILINE && CharType(GETCHAR(i))=='\n') {
|
||||
_make_error("Unexpected EOL at String.");
|
||||
return;
|
||||
|
||||
} else if (CharType(GETCHAR(i))=='\\') {
|
||||
//escaped characters...
|
||||
i++;
|
||||
CharType next = GETCHAR(i);
|
||||
|
||||
@@ -122,6 +122,13 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
enum StringMode {
|
||||
STRING_SINGLE_QUOTE,
|
||||
STRING_DOUBLE_QUOTE,
|
||||
STRING_MULTILINE
|
||||
};
|
||||
|
||||
static const char* token_names[TK_MAX];
|
||||
public:
|
||||
static const char *get_token_name(Token p_token);
|
||||
|
||||
Reference in New Issue
Block a user