Added support for argument references.
authorDavid Anderson <dvander@alliedmods.net>
Sat Jun 30 22:34:48 2012 -0700 (2012-06-30)
changeset 15d8ed9b8f19ca
parent 14 0784ac5cc347
child 16 23627f8bc421
Added support for argument references.
jitcraft/BytecodeCompiler.cpp
jitcraft/main.cpp
tests/prototype/ref-arg.sp
tests/prototype/ref-var.sp
     1.1 --- a/jitcraft/BytecodeCompiler.cpp	Sat Jun 30 22:31:14 2012 -0700
     1.2 +++ b/jitcraft/BytecodeCompiler.cpp	Sat Jun 30 22:34:48 2012 -0700
     1.3 @@ -141,10 +141,10 @@
     1.4  
     1.5              // If this argument is actually a reference, dereference it now.
     1.6              if (var->type()->isReference()) {
     1.7 -                if (var->type()->isFloat()) {
     1.8 +                if (var->type()->contained()->isFloat()) {
     1.9                      __ getref_f();
    1.10                  } else {
    1.11 -                    assert(name->type()->isInt());
    1.12 +                    assert(var->type()->contained()->isInt());
    1.13                      __ getref_i();
    1.14                  }
    1.15              }
     2.1 --- a/jitcraft/main.cpp	Sat Jun 30 22:31:14 2012 -0700
     2.2 +++ b/jitcraft/main.cpp	Sat Jun 30 22:34:48 2012 -0700
     2.3 @@ -85,7 +85,7 @@
     2.4  
     2.5      printf("\n ------------ \n\n");
     2.6  
     2.7 -    Code *main = module->getFunction(1);
     2.8 +    Code *main = module->getFunction(2);
     2.9  
    2.10      Top top = ZONE()->stack().begin();
    2.11      LocalTop localTop(top);
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tests/prototype/ref-arg.sp	Sat Jun 30 22:34:48 2012 -0700
     3.3 @@ -0,0 +1,18 @@
     3.4 +f(&a)
     3.5 +{
     3.6 +    for (new i = 0; i < 10; i = i + 1)
     3.7 +        a = a + i;
     3.8 +    return 0;
     3.9 +}
    3.10 +
    3.11 +g(&b)
    3.12 +{
    3.13 +    return f(b);
    3.14 +}
    3.15 +
    3.16 +main()
    3.17 +{
    3.18 +    new b = 77;
    3.19 +    g(b);
    3.20 +    return b;
    3.21 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tests/prototype/ref-var.sp	Sat Jun 30 22:34:48 2012 -0700
     4.3 @@ -0,0 +1,13 @@
     4.4 +f(&a)
     4.5 +{
     4.6 +    for (new i = 0; i < 10; i = i + 1)
     4.7 +        a = a + i;
     4.8 +    return 0;
     4.9 +}
    4.10 +
    4.11 +main()
    4.12 +{
    4.13 +    new b = 77;
    4.14 +    f(b);
    4.15 +    return b;
    4.16 +}