Mon, 30 Jul 2012 03:38:02 +0300
Added if() support
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * botc source code |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2012 Santeri `Dusk` Piippo |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * All rights reserved. |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright notice, |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * this list of conditions and the following disclaimer. |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * this list of conditions and the following disclaimer in the documentation |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * and/or other materials provided with the distribution. |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * 3. Neither the name of the developer nor the names of its contributors may |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * be used to endorse or promote products derived from this software without |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * specific prior written permission. |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | * 4. Redistributions in any form must be accompanied by information on how to |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | * obtain complete source code for the software and any accompanying |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | * software that uses the software. The source code must either be included |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | * in the distribution or be available for no more than the cost of |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | * distribution plus a nominal fee, and must be freely redistributable |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | * under reasonable conditions. For an executable file, complete source |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | * code means the source code for all modules it contains. It does not |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | * include source code for modules or files that typically accompany the |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | * major components of the operating system on which the executable file |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | * runs. |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | * |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | * POSSIBILITY OF SUCH DAMAGE. |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | */ |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | #define __VARIABLES_CXX__ |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | #include <stdio.h> |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | #include <stdlib.h> |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | #include <string.h> |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | #include "common.h" |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | #include "bots.h" |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | #include "botcommands.h" |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | #include "objwriter.h" |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | #include "stringtable.h" |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | #include "variables.h" |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | #include "scriptreader.h" |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | ScriptVar* g_GlobalVariables[MAX_SCRIPT_VARIABLES]; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | ScriptVar* g_LocalVariable; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | void InitVariables () { |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | unsigned int u; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | ITERATE_GLOBAL_VARS (u) |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | g_GlobalVariables[u] = NULL; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | } |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
62 | // ============================================================================ |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | // Tries to declare a new global-scope variable. Returns pointer |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | // to new global variable, NULL if declaration failed. |
24
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
65 | ScriptVar* DeclareGlobalVariable (ScriptReader* r, str name) { |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
66 | // Check that the name is valid |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
67 | if (FindCommand (name)) |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
68 | r->ParserError ("name of variable-to-be `%s` conflicts with that of a command", name.chars()); |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
69 | |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
70 | if (IsKeyword (name)) |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
71 | r->ParserError ("name of variable-to-be `%s` is a keyword", name.chars()); |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
72 | |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | // Find a NULL pointer to a global variable |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | ScriptVar* g; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | unsigned int u = 0; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | ITERATE_GLOBAL_VARS (u) { |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | // Check that it doesn't exist already |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | if (!g_GlobalVariables[u]) |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | break; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | if (!g_GlobalVariables[u]->name.icompare (name)) |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
82 | r->ParserError ("attempted redeclaration of variable `%s`", name.chars()); |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | } |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | if (u == MAX_SCRIPT_VARIABLES) |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | r->ParserError ("too many global variables!"); |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | g = new ScriptVar; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | g->index = u; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | g->name = name; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | g->statename = ""; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | g->next = NULL; |
24
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
93 | g->value = 0; |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | g_GlobalVariables[u] = g; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | return g; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | } |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
99 | /* |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
100 | void AssignScriptVariable (ScriptReader* r, str name, str value) { |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | ScriptVar* g = FindScriptVariable (name); |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | if (!g) |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | r->ParserError ("global variable %s not declared", name.chars()); |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
104 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
105 | */ |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
107 | // ============================================================================ |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | // Find a global variable by name |
24
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
109 | ScriptVar* FindGlobalVariable (str name) { |
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
110 | unsigned int u = 0; |
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
111 | ITERATE_GLOBAL_VARS (u) { |
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
112 | ScriptVar* g = g_GlobalVariables[u]; |
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
113 | if (!g) |
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
114 | return NULL; |
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
115 | |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | if (!g->name.compare (name)) |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | return g; |
24
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
118 | } |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | return NULL; |
24
7dcc8419dbdb
Variables can now be assigned values, unfortunately not at top level.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
121 | } |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
123 | // ============================================================================ |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
124 | // Count all declared global variables |
23
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | unsigned int CountGlobalVars () { |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | unsigned int count = 0; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | unsigned int u = 0; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | ITERATE_GLOBAL_VARS (u) { |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | if (g_GlobalVariables[u] != NULL) |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | count++; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | } |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | return count; |
ba351235688e
Forgot the actual new code files out of previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | } |