| File: | config/auto/cgoto.pm |
| Coverage: | 94.9% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2001-2005, Parrot Foundation. | ||||
| 2 | # $Id: cgoto.pm 43593 2010-01-26 02:39:50Z jkeenan $ | ||||
| 3 | |||||
| 4 - 12 | =head1 NAME config/auto/cgoto.pm - Computed C<goto> =head1 DESCRIPTION Determines whether the compiler supports computed C<goto>. =cut | ||||
| 13 | |||||
| 14 | package auto::cgoto; | ||||
| 15 | |||||
| 16 | 81 81 81 | use strict; | |||
| 17 | 81 81 81 | use warnings; | |||
| 18 | |||||
| 19 | 81 81 81 | use base qw(Parrot::Configure::Step); | |||
| 20 | |||||
| 21 | 81 81 81 | use Parrot::Configure::Utils ':auto'; | |||
| 22 | |||||
| 23 | sub _init { | ||||
| 24 | 83 | my $self = shift; | |||
| 25 | 83 | my %data; | |||
| 26 | 83 | $data{description} = q{Does your compiler support computed goto}; | |||
| 27 | 83 | $data{result} = q{}; | |||
| 28 | 83 | return \%data; | |||
| 29 | } | ||||
| 30 | |||||
| 31 | sub runstep { | ||||
| 32 | 81 | my ( $self, $conf ) = @_; | |||
| 33 | |||||
| 34 | 81 | my $test = _probe_for_cgoto( $conf ); | |||
| 35 | |||||
| 36 | 81 | $self->_evaluate_cgoto($conf, $test); | |||
| 37 | |||||
| 38 | 81 | return 1; | |||
| 39 | } | ||||
| 40 | |||||
| 41 | sub _probe_for_cgoto { | ||||
| 42 | 84 | my $conf = shift; | |||
| 43 | 84 | my $cgoto = $conf->options->get('cgoto'); | |||
| 44 | 84 | my $test; | |||
| 45 | 84 | if ( defined $cgoto ) { | |||
| 46 | 2 | $test = $cgoto; | |||
| 47 | } | ||||
| 48 | else { | ||||
| 49 | 82 | $conf->cc_gen('config/auto/cgoto/test_c.in'); | |||
| 50 | 82 82 82 | $test = eval { $conf->cc_build(); 1; } || 0; | |||
| 51 | 82 | $conf->cc_clean(); | |||
| 52 | } | ||||
| 53 | 84 | return $test; | |||
| 54 | } | ||||
| 55 | |||||
| 56 | sub _evaluate_cgoto { | ||||
| 57 | 85 | my ($self, $conf, $test) = @_; | |||
| 58 | 85 | my $verbose = $conf->options->get('verbose'); | |||
| 59 | 85 | if ($test) { | |||
| 60 | 83 | $conf->data->set( | |||
| 61 | TEMP_cg_h => '$(INC_DIR)/oplib/core_ops_cg.h $(INC_DIR)/oplib/core_ops_cgp.h', | ||||
| 62 | TEMP_cg_c => <<'EOF', | ||||
| 63 | # generated by config/auto/cgoto.pm | ||||
| 64 | |||||
| 65 | src/ops/core_ops_cg$(O): $(GENERAL_H_FILES) src/ops/core_ops_cg.c \ | ||||
| 66 | include/pmc/pmc_parrotlibrary.h | ||||
| 67 | src/ops/core_ops_cgp$(O): $(GENERAL_H_FILES) src/ops/core_ops_cgp.c \ | ||||
| 68 | include/pmc/pmc_parrotlibrary.h | ||||
| 69 | src/runcore/cores.c: $(INC_DIR)/oplib/core_ops_cgp.h | ||||
| 70 | |||||
| 71 | $(INC_DIR)/oplib/core_ops_cg.h: src/ops/core_ops_cg.c | ||||
| 72 | |||||
| 73 | src/ops/core_ops_cg.c : $(OPS_FILES) $(BUILD_TOOLS_DIR)/ops2c.pl lib/Parrot/OpsFile.pm lib/Parrot/Op.pm lib/Parrot/OpTrans/CGoto.pm lib/Parrot/OpLib/core.pm | ||||
| 74 | $(PERL) $(BUILD_TOOLS_DIR)/ops2c.pl CGoto --core | ||||
| 75 | |||||
| 76 | $(INC_DIR)/oplib/core_ops_cgp.h: src/ops/core_ops_cgp.c | ||||
| 77 | |||||
| 78 | src/ops/core_ops_cgp.c : $(OPS_FILES) $(BUILD_TOOLS_DIR)/ops2c.pl lib/Parrot/OpsFile.pm lib/Parrot/Op.pm lib/Parrot/OpTrans/CGP.pm lib/Parrot/OpLib/core.pm lib/Parrot/OpTrans/CPrederef.pm | ||||
| 79 | $(PERL) $(BUILD_TOOLS_DIR)/ops2c.pl CGP --core | ||||
| 80 | EOF | ||||
| 81 | TEMP_cg_o => 'src/ops/core_ops_cg$(O) src/ops/core_ops_cgp$(O)', | ||||
| 82 | TEMP_cg_r => '$(RM_F) $(INC_DIR)/oplib/core_ops_cg.h src/ops/core_ops_cg.c \ | ||||
| 83 | $(INC_DIR)/oplib/core_ops_cgp.h src/ops/core_ops_cgp.c', | ||||
| 84 | cg_flag => '-DHAVE_COMPUTED_GOTO' | ||||
| 85 | ); | ||||
| 86 | 83 | print " (yes) " if $verbose; | |||
| 87 | 83 | $self->set_result('yes'); | |||
| 88 | } | ||||
| 89 | else { | ||||
| 90 | 2 | $conf->data->set( | |||
| 91 | TEMP_cg_h => '', | ||||
| 92 | TEMP_cg_c => '', | ||||
| 93 | TEMP_cg_o => '', | ||||
| 94 | TEMP_cg_r => '', | ||||
| 95 | cg_flag => '' | ||||
| 96 | ); | ||||
| 97 | 2 | print " (no) " if $verbose; | |||
| 98 | 2 | $self->set_result('no'); | |||
| 99 | } | ||||
| 100 | } | ||||
| 101 | |||||
| 102 | 1; | ||||
| 103 | |||||
| 104 | # Local Variables: | ||||
| 105 | # mode: cperl | ||||
| 106 | # cperl-indent-level: 4 | ||||
| 107 | # fill-column: 100 | ||||
| 108 | # End: | ||||
| 109 | # vim: expandtab shiftwidth=4: | ||||