C-TinyCompiler

 view release on metacpan or  search on metacpan

lib/C/TinyCompiler/package.pm  view on Meta::CPAN

package C::TinyCompiler::package;

use strict;
use warnings;

sub get_packages {
	my $package_list;
	if (@_ > 0) {
		$package_list = shift;
	}
	else {
		my $hashref = (caller(1))[10];
		$package_list = $hashref->{C_TinyCompiler_packages} if defined $hashref;
	}
	$package_list ||= '';
	return split /[|]/, $package_list;
}

# Args:
#  * $package_name
#  * $compiler_state
#  * @options
sub apply {
	# empty apply
}

# Args:
#  * $package_name
#  * $compiler_state
#  * @other_packages
sub conflicts_with {
	# doesn't conflict with anything
	0;
}

# Args:
#  * $package_name
#  * $compiler_state
#  * @options
sub apply_symbols {
	# empty apply_symbols
}

# Args:
#  * $package_name
#  * $compiler_state
#  * @options
sub preprocess {
	# No preprocessing
}

sub import {
	my $module = shift;
	# Build a hash with keys as currently used package names:
	my %packages = map {$_ => 1} get_packages($^H{C_TinyCompiler_packages});
	# Add this package:
	$packages{$module} = 1;
	# Reassemble into the package list:
	$^H{C_TinyCompiler_packages} = join('|', keys %packages);
}

sub unimport {
	my $module = shift;
	# Build a hash with keys as currently used package names:
	my %packages = map {$_ => 1} get_packages($^H{C_TinyCompiler_packages});
	# Remove this package:
	delete $packages{$module};
	# Reassemble into the package list:
	$^H{C_TinyCompiler_packages} = join('|', keys %packages);
}

1;



( run in 1.200 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )