Determining State of the parameter

For a Value parameterized class I want to know the state of parameter .


class  env #( SIZE = 10 )  ;

   localparam  STATE   =  state() ;  //  Calculates  the  state  

   localparam  type_name  =  $sformatf("env#(%0d_%0d_%0d_%0s)" , SIZE , $left( SIZE ) , $right( SIZE )  ,  STATE  ) ;

   static  function   string   state() ;  //  Returns  either  "2_state"  OR  "4_state"

      string  state_q[$] = '{ "reg" , "logic" , "integer" } ; 
   
          string  sign  =  $typename( SIZE ) ;   
   
           state  =  "2_state" ;  //  By  default  2-state .
  
         foreach( state_q[i] )
           begin
             
             automatic int  l1  =  sign.len();
             automatic int  l2  =  state_q[i].len() ;            
  
             for( int i = 0 ; i < ( l1 - l2 ) ; i ++ )
              begin
  
                if( sign.substr( i , i + l2 - 1  )  ==  state_q[i] )
                 begin
  
                    state  =  "4_state" ;
  
                    break ;
  
                 end
  
             end
  
           end
  
      endfunction     

   endclass
  
   parameter   int  INT  =  100 ;    //  2 - state 

   parameter   logic  [ 9 : 0 ]  L_9_0  =  50 ;   //  4 - state 
 
   initial  begin
 
     $display(" env#( INT )  is  %0s  " , env #( INT ) ::  type_name );
 
      $display(" env#( L_9_0 )  is  %0s  " , env #( L_9_0 ) ::  type_name );


   end


I observe a Compilation error saying " state() is not a constant function "

This could be due to $typename limitations in LRM / Tools .

Is there any alternative way to determine state of parameter ‘SIZE’ ?