summaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_compiler.h
diff options
context:
space:
mode:
authorBil Bas (Spooner) <bil.bagpuss@gmail.com>2015-02-01 20:29:11 +0000
committerBil Bas (Spooner) <bil.bagpuss@gmail.com>2015-02-01 20:29:11 +0000
commit2c1a3dfed6f9a474ace9123b46edca77be548d3e (patch)
treee1cd0db9257a5a241a1db3906041dbb9c1295c74 /modules/gdscript/gd_compiler.h
parentaf7c8bdf236b7c572bc33a44e3bb64fecdaa99d9 (diff)
parent67d357191ff74b2cfc80015941363a97e7ee19fd (diff)
Merge branch 'master' of https://github.com/okamstudio/godot into add_sprintf
Diffstat (limited to 'modules/gdscript/gd_compiler.h')
-rw-r--r--modules/gdscript/gd_compiler.h122
1 files changed, 53 insertions, 69 deletions
diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h
index b83d0ded4b..0c34c23b25 100644
--- a/modules/gdscript/gd_compiler.h
+++ b/modules/gdscript/gd_compiler.h
@@ -37,77 +37,65 @@ class GDCompiler {
const GDParser *parser;
struct CodeGen {
-
-
GDScript *script;
const GDParser::ClassNode *class_node;
const GDParser::FunctionNode *function_node;
-
-
- bool debug_stack;
-
-
- List< Map<StringName,int> > stack_id_stack;
- Map<StringName,int> stack_identifiers;
-
- List<GDFunction::StackDebug> stack_debug;
- List< Map<StringName,int> > block_identifier_stack;
- Map<StringName,int> block_identifiers;
-
-
- void add_stack_identifier(const StringName& p_id,int p_stackpos) {
-
- stack_identifiers[p_id]=p_stackpos;
- if (debug_stack) {
-
- block_identifiers[p_id]=p_stackpos;
- GDFunction::StackDebug sd;
- sd.added=true;
- sd.line=current_line;
- sd.identifier=p_id;
- sd.pos=p_stackpos;
- stack_debug.push_back(sd);
- }
- }
-
- void push_stack_identifiers() {
-
- stack_id_stack.push_back( stack_identifiers );
- if (debug_stack) {
-
- block_identifier_stack.push_back(block_identifiers);
- block_identifiers.clear();
- }
- }
-
- void pop_stack_identifiers() {
-
- stack_identifiers = stack_id_stack.back()->get();
- stack_id_stack.pop_back();
-
- if (debug_stack) {
- for (Map<StringName,int>::Element *E=block_identifiers.front();E;E=E->next()) {
-
- GDFunction::StackDebug sd;
- sd.added=false;
- sd.identifier=E->key();
- sd.line=current_line;
- sd.pos=E->get();
- stack_debug.push_back(sd);
- }
- block_identifiers=block_identifier_stack.back()->get();
- block_identifier_stack.pop_back();
- }
-
- }
-
-
- // int get_identifier_pos(const StringName& p_dentifier) const;
+ bool debug_stack;
+
+ List< Map<StringName,int> > stack_id_stack;
+ Map<StringName,int> stack_identifiers;
+
+ List<GDFunction::StackDebug> stack_debug;
+ List< Map<StringName,int> > block_identifier_stack;
+ Map<StringName,int> block_identifiers;
+
+ void add_stack_identifier(const StringName& p_id,int p_stackpos) {
+ stack_identifiers[p_id]=p_stackpos;
+ if (debug_stack) {
+ block_identifiers[p_id]=p_stackpos;
+ GDFunction::StackDebug sd;
+ sd.added=true;
+ sd.line=current_line;
+ sd.identifier=p_id;
+ sd.pos=p_stackpos;
+ stack_debug.push_back(sd);
+ }
+ }
+
+ void push_stack_identifiers() {
+ stack_id_stack.push_back( stack_identifiers );
+ if (debug_stack) {
+
+ block_identifier_stack.push_back(block_identifiers);
+ block_identifiers.clear();
+ }
+ }
+
+ void pop_stack_identifiers() {
+ stack_identifiers = stack_id_stack.back()->get();
+ stack_id_stack.pop_back();
+
+ if (debug_stack) {
+ for (Map<StringName,int>::Element *E=block_identifiers.front();E;E=E->next()) {
+
+ GDFunction::StackDebug sd;
+ sd.added=false;
+ sd.identifier=E->key();
+ sd.line=current_line;
+ sd.pos=E->get();
+ stack_debug.push_back(sd);
+ }
+ block_identifiers=block_identifier_stack.back()->get();
+ block_identifier_stack.pop_back();
+ }
+ }
+
+
+ //int get_identifier_pos(const StringName& p_dentifier) const;
HashMap<Variant,int,VariantHasher> constant_map;
Map<StringName,int> name_map;
int get_name_map_pos(const StringName& p_identifier) {
-
int ret;
if (!name_map.has(p_identifier)) {
ret=name_map.size();
@@ -118,11 +106,7 @@ class GDCompiler {
return ret;
}
-
-
int get_constant_pos(const Variant& p_constant) {
-
-
if (constant_map.has(p_constant))
return constant_map[p_constant];
int pos = constant_map.size();
@@ -134,7 +118,7 @@ class GDCompiler {
void alloc_stack(int p_level) { if (p_level >= stack_max) stack_max=p_level+1; }
void alloc_call(int p_params) { if (p_params >= call_max) call_max=p_params; }
- int current_line;
+ int current_line;
int stack_max;
int call_max;
};