nitj: implement static frame to handle calls
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 9 Jul 2015 23:20:08 +0000 (19:20 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 21 Jul 2015 21:23:20 +0000 (17:23 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/compiler/java_compiler.nit

index fa4df54..2521c08 100644 (file)
@@ -317,6 +317,11 @@ class JavaCompilerVisitor
                return decl_var(name, mtype)
        end
 
+       # Calls handling
+
+       # The current `JavaStaticFrame`
+       var frame: nullable JavaStaticFrame = null is writable
+
        # Code generation
 
        # Add a line (will be suffixed by `\n`)
@@ -492,6 +497,28 @@ class RuntimeVariable
        end
 end
 
+# The static context of a visited property in a `JavaCompilerVisitor`
+class JavaStaticFrame
+       # The associated visitor
+       var visitor: JavaCompilerVisitor
+
+       # The executed property.
+       # A Method in case of a call, an attribute in case of a default initialization.
+       var mpropdef: MPropDef
+
+       # The static type of the receiver
+       var receiver: MClassType
+
+       # Arguments of the method (the first is the receiver)
+       var arguments: Array[RuntimeVariable]
+
+       # The runtime_variable associated to the return (in a function)
+       var returnvar: nullable RuntimeVariable = null is writable
+
+       # The label at the end of the property
+       var returnlabel: nullable String = null is writable
+end
+
 redef class MType
        # Return the Java type associated to a given Nit static type
        fun java_type: String do return "RTVal"