From 61745855d0bb309cb0ebcd2d92fc15f7f6fb1840 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 2 Jan 2016 17:56:45 -0300 Subject: PI is now a built-in constant, fixes #2134 --- modules/gdscript/gd_parser.cpp | 7 +++++++ modules/gdscript/gd_tokenizer.cpp | 4 +++- modules/gdscript/gd_tokenizer.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 73264b0a12..c4175e048d 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -267,6 +267,13 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ constant->value=tokenizer->get_token_constant(); tokenizer->advance(); expr=constant; + } else if (tokenizer->get_token()==GDTokenizer::TK_CONST_PI) { + + //constant defined by tokenizer + ConstantNode *constant = alloc_node(); + constant->value=Math_PI; + tokenizer->advance(); + expr=constant; } else if (tokenizer->get_token()==GDTokenizer::TK_PR_PRELOAD) { //constant defined by tokenizer diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 61738146ae..4280c47edf 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -111,6 +111,7 @@ const char* GDTokenizer::token_names[TK_MAX]={ "'?'", "':'", "'\\n'", +"PI", "Error", "EOF", "Cursor"}; @@ -878,6 +879,7 @@ void GDTokenizerText::_advance() { {TK_CF_RETURN,"return"}, {TK_CF_PASS,"pass"}, {TK_SELF,"self"}, + {TK_CONST_PI,"PI"}, {TK_ERROR,NULL} }; @@ -1044,7 +1046,7 @@ void GDTokenizerText::advance(int p_amount) { ////////////////////////////////////////////////////////////////////////////////////////////////////// -#define BYTECODE_VERSION 8 +#define BYTECODE_VERSION 9 Error GDTokenizerBuffer::set_code_buffer(const Vector & p_buffer) { diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h index bbd1ec5b72..aaff573090 100644 --- a/modules/gdscript/gd_tokenizer.h +++ b/modules/gdscript/gd_tokenizer.h @@ -119,6 +119,7 @@ public: TK_QUESTION_MARK, TK_COLON, TK_NEWLINE, + TK_CONST_PI, TK_ERROR, TK_EOF, TK_CURSOR, //used for code completion -- cgit v1.2.3