mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
BUGFIX: chained calls not being dottified
This commit is contained in:
@@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
fn _b(self) {
|
|
||||||
print "running _b";
|
|
||||||
print self;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _c(self) {
|
|
||||||
print "running _c";
|
|
||||||
print self;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _d(self) {
|
|
||||||
print "running _d";
|
|
||||||
print self;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _e(self) {
|
|
||||||
print "running _e";
|
|
||||||
print self;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _f(self) {
|
|
||||||
print "running _f";
|
|
||||||
print self;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fn b() {
|
|
||||||
print "running b";
|
|
||||||
}
|
|
||||||
|
|
||||||
fn c() {
|
|
||||||
print "running c";
|
|
||||||
}
|
|
||||||
|
|
||||||
fn d() {
|
|
||||||
print "running d";
|
|
||||||
}
|
|
||||||
|
|
||||||
fn e() {
|
|
||||||
print "running e";
|
|
||||||
}
|
|
||||||
|
|
||||||
fn f() {
|
|
||||||
print "running f";
|
|
||||||
}
|
|
||||||
|
|
||||||
var a = 42;
|
|
||||||
|
|
||||||
print a.b().c().d().e().f();
|
|
||||||
9
scripts/test/dottify-bugfix.toy
Normal file
9
scripts/test/dottify-bugfix.toy
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
fn _add(self, inc) {
|
||||||
|
return self + inc;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert 1.add(2).add(3).add(4) == 10, "dottify bugfix failed";
|
||||||
|
|
||||||
|
|
||||||
|
print "All good";
|
||||||
@@ -798,12 +798,6 @@ static Opcode dot(Parser* parser, ASTNode** nodeHandle) {
|
|||||||
return OP_EOF;
|
return OP_EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
//hijack the function call, and hack in an extra parameter
|
|
||||||
if (node->binary.opcode == OP_FN_CALL) {
|
|
||||||
node->binary.right->fnCall.argumentCount++;
|
|
||||||
node->binary.opcode = OP_DOT;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*nodeHandle) = node;
|
(*nodeHandle) = node;
|
||||||
return OP_DOT; //signal that the function name and arguments are in the wrong order
|
return OP_DOT; //signal that the function name and arguments are in the wrong order
|
||||||
}
|
}
|
||||||
@@ -1090,6 +1084,7 @@ static void dottify(Parser* parser, ASTNode** nodeHandle) {
|
|||||||
if ((*nodeHandle)->type == AST_NODEBINARY) {
|
if ((*nodeHandle)->type == AST_NODEBINARY) {
|
||||||
if ((*nodeHandle)->binary.opcode == OP_FN_CALL) {
|
if ((*nodeHandle)->binary.opcode == OP_FN_CALL) {
|
||||||
(*nodeHandle)->binary.opcode = OP_DOT;
|
(*nodeHandle)->binary.opcode = OP_DOT;
|
||||||
|
(*nodeHandle)->binary.right->fnCall.argumentCount++;
|
||||||
}
|
}
|
||||||
dottify(parser, &(*nodeHandle)->binary.left);
|
dottify(parser, &(*nodeHandle)->binary.left);
|
||||||
dottify(parser, &(*nodeHandle)->binary.right);
|
dottify(parser, &(*nodeHandle)->binary.right);
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ int main() {
|
|||||||
"dot-and-matrix.toy",
|
"dot-and-matrix.toy",
|
||||||
"dot-assignments-bugfix.toy",
|
"dot-assignments-bugfix.toy",
|
||||||
"dot-chaining.toy",
|
"dot-chaining.toy",
|
||||||
|
"dottify-bugfix.toy",
|
||||||
"functions.toy",
|
"functions.toy",
|
||||||
"imports-and-exports.toy",
|
"imports-and-exports.toy",
|
||||||
"index-arrays.toy",
|
"index-arrays.toy",
|
||||||
|
|||||||
Reference in New Issue
Block a user