| 1 | package VM::Dreamer::Environment; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 2 | our $VERSION = '0.851'; | |
| 7 | |||
| 8 | 2 | require Exporter; | |
| 9 | |||
| 10 | 2 | our @ISA = qw(Exporter); | |
| 11 | 2 | our @EXPORT_OK = qw( get_restrictions get_say_normal ); | |
| 12 | |||
| 13 | 2 | my $restrictions = { | |
| 14 | base => { | ||
| 15 | min => 2, | ||
| 16 | max => 10 | ||
| 17 | }, | ||
| 18 | |||
| 19 | op_code_width => { | ||
| 20 | min => 1, | ||
| 21 | max => 8 | ||
| 22 | }, | ||
| 23 | |||
| 24 | operand_width => { | ||
| 25 | min => 1, | ||
| 26 | max => 248 | ||
| 27 | } | ||
| 28 | }; | ||
| 29 | |||
| 30 | 2 | our $say_normal = { | |
| 31 | base => "base", | ||
| 32 | op_code_width => "op-code's width", | ||
| 33 | operand_width => "operand's width" | ||
| 34 | }; | ||
| 35 | |||
| 36 | 4 | ▶ | sub get_restrictions { |
|
Subroutine
get_restrictions: called CC=1 SCAR=0.0
Pod
documented
| |||
| 37 | 4 | return $restrictions; | |
| 38 | } | ||
| 39 | |||
| 40 | 2 | ▶ | sub get_say_normal { |
|
Subroutine
get_say_normal: called CC=1 SCAR=0.0
Pod
documented
| |||
| 41 | 2 | return $say_normal; | |
| 42 | } | ||
| 43 | |||
| 44 | 2 | 1; | |
| 45 | |||
| 46 | =pod | ||
| 47 | |||
| 48 | =head1 NAME | ||
| 49 | |||
| 50 | Vm::Dreamer::Environment | ||
| 51 | |||
| 52 | =head1 SYNOPSIS | ||
| 53 | |||
| 54 | get_restrictions(); | ||
| 55 | get_say_normal(); | ||
| 56 | |||
| 57 | =head1 DESCRIPTION | ||
| 58 | |||
| 59 | Provides a place for environmental variables. Currently lets you set boundaries on the base, the op_code_width and the operand_width. Used for validation during initialization. | ||
| 60 | |||
| 61 | =head1 SUBROUTINES | ||
| 62 | |||
| 63 | =head2 get_restrictions | ||
| 64 | |||
| 65 | Doesn't take any arguments and returns a hash ref with three keys - base, op_code_width and operand_width. Each in turn is a reference to a hash which has a key called min and another called max. | ||
| 66 | |||
| 67 | Used by VM::Dreamer::Validate to validate the machine definition during initialization and by VM::Dreamer::Error to populate an error string with the min/max values for a more robust error message to the user. | ||
| 68 | |||
| 69 | =head2 get_say_normal | ||
| 70 | |||
| 71 | Returns a analog of base, op_code_width and operand_width suitable for use in strings when presented to a human. Used by vM::Dreamer::Error. | ||
| 72 | |||
| 73 | =head1 AUTHOR | ||
| 74 | |||
| 75 | William Stevenson <william at coders dot coop> | ||
| 76 | |||
| 77 | =head1 SEE ALSO | ||
| 78 | |||
| 79 | VM::Dreamer | ||
| 80 | VM::Dreamer::Error | ||
| 81 | VM::Dreamer::Validate | ||
| 82 | |||
| 83 | =head1 COPYRIGHT AND LICENSE | ||
| 84 | |||
| 85 | This software is Copyright (c) 2013 by William Stevenson. | ||
| 86 | |||
| 87 | This is free software, licensed under: | ||
| 88 | |||
| 89 | The Artistic License 2.0 (GPL Compatible) | ||
| 90 | |||
| 91 | =cut | ||