public function GetRegisterVarConstantTemplate(
        \Peg\Lib\Definitions\Element\GlobalVariable $variable,
        $namespace=""
    )
    {
        if($namespace)
        {
            $namespace = str_replace(
                array("\\", "::"),
                "_",
                $namespace
            ) . "_";
        }

        $ptr = "";
        if($variable->is_pointer)
        {
            for($i=0; $i<$variable->indirection_level; $i++)
            {
                $ptr .= "_ptr";
            }
        }

        $ref = "";
        if($variable->is_reference)
        {
            $ref .= "_ref";
        }

        $array = "";
        if($variable->is_array)
        {
            $array .= "_arr";
        }

        $override = $this->templates_path
            . "constants/overrides/"
            . $variable->type
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(file_exists($override))
        {
            return $override;
        }

        $standard_type = $this->symbols->GetStandardType($variable);

        $template = $this->templates_path
            . "constants/"
            . $standard_type
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(!file_exists($template))
        {
            return $this->templates_path
                . "constants/"
                . "default.php"
            ;
        }

        return $template;
    }
public function GetRegisterVarConstantTemplate(
        \Peg\Lib\Definitions\Element\GlobalVariable $variable,
        $namespace=""
    )
    {
        if($namespace)
        {
            $namespace = str_replace(
                array("\\", "::"),
                "_",
                $namespace
            ) . "_";
        }

        $ptr = "";
        if($variable->is_pointer)
        {
            for($i=0; $i<$variable->indirection_level; $i++)
            {
                $ptr .= "_ptr";
            }
        }

        $ref = "";
        if($variable->is_reference)
        {
            $ref .= "_ref";
        }

        $array = "";
        if($variable->is_array)
        {
            $array .= "_arr";
        }

        $override = $this->templates_path
            . "constants/overrides/"
            . $variable->type
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(file_exists($override))
        {
            return $override;
        }

        $standard_type = $this->symbols->GetStandardType($variable);

        $template = $this->templates_path
            . "constants/"
            . $standard_type
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(!file_exists($template))
        {
            return $this->templates_path
                . "constants/"
                . "default.php"
            ;
        }

        return $template;
    }
public function GetRegisterVarConstantTemplate ( \ Peg \ Lib \ Definitions \ Element \ GlobalVariable $ variable , $ namespace = "" ) { if ( $ namespace ) { $ namespace = str_replace ( array ( "\\" , "::" ) , "_" , $ namespace ) . "_" ; } $ ptr = "" ; if ( $ variable -> is_pointer ) { for ( $ i = 0 ; $ i < $ variable -> indirection_level ; $ i ++ ) { $ ptr .= "_ptr" ; } } $ ref = "" ; if ( $ variable -> is_reference ) { $ ref .= "_ref" ; } $ array = "" ; if ( $ variable -> is_array ) { $ array .= "_arr" ; } $ override = $ this -> templates_path . "constants/overrides/" . $ variable -> type . $ ptr . $ ref . $ array . ".php" ; if ( file_exists ( $ override ) ) { return $ override ; } $ standard_type = $ this -> symbols -> GetStandardType ( $ variable ) ; $ template = $ this -> templates_path . "constants/" . $ standard_type . $ ptr . $ ref . $ array . ".php" ; if ( ! file_exists ( $ template ) ) { return $ this -> templates_path . "constants/" . "default.php" ; } return $ template ; }
Retrieve the template path for registering constants registered as global
variables, also checks if a valid override exists and returns that instead.
@param \Peg\Lib\Definitions\Element\GlobalVariable $variable
@param string $namespace Namespace where resides the constant.
@return string Path to template file.
Retrieve the template path for registering constants registered as global variables also checks if a valid override exists and returns that instead .