fprintf(fp, "%s= %s (%s) parent: %s\n", tabs, m_name.toUtf8().constData(),
spaceTypeName(m_type),
m_parent == NULL ? "<none>" : m_parent->name().toUtf8().constData());
- fprintf(fp, "%s== Classes:\n", tabs);
QList<QString> sorted;
- sorted.reserve(m_classes.size());
- ClassMap::iterator it;
- for (it = m_classes.begin(); it != m_classes.end(); it++){
- sorted.append(it.key());
- }
- qSort(sorted.begin(), sorted.end(), qLess<QString>());
- QList<QString>::iterator it2;
- for (it2 = sorted.begin(); it2 != sorted.end(); it2++){
- RplASClass* clazz = m_classes[*it2];
- clazz->dump(fp, indent);
- }
-
- fprintf(fp, "%s== Methods:\n", tabs);
- sorted.clear();
- sorted.reserve(m_variables.size());
- MethodMap::iterator it3;
- for (it3 = m_methods.begin(); it3 != m_methods.end(); it3++){
- sorted.append(it3.key());
+ if (m_classes.size() > 0){
+ fprintf(fp, "%s== Classes:\n", tabs);
+ sorted.reserve(m_classes.size());
+ ClassMap::iterator it;
+ for (it = m_classes.begin(); it != m_classes.end(); it++){
+ sorted.append(it.key());
+ }
+ qSort(sorted.begin(), sorted.end(), qLess<QString>());
+ QList<QString>::iterator it2;
+ for (it2 = sorted.begin(); it2 != sorted.end(); it2++){
+ RplASClass* clazz = m_classes[*it2];
+ clazz->dump(fp, indent);
+ }
}
- qSort(sorted.begin(), sorted.end(), qLess<QString>());
- QList<QString>::iterator it4;
- for (it4 = sorted.begin(); it4 != sorted.end(); it4++){
- RplASMethod* var = m_methods[*it4];
- var->dump(fp, indent);
+ if (m_methods.size() > 0){
+ fprintf(fp, "%s== Methods:\n", tabs);
+ sorted.clear();
+ sorted.reserve(m_variables.size());
+ MethodMap::iterator it3;
+ for (it3 = m_methods.begin(); it3 != m_methods.end(); it3++){
+ sorted.append(it3.key());
+ }
+ qSort(sorted.begin(), sorted.end(), qLess<QString>());
+ QList<QString>::iterator it4;
+ for (it4 = sorted.begin(); it4 != sorted.end(); it4++){
+ RplASMethod* method = m_methods[*it4];
+ do {
+ method->dump(fp, indent);
+ method = method->sibling();
+ } while (method != NULL);
+ }
}
- fprintf(fp, "%s== Variables:\n", tabs);
- sorted.clear();
- sorted.reserve(m_variables.size());
- VariableMap::iterator it5;
- for (it5 = m_variables.begin(); it5 != m_variables.end(); it5++){
- sorted.append(it5.key());
+ if (m_variables.size() > 0){
+ fprintf(fp, "%s== Variables:\n", tabs);
+ sorted.clear();
+ sorted.reserve(m_variables.size());
+ VariableMap::iterator it5;
+ for (it5 = m_variables.begin(); it5 != m_variables.end(); it5++){
+ sorted.append(it5.key());
+ }
+ qSort(sorted.begin(), sorted.end(), qLess<QString>());
+ QList<QString>::iterator it6;
+ for (it6 = sorted.begin(); it6 != sorted.end(); it6++){
+ RplASVarDefinition* var = m_variables[*it6];
+ var->dump(fp, indent);
+ }
}
- qSort(sorted.begin(), sorted.end(), qLess<QString>());
- QList<QString>::iterator it6;
- for (it6 = sorted.begin(); it6 != sorted.end(); it6++){
- RplASVarDefinition* var = m_variables[*it6];
- var->dump(fp, indent);
+ if (m_body != NULL){
+ fprintf(fp, "%s== Body:\n", tabs);
+ RplASNode1::dumpStatements(fp, indent, m_body);
}
-
- fprintf(fp, "%s== Body:%s\n", tabs, m_body == NULL ? " <none>" : "");
- RplASNode1::dumpStatements(fp, indent, m_body);
}
/**
else if (! m_methods.contains(name)){
m_methods[name] = method;
} else {
- RplASMethod* oldMethod = m_methods[name];
+ RplASMethod* first = m_methods[name];
+ RplASMethod* oldMethod = first;
do {
if (oldMethod->equalSignature(*method))
rc = oldMethod;
else
oldMethod = oldMethod->sibling();
} while (rc == NULL && oldMethod != NULL);
- if (rc == NULL)
+ if (rc == NULL){
+ method->setChild(first);
m_methods[name] = method;
+ }
}
return rc;
}
const QString& RplASVarDefinition::name() const
{
RplASNamedValue* namedValue = dynamic_cast<RplASNamedValue*>(m_child2);
- const QString& rc = namedValue == NULL ? "?" : namedValue->name();
+ const QString& rc = namedValue->name();
return rc;
}
{
DEFINE_TABS(indent);
char buffer[256];
+ if (m_id == 40)
+ m_id = 40;
fprintf(fp, "%sExpr id: %d expr: %d succ: %d %s\n", tabs, m_id,
m_child2 == NULL ? 0 : m_child2->id(),
m_child == NULL ? 0 : m_child->id(),
RplASNode2(AST_METHOD),
m_name(name),
m_resultType(NULL),
- m_symbols(tree.startClassOrMethod(name, RplSymbolSpace::SST_METHOD)),
+ m_symbols(NULL),
m_sibling(NULL),
m_tree(tree)
{
if (m_child2 != NULL)
m_child2->dump(fp, indent + 1);
dumpStatements(fp, indent + 1, m_child);
+ m_symbols->dump(fp, indent + 1);
}
+/**
+ * @brief Returns the symbol space of the instance.
+ *
+ * @return the symbol space
+ */
RplSymbolSpace* RplASMethod::symbols() const
{
return m_symbols;
}
+
+/**
+ * @brief Sets the symbol space from the current of the tree.
+ */
+void RplASMethod::setSymbols()
+{
+ m_symbols = m_tree.currentSpace();
+}
/**
* @brief Returns the name of the method
* @return the name
void execute();
void dump(FILE* fp, int indent);
RplSymbolSpace* symbols() const;
-
+ void setSymbols();
const QString& name() const;
bool equalSignature(RplASMethod& other) const;
RplASMethod* sibling() const;
RplASExprStatement* rc = NULL;
RplASExprStatement* last = NULL;
const RplSourcePosition* startPos = m_lexer.currentPosition();
- RplASItem* definition;
+ RplASItem* definition = NULL;
do {
+ if (definition != NULL)
+ m_lexer.nextNonSpaceToken();
definition = parseVarDefinition(RplASNamedValue::A_PARAM);
RplASExprStatement *current = new RplASExprStatement();
current->setChild2(definition);
if (rc == NULL){
rc = current;
} else {
- current->setChild(last);
last->setChild(current);
}
last = current;
method->setPosition(startPos);
RplSymbolSpace* symbols = m_tree.currentSpace();
symbols->addMethod(method);
-
+ m_tree.startClassOrMethod(name, RplSymbolSpace::SST_METHOD);
+ method->setSymbols();
if (token->isOperator(O_LPARENTH)){
token = m_lexer.nextNonSpaceToken();
if (token->isOperator(O_RPARENTH)){
2+3*4
= <test> (module) parent: global
-== Classes:
-== Variables:
== Body:
Expr id: 6 expr: 2 succ: 0 <test>:1:1
BinOp id: 2 op: + (26) left: 1 right: 4 <test>:1:1
Int i = 3; const lazy Str s = 'Hi'; const List l;
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef i id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:4
+ namedValue i id: 1 attr: 0x0 <test>:1:4
+ const id: 3 value: 3 <test>:1:8
+varDef l id: 8 namedValue: 7 value: 0 succ: 0 <test>:1:47
+ namedValue l id: 7 attr: 0x2 <test>:1:47
+varDef s id: 5 namedValue: 4 value: 6 succ: 8 <test>:1:26
+ namedValue s id: 4 attr: 0x12 <test>:1:26
+ const id: 6 value: 'Hi' <test>:1:30
== Body:
varDef i id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:4
namedValue i id: 1 attr: 0x0 <test>:1:4
[1,2,3].join(' ');
3.14.trunc;
= <test> (module) parent: global
-== Classes:
-== Variables:
== Body:
Expr id: 8 expr: 7 succ: 15 <test>:1:24
field name id: 7 parent: 5 succ: <test>:1:24
a += 1;
od
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
== Body:
varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
Int a; for to 10 do a += 1 od
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
== Body:
varDef a id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
a += 1;
od
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
== Body:
varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
else a = 15 / 16
fi
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+varDef b id: 4 namedValue: 3 value: 0 succ: 10 <test>:2:4
+ namedValue b id: 3 attr: 0x0 <test>:2:4
== Body:
varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
then x = '123';
fi
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef x id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
+ namedValue x id: 1 attr: 0x0 <test>:1:4
== Body:
varDef x id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
namedValue x id: 1 attr: 0x0 <test>:1:4
List b = [];
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef b id: 2 namedValue: 1 value: 3 succ: 0 <test>:1:5
+ namedValue b id: 1 attr: 0x0 <test>:1:5
+ listConst id: 3 <test>:1:9
+ []
== Body:
varDef b id: 2 namedValue: 1 value: 3 succ: 0 <test>:1:5
namedValue b id: 1 attr: 0x0 <test>:1:5
List a = [2+3, 3.14, 7, 'hi', a]; List b = [];
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 3 succ: 11 <test>:1:5
+ namedValue a id: 1 attr: 0x0 <test>:1:5
+ listConst id: 3 <test>:1:9
+ [<formula 7>,3.140000,7,'hi',<formula 9>]
+varDef b id: 11 namedValue: 10 value: 12 succ: 0 <test>:1:39
+ namedValue b id: 10 attr: 0x0 <test>:1:39
+ listConst id: 12 <test>:1:43
+ []
== Body:
varDef a id: 2 namedValue: 1 value: 3 succ: 11 <test>:1:5
namedValue a id: 1 attr: 0x0 <test>:1:5
Map a = {};
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 3 succ: 0 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ mapConst id: 3 <test>:1:8
+ {}
== Body:
varDef a id: 2 namedValue: 1 value: 3 succ: 0 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
Map a = {'a': 2+3,'bcd':3.14,'ccc':7, 'hi':'world'};
Map b = {};
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 3 succ: 11 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ mapConst id: 3 <test>:1:8
+ {'a':<formula 7>,'bcd':3.140000,'ccc':7,'hi':<formula 9>}
+varDef b id: 11 namedValue: 10 value: 12 succ: 0 <test>:2:4
+ namedValue b id: 10 attr: 0x0 <test>:2:4
+ mapConst id: 12 <test>:2:8
+ {}
== Body:
varDef a id: 2 namedValue: 1 value: 3 succ: 11 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
func Float pi: 3.1415; endf func Str delim(): '/' endf;
= <test> (module) parent: global
-== Classes:
-== Variables:
-== Body:
-Method <NoneType> pi() id: 1 parent: 0 args: 0 body: 4 <test>:0:0
- Method <NoneType> delim() id: 4 parent: 0 args: 0 body: 6 <test>:1:28
- Expr id: 6 expr: 5 succ: 0 <test>:1:46
- const id: 5 value: '/' <test>:1:46
+== Methods:
+Method <NoneType> delim() id: 4 parent: <test> args: 0 body: 6 <test>:1:28
Expr id: 6 expr: 5 succ: 0 <test>:1:46
const id: 5 value: '/' <test>:1:46
-Method <NoneType> delim() id: 4 parent: 0 args: 0 body: 6 <test>:1:28
- Expr id: 6 expr: 5 succ: 0 <test>:1:46
- const id: 5 value: '/' <test>:1:46
-Expr id: 6 expr: 5 succ: 0 <test>:1:46
- const id: 5 value: '/' <test>:1:46
+ = <test>.delim (method) parent: <test>
+Method <NoneType> pi() id: 1 parent: <test> args: 0 body: 3 <test>:0:0
+ Expr id: 3 expr: 2 succ: 0 <test>:1:15
+ const id: 2 value: 3.141500 <test>:1:15
+ = <test>.pi (method) parent: <test>
Int rc; if rc <= 1 then rc = 1 else rc = n*fac(n-1) fi
rc endf
= <test> (module) parent: global
-== Classes:
-== Variables:
-== Body:
-Method <NoneType> fac() id: 4 parent: 0 args: 3 body: 6 <test>:0:55
- Expr id: 3 expr: 2 succ: 0
- varDef n id: 2 namedValue: 1 value: 0 succ: 0 <test>:1:23
- namedValue n id: 1 attr: 0x22 <test>:1:23
+== Methods:
+Method <NoneType> fac() id: 1 parent: <test> args: 4 body: 6 <test>:0:55
+ Expr id: 4 expr: 3 succ: 0
+ varDef n id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
+ namedValue n id: 2 attr: 0x22 <test>:1:23
varDef rc id: 6 namedValue: 5 value: 0 succ: 7 <test>:2:4
namedValue rc id: 5 attr: 0x0 <test>:2:4
If id: 7 condition: 9 then: 14 else: 24 succ: 26<test>:2:8
const id: 22 value: 1 <test>:2:49
Expr id: 26 expr: 25 succ: 0 <test>:3:3
namedValue rc id: 25 attr: 0x0 <test>:3:3
-varDef rc id: 6 namedValue: 5 value: 0 succ: 7 <test>:2:4
- namedValue rc id: 5 attr: 0x0 <test>:2:4
-If id: 7 condition: 9 then: 14 else: 24 succ: 26<test>:2:8
- BinOp id: 9 op: <= (23) left: 8 right: 10 <test>:2:14
- namedValue rc id: 8 attr: 0x0 <test>:2:14
- const id: 10 value: 1 <test>:2:17
- Expr id: 14 expr: 12 succ: 0 <test>:2:27
- BinOp id: 12 op: = (5) left: 11 right: 13 <test>:2:27
- namedValue rc id: 11 attr: 0x0 <test>:2:27
- const id: 13 value: 1 <test>:2:29
- Expr id: 24 expr: 16 succ: 0 <test>:2:39
- BinOp id: 16 op: = (5) left: 15 right: 18 <test>:2:39
- namedValue rc id: 15 attr: 0x0 <test>:2:39
- BinOp id: 18 op: * (30) left: 17 right: 19 <test>:2:42
- namedValue n id: 17 attr: 0x0 <test>:2:42
- call fac Id: 19 args: 23 parent: 0 succ: 0 <test>:2:46
- arg 1 id: 23 expr: 21 succ: 0
- BinOp id: 21 op: - (27) left: 20 right: 22 <test>:2:48
- namedValue n id: 20 attr: 0x0 <test>:2:48
- const id: 22 value: 1 <test>:2:49
-Expr id: 26 expr: 25 succ: 0 <test>:3:3
- namedValue rc id: 25 attr: 0x0 <test>:3:3
+ = <test>.fac (method) parent: <test>
+ == Variables:
+ varDef n id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
+ namedValue n id: 2 attr: 0x22 <test>:1:23
+ varDef rc id: 6 namedValue: 5 value: 0 succ: 7 <test>:2:4
+ namedValue rc id: 5 attr: 0x0 <test>:2:4
--- /dev/null
+func Int max(Int a, Int b):
+ Int rc = a;
+if a < b then rc = b; fi
+rc
+endf
+func Int max(const Int a, Int b, Int c):
+max(a, max(b, c))
+endf
+= <test> (module) parent: global
+== Methods:
+Method <NoneType> max() id: 21 parent: <test> args: 24 body: 40 <test>:5:5
+ Expr id: 24 expr: 23 succ: 27
+ varDef a id: 23 namedValue: 22 value: 0 succ: 0 <test>:6:23
+ namedValue a id: 22 attr: 0x22 <test>:6:23
+ Expr id: 40 expr: 31 succ: 0 <test>:7:3
+ call max Id: 31 args: 33 parent: 0 succ: 0 <test>:7:3
+ arg 1 id: 33 expr: 32 succ: 39
+ namedValue a id: 32 attr: 0x0 <test>:7:5
+ arg 2 id: 39 expr: 34 succ: 0
+ call max Id: 34 args: 36 parent: 0 succ: 0 <test>:7:10
+ arg 1 id: 36 expr: 35 succ: 38
+ namedValue b id: 35 attr: 0x0 <test>:7:12
+ arg 2 id: 38 expr: 37 succ: 0
+ namedValue c id: 37 attr: 0x0 <test>:7:15
+ = <test>.max (method) parent: <test>
+ == Variables:
+ varDef a id: 23 namedValue: 22 value: 0 succ: 0 <test>:6:23
+ namedValue a id: 22 attr: 0x22 <test>:6:23
+ varDef b id: 26 namedValue: 25 value: 0 succ: 0 <test>:6:30
+ namedValue b id: 25 attr: 0x20 <test>:6:30
+ varDef c id: 29 namedValue: 28 value: 0 succ: 0 <test>:6:37
+ namedValue c id: 28 attr: 0x20 <test>:6:37
--- /dev/null
+func Int max(const Int a, Int b, Int c):
+func Int max(Int a, Int b):
+ Int rc = a;
+if a < b then rc = b; fi
+rc
+endf
+max(a, max(b, c))
+endf
+= <test> (module) parent: global
+== Methods:
+Method <NoneType> max() id: 1 parent: <test> args: 4 body: 40 <test>:0:4
+ Expr id: 4 expr: 3 succ: 7
+ varDef a id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
+ namedValue a id: 2 attr: 0x22 <test>:1:23
+ Expr id: 40 expr: 31 succ: 0 <test>:7:3
+ call max Id: 31 args: 33 parent: 0 succ: 0 <test>:7:3
+ arg 1 id: 33 expr: 32 succ: 39
+ namedValue a id: 32 attr: 0x0 <test>:7:5
+ arg 2 id: 39 expr: 34 succ: 0
+ call max Id: 34 args: 36 parent: 0 succ: 0 <test>:7:10
+ arg 1 id: 36 expr: 35 succ: 38
+ namedValue b id: 35 attr: 0x0 <test>:7:12
+ arg 2 id: 38 expr: 37 succ: 0
+ namedValue c id: 37 attr: 0x0 <test>:7:15
+ = <test>.max (method) parent: <test>
+ == Methods:
+ Method <NoneType> max() id: 11 parent: <test>.max args: 14 body: 19 <test>:1:41
+ Expr id: 14 expr: 13 succ: 17
+ varDef a id: 13 namedValue: 12 value: 0 succ: 0 <test>:2:17
+ namedValue a id: 12 attr: 0x20 <test>:2:17
+ varDef rc id: 19 namedValue: 18 value: 20 succ: 21 <test>:3:5
+ namedValue rc id: 18 attr: 0x0 <test>:3:5
+ namedValue a id: 20 attr: 0x0 <test>:3:11
+ If id: 21 condition: 23 then: 28 else: 0 succ: 30<test>:3:13
+ BinOp id: 23 op: < (21) left: 22 right: 24 <test>:4:5
+ namedValue a id: 22 attr: 0x0 <test>:4:5
+ namedValue b id: 24 attr: 0x0 <test>:4:9
+ Expr id: 28 expr: 26 succ: 0 <test>:4:17
+ BinOp id: 26 op: = (5) left: 25 right: 27 <test>:4:17
+ namedValue rc id: 25 attr: 0x0 <test>:4:17
+ namedValue b id: 27 attr: 0x0 <test>:4:20
+ Expr id: 30 expr: 29 succ: 0 <test>:5:3
+ namedValue rc id: 29 attr: 0x0 <test>:5:3
+ = <test>.max.max (method) parent: <test>.max
+ == Variables:
+ varDef a id: 13 namedValue: 12 value: 0 succ: 0 <test>:2:17
+ namedValue a id: 12 attr: 0x20 <test>:2:17
+ varDef b id: 16 namedValue: 15 value: 0 succ: 0 <test>:2:24
+ namedValue b id: 15 attr: 0x20 <test>:2:24
+ varDef rc id: 19 namedValue: 18 value: 20 succ: 21 <test>:3:5
+ namedValue rc id: 18 attr: 0x0 <test>:3:5
+ namedValue a id: 20 attr: 0x0 <test>:3:11
+ == Variables:
+ varDef a id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
+ namedValue a id: 2 attr: 0x22 <test>:1:23
+ varDef b id: 6 namedValue: 5 value: 0 succ: 0 <test>:1:30
+ namedValue b id: 5 attr: 0x20 <test>:1:30
+ varDef c id: 9 namedValue: 8 value: 0 succ: 0 <test>:1:37
+ namedValue c id: 8 attr: 0x20 <test>:1:37
sin(a);
max(1+2*3,4**(5-4));
= <test> (module) parent: global
-== Classes:
-== Variables:
== Body:
Expr id: 2 expr: 1 succ: 6 <test>:1:4
call rand Id: 1 args: 0 parent: 0 succ: 0 <test>:1:4
a--*++b**(8-3);
a=b=(a+(b-2)*3)
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ const id: 3 value: 1 <test>:1:8
+varDef b id: 5 namedValue: 4 value: 6 succ: 9 <test>:2:4
+ namedValue b id: 4 attr: 0x0 <test>:2:4
+ const id: 6 value: 100 <test>:2:8
== Body:
varDef a id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
a++;
until a != 2 * 3;
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
== Body:
varDef a id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
a = 7
od
= <test> (module) parent: global
-== Classes:
== Variables:
+varDef a id: 2 namedValue: 1 value: 3 succ: 4 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ const id: 3 value: 20 <test>:1:8
== Body:
varDef a id: 2 namedValue: 1 value: 3 succ: 4 <test>:1:4
namedValue a id: 1 attr: 0x0 <test>:1:4
"rc endf");
parser.parse();
checkAST("meth2.txt", __LINE__);
+ setSource("func Int max(Int a, Int b):\n Int rc = a;\n"
+ "if a < b then rc = b; fi\nrc\n"
+ "endf\n"
+ "func Int max(const Int a, Int b, Int c):\n"
+ "max(a, max(b, c))\n"
+ "endf");
+ parser.parse();
+ checkAST("meth3.txt", __LINE__);
+ setSource("func Int max(const Int a, Int b, Int c):\n"
+ "func Int max(Int a, Int b):\n Int rc = a;\n"
+ "if a < b then rc = b; fi\nrc\n"
+ "endf\n"
+ "max(a, max(b, c))\n"
+ "endf");
+ parser.parse();
+ checkAST("meth4.txt", __LINE__);
}
virtual void doIt(void) {
methodTest();