Merge: ldflags for Android
[nit.git] / contrib / jwrapper / src / javap_visitor.nit
index 45edb3d..64415a4 100644 (file)
@@ -21,7 +21,7 @@ module javap_visitor
 import javap_test_parser
 import code_generator
 import jtype_converter
-intrude import types
+intrude import model
 
 class JavaVisitor
        super Visitor
@@ -61,6 +61,22 @@ class JavaVisitor
                self.variable_type = new JavaType(self.converter)
                super
        end
+
+       # Add the identifier from `token` to the current context
+       fun add_identifier(token: NToken)
+       do
+               if declaration_type == "variable" then
+                       if declaration_element == "type" then
+                               variable_type.identifier.add(token.text)
+                       end
+               else if declaration_type == "method" then
+                       if declaration_element == "return_type" then
+                               method_return_type.identifier.add(token.text)
+                       else if declaration_element == "parameter_list" then
+                               method_params[param_index].identifier.add(token.text)
+                       end
+               end
+       end
 end
 
 redef class Node
@@ -162,144 +178,41 @@ redef class N_39d_91d_93d_39d
 end
 
 redef class N_39dchar_39d
-       redef fun accept_visitor(v)
-       do
-               if v.declaration_type == "variable" then
-                       if v.declaration_element == "type" then
-                               v.variable_type.identifier.add(self.text)
-                       end
-               else if v.declaration_type == "method" then
-                       if v.declaration_element == "return_type" then
-                               v.method_return_type.identifier.add(self.text)
-                       else if v.declaration_element == "parameter_list" then
-                               v.method_params[v.param_index].identifier.add(self.text)
-                       end
-               end
-       end
+       redef fun accept_visitor(v) do v.add_identifier self
 end
 
 redef class N_39dboolean_39d
-       redef fun accept_visitor(v)
-       do
-               if v.declaration_type == "variable" then
-                       if v.declaration_element == "type" then
-                               v.variable_type.identifier.add(self.text)
-                       end
-               else if v.declaration_type == "method" then
-                       if v.declaration_element == "return_type" then
-                               v.method_return_type.identifier.add(self.text)
-                       else if v.declaration_element == "parameter_list" then
-                               v.method_params[v.param_index].identifier.add(self.text)
-                       end
-               end
-       end
+       redef fun accept_visitor(v) do v.add_identifier self
 end
 
 redef class N_39dfloat_39d
-       redef fun accept_visitor(v)
-       do
-               if v.declaration_type == "variable" then
-                       if v.declaration_element == "type" then
-                               v.variable_type.identifier.add(self.text)
-                       end
-               else if v.declaration_type == "method" then
-                       if v.declaration_element == "return_type" then
-                               v.method_return_type.identifier.add(self.text)
-                       else if v.declaration_element == "parameter_list" then
-                               v.method_params[v.param_index].identifier.add(self.text)
-                       end
-               end
-       end
+       redef fun accept_visitor(v) do v.add_identifier self
 end
 
 redef class N_39ddouble_39d
-       redef fun accept_visitor(v)
-       do
-               if v.declaration_type == "variable" then
-                       if v.declaration_element == "type" then
-                               v.variable_type.identifier.add(self.text)
-                       end
-               else if v.declaration_type == "method" then
-                       if v.declaration_element == "return_type" then
-                               v.method_return_type.identifier.add(self.text)
-                       else if v.declaration_element == "parameter_list" then
-                               v.method_params[v.param_index].identifier.add(self.text)
-                       end
-               end
-       end
+       redef fun accept_visitor(v) do v.add_identifier self
 end
 
 redef class N_39dbyte_39d
-       redef fun accept_visitor(v)
-       do
-               if v.declaration_type == "variable" then
-                       if v.declaration_element == "type" then
-                               v.variable_type.identifier.add(self.text)
-                       end
-               else if v.declaration_type == "method" then
-                       if v.declaration_element == "return_type" then
-                               v.method_return_type.identifier.add(self.text)
-                       else if v.declaration_element == "parameter_list" then
-                               v.method_params[v.param_index].identifier.add(self.text)
-                       end
-               end
-       end
+       redef fun accept_visitor(v) do v.add_identifier self
 end
 
 redef class N_39dshort_39d
-       redef fun accept_visitor(v)
-       do
-               if v.declaration_type == "variable" then
-                       if v.declaration_element == "type" then
-                               v.variable_type.identifier.add(self.text)
-                       end
-               else if v.declaration_type == "method" then
-                       if v.declaration_element == "return_type" then
-                               v.method_return_type.identifier.add(self.text)
-                       else if v.declaration_element == "parameter_list" then
-                               v.method_params[v.param_index].identifier.add(self.text)
-                       end
-               end
-       end
+       redef fun accept_visitor(v) do v.add_identifier self
 end
 
 redef class N_39dint_39d
-       redef fun accept_visitor(v)
-       do
-               if v.declaration_type == "variable" then
-                       if v.declaration_element == "type" then
-                               v.variable_type.identifier.add(self.text)
-                       end
-               else if v.declaration_type == "method" then
-                       if v.declaration_element == "return_type" then
-                               v.method_return_type.identifier.add(self.text)
-                       else if v.declaration_element == "parameter_list" then
-                               v.method_params[v.param_index].identifier.add(self.text)
-                       end
-               end
-       end
+       redef fun accept_visitor(v) do v.add_identifier self
 end
 
 redef class N_39dlong_39d
-       redef fun accept_visitor(v)
-       do
-               if v.declaration_type == "variable" then
-                       if v.declaration_element == "type" then
-                               v.variable_type.identifier.add(self.text)
-                       end
-               else if v.declaration_type == "method" then
-                       if v.declaration_element == "return_type" then
-                               v.method_return_type.identifier.add(self.text)
-                       else if v.declaration_element == "parameter_list" then
-                               v.method_params[v.param_index].identifier.add(self.text)
-                       end
-               end
-       end
+       redef fun accept_visitor(v) do v.add_identifier self
 end
 
 #                                  #
 #    C L A S S     H E A D E R     #
 #                                  #
+
 redef class Nclass_header
        redef fun accept_visitor(v)
        do
@@ -335,11 +248,11 @@ redef class Nimplements_declaration
        end
 end
 
-#                                          #
-#   F I E L D    D E C L A R A T I O N S   #
-#                                          #
+#                                            #
+# P R O P E R T Y    D E C L A R A T I O N S #
+#                                            #
 
-# Method declaration in the field declarations
+# Method declaration
 redef class Nmethod_declaration
        redef fun accept_visitor(v)
        do
@@ -356,7 +269,7 @@ redef class Nmethod_declaration
        end
 end
 
-# Constructor declaration in the field declarations
+# Constructor declaration
 redef class Nconstructor_declaration
        redef fun accept_visitor(v)
        do
@@ -366,7 +279,7 @@ redef class Nconstructor_declaration
        end
 end
 
-# Variable declaration in the field declarations
+# Variable property declaration
 redef class Nvariable_declaration
        redef fun accept_visitor(v)
        do
@@ -381,7 +294,7 @@ redef class Nvariable_declaration
        end
 end
 
-# Static declaration in the field declarations
+# Static property declaration
 redef class Nstatic_declaration
        redef fun accept_visitor(v)
        do
@@ -391,7 +304,7 @@ redef class Nstatic_declaration
        end
 end
 
-# Identifier of the field
+# Identifier of a variable
 redef class Nvariable_id
        redef fun accept_visitor(v)
        do