Permalink
Browse files

* global symbol table renamed

git-svn-id: svn+ssh://svn.bestpractical.com/svn/bps-public/pie/branches/named-params@12655 e417ac7c-1bcc-0310-8ffa-8f5827389a85
  • Loading branch information...
1 parent ac836f5 commit cbe3c34c0b4f2c4b5585cdebbbd1e9c23a6cb0e2 @obra obra committed May 24, 2008
Showing with 24 additions and 24 deletions.
  1. +5 −5 TODO
  2. +2 −2 doc/yapperl.txt
  3. +5 −5 lib/PIE/Evaluator.pm
  4. +2 −2 lib/PIE/Expression.pm
  5. +2 −2 t/01basic.t
  6. +4 −4 t/hello_world.t
  7. +2 −2 t/leaky-lexicals.t
  8. +2 −2 t/named-params.t
View
@@ -1,10 +1,10 @@
Backend
-# is there a reason we shouldn't force _all_ arguments to _all_ functions to be named?
+# is there a reason we shouldn't force _all_ arguments to _all_ functions to be global_symbols?
-- define named functions with typed arguments
+- define global_symbols functions with typed arguments
- builtins
- - control op: named subexpression?
+ - control op: global_symbols subexpression?
-
@@ -15,7 +15,7 @@ Backend
args => { value => 'defined-symbol' } }
{ op => 'orz',
- args => { named1 => EXP2,
+ args => { global_symbols1 => EXP2,
orz2 => EXP3 } }
@@ -60,7 +60,7 @@ GUI Builder
- let user add an expression as an argument to an existing expression
- let user add expression to run sequentially "after" another expression
- serialize and save the tree of expressions
-- save a tree of expressions as a named thingy which can be referenced from other expressions.
+- save a tree of expressions as a global_symbols thingy which can be referenced from other expressions.
Hooks
View
@@ -63,7 +63,7 @@ Just to name things:
does it return results or does it shove results in some input handed to it?
- a block is essentially a named bricks built up of one or more blocks or bricks
+ a block is essentially a global_symbols bricks built up of one or more blocks or bricks
@@ -300,7 +300,7 @@ sub exec {}
# a class to describe an op tree
# a class to run an optree
# primitives for basic ops
- # run a named optree like it's a primitive
+ # run a global_symbols optree like it's a primitive
# primitives for variables
# a way to store an optree as a variable
View
@@ -11,14 +11,14 @@ has result => (
default => sub { return PIE::EvaluatorResult->new()}
);
-has named => (
+has global_symbols => (
metaclass => 'Collection::Hash',
is => 'rw',
default => sub { {} },
isa => 'HashRef',
provides => {
- get => 'get_named',
- set => 'set_named',
+ get => 'get_global_symbol',
+ set => 'set_global_symbol',
});
has stack_vars => (
@@ -82,11 +82,11 @@ sub run {
sub trace{}
-sub resolve_name {
+sub resolve_symbol_name {
my ($self, $name) = @_;
my $stack = $self->stack_vars->[-1] || {};
Carp::cluck if ref($name);
- $stack->{$name} || $self->get_named($name) || die "Could not find symbol $name in the current lexical context.";
+ $stack->{$name} || $self->get_global_symbol($name) || die "Could not find symbol $name in the current lexical context.";
}
sub apply_script {
@@ -32,7 +32,7 @@ has args => (
sub evaluate {
my ($self, $ev) = @_;
- my $lambda = $ev->resolve_name($self->name);
+ my $lambda = $ev->resolve_symbol_name($self->name);
die "Function ".$self->name." not defined" unless $lambda;
$ev->apply_script( $lambda, $self->args );
return $ev->result->value;
@@ -151,7 +151,7 @@ has signature => (
sub evaluate {
my ($self, $eval) = validate_pos(@_, { isa => 'PIE::Expression'}, { isa => 'PIE::Evaluator'});
my $symbol = $self->{'args'}->{'symbol'}->evaluate($eval);
- my $result = $eval->resolve_name($symbol);
+ my $result = $eval->resolve_symbol_name($symbol);
return $result->meta->does_role('PIE::Evaluatable') ? $result->evaluate($eval): $result; # XXX: figure out evaluation order here
}
View
@@ -78,7 +78,7 @@ my $MATCH_REGEX = PIE::Lambda::Native->new(
);
-$eval9->set_named( 'match-regexp' => $MATCH_REGEX );
+$eval9->set_global_symbol( 'match-regexp' => $MATCH_REGEX );
$eval9->apply_script(
$MATCH_REGEX,
@@ -92,7 +92,7 @@ is( $eval9->result->value, 1 );
my $builder = PIE::Builder->new();
my $eval10 = PIE::Evaluator->new();
-$eval10->set_named( 'match-regexp' => $MATCH_REGEX );
+$eval10->set_global_symbol( 'match-regexp' => $MATCH_REGEX );
$eval10->apply_script(
$builder->defun(
View
@@ -51,12 +51,12 @@ my $hello = Hello->new;
isa_ok( $hello => 'Hello' );
use PIE::Lambda::Native;
-$hello->evaluator->set_named( 'make-fred',
+$hello->evaluator->set_global_symbol( 'make-fred',
PIE::Lambda::Native->new( body => sub { return 'fred' } ) );
-$hello->evaluator->set_named( 'make-bob',
+$hello->evaluator->set_global_symbol( 'make-bob',
PIE::Lambda::Native->new( body => sub { return 'bob' } ) );
-$hello->evaluator->set_named(
+$hello->evaluator->set_global_symbol(
'make-whoever',
PIE::Lambda::Native->new(
body => sub { my $args = shift; return $args->{'name'} },
@@ -106,7 +106,7 @@ isa_ok( $hello->rules->[0], 'PIE::Lambda' );
isa_ok( $hello->rules->[1], 'PIE::Lambda' );
is( $hello->run('jesse'), 'Hello fred' );
-$hello->rules( [ $hello->evaluator->get_named('make-whoever') ] );
+$hello->rules( [ $hello->evaluator->get_global_symbol('make-whoever') ] );
isa_ok( $hello->rules->[0], 'PIE::Lambda' );
is( $hello->run('jesse'), 'Hello jesse' );
View
@@ -22,15 +22,15 @@ my $A_SIDE = PIE::Builder->defun(
signature => { x => PIE::FunctionArgument->new(name => 'x', type => 'Str')});
-$eval->set_named( 'a' => $A_SIDE );
+$eval->set_global_symbol( 'a' => $A_SIDE );
my $defined_b = $builder->defun(
ops => [{ name => 'a', args => { x => 'x456' }} ],
signature =>
{ y => PIE::FunctionArgument->new( name => 'y', type => 'String' ) }
);
-$eval->set_named( b=> $defined_b);
+$eval->set_global_symbol( b=> $defined_b);
$eval->run( $builder->build_expression( { name => 'b', args => { y => 'Y123' }}));
ok (!$eval->result->success);
View
@@ -23,7 +23,7 @@ my $MATCH_REGEX = PIE::Lambda::Native->new(
);
my $eval5 = PIE::Evaluator->new;
-$eval5->set_named( 'match-regex' => $MATCH_REGEX );
+$eval5->set_global_symbol( 'match-regex' => $MATCH_REGEX );
my $match_p = PIE::Expression->new(
name => 'match-regex',
@@ -40,7 +40,7 @@ is( $eval5->result->value, 1 );
my $eval6 = PIE::Evaluator->new();
-$eval6->set_named( 'match-regex' => $MATCH_REGEX );
+$eval6->set_global_symbol( 'match-regex' => $MATCH_REGEX );
my $match_fail_p = PIE::Expression->new(
name => 'match-regex',

0 comments on commit cbe3c34

Please sign in to comment.