From 721be50971822c780f037f544b31315f046b1334 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 19 Jan 2009 17:26:17 -0500 Subject: [PATCH] Remove specific flow analysis for params and forvardecls Instead, consider that only variable declared with var need to be set. --- src/syntax/control_flow.nit | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/syntax/control_flow.nit b/src/syntax/control_flow.nit index 1057e47..0891fe2 100644 --- a/src/syntax/control_flow.nit +++ b/src/syntax/control_flow.nit @@ -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 -- 1.7.9.5