summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-11-02 11:31:01 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-11-02 11:31:01 -0300
commitd85b67be53bac252c0a28b799d56d1b359c4ee99 (patch)
tree5227e145e3271bfee542bdd3e4237c3378565306 /modules
parent738eb2c1a88d441eacc4149ce8f1c12a90267191 (diff)
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)
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gd_compiler.cpp24
-rw-r--r--modules/gdscript/gd_compiler.h4
-rw-r--r--modules/gdscript/gd_editor.cpp1
-rw-r--r--modules/gdscript/gd_parser.cpp2
-rw-r--r--modules/gdscript/gd_parser.h1
-rw-r--r--modules/gdscript/gd_script.cpp1
-rw-r--r--modules/gdscript/gd_tokenizer.cpp30
-rw-r--r--modules/gdscript/gd_tokenizer.h7
8 files changed, 48 insertions, 22 deletions
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index 4c56468297..5595db95de 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -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;
diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h
index cda221dab0..b83d0ded4b 100644
--- a/modules/gdscript/gd_compiler.h
+++ b/modules/gdscript/gd_compiler.h
@@ -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);
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index d1f511b46e..b1db087fb3 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -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 {
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 659e19a9d0..dc6b0ff962 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -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);
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index 16a9a85290..5fac34396c 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -215,6 +215,7 @@ public:
OP_MOD,
OP_SHIFT_LEFT,
OP_SHIFT_RIGHT,
+ OP_INIT_ASSIGN,
OP_ASSIGN,
OP_ASSIGN_ADD,
OP_ASSIGN_SUB,
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index b20fc51a03..8738185d41 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -2448,6 +2448,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
"if" ,
"in" ,
"null" ,
+ "not" ,
"return" ,
"self" ,
"while" ,
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp
index 0fa83b9eb4..0f6ee41616 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gd_tokenizer.cpp
@@ -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);
diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h
index 4f9522fb56..fe7bfa73ca 100644
--- a/modules/gdscript/gd_tokenizer.h
+++ b/modules/gdscript/gd_tokenizer.h
@@ -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);