Remove specific flow analysis for params and forvardecls
authorJean Privat <jean@pryen.org>
Mon, 19 Jan 2009 22:26:17 +0000 (17:26 -0500)
committerJean Privat <jean@pryen.org>
Mon, 19 Jan 2009 22:26:17 +0000 (17:26 -0500)
Instead, consider that only variable declared with var need to be set.

src/syntax/control_flow.nit

index 1057e47..0891fe2 100644 (file)
@@ -29,6 +29,17 @@ redef class MMSrcModule
        end
 end
 
+redef class Variable
+       # Is the variable must be set before being used ?
+       meth must_be_set: Bool do return false
+end
+
+redef class VarVariable
+       redef meth must_be_set do return true
+end
+
+
+
 # Control flow visitor
 # * Check reachability in methods
 # * Associate breaks and continues
@@ -48,7 +59,7 @@ special AbsSyntaxVisitor
 
        meth check_is_set(n: PNode, v: Variable)
        do
-               if not control_flow_ctx.is_set(v) then
+               if v.must_be_set and not control_flow_ctx.is_set(v) then
                        error(n, "Error: variable '{v}' is possibly unset.")
                        var cfc = control_flow_ctx
                        while cfc != null do
@@ -138,14 +149,6 @@ redef class AConcreteMethPropdef
        end
 end
 
-redef class PParam
-       redef meth accept_control_flow(v)
-       do
-               super
-               v.mark_is_set(variable)
-       end
-end
-
 redef class AVardeclExpr
        redef meth accept_control_flow(v)
        do
@@ -282,15 +285,6 @@ redef class AForExpr
 special AControlableBlock
 end
 
-redef class AForVardeclExpr
-       redef meth accept_control_flow(v)
-       do
-               super
-               v.mark_is_set(variable)
-       end
-end     
-
-
 redef class AVarExpr
        redef meth accept_control_flow(v)
        do