[Bps-public-commit] lcore branch, master, updated. 3cce490baac91e5b18eb04407c7a6d5599076ca5

clkao at bestpractical.com clkao at bestpractical.com
Mon Oct 5 23:07:35 EDT 2009


The branch, master has been updated
       via  3cce490baac91e5b18eb04407c7a6d5599076ca5 (commit)
      from  86de5589db6c411ef8b248545e00c0c844ad0e9e (commit)

Summary of changes:
 lib/LCore/Expression/Application.pm    |    8 ++++++++
 lib/LCore/Expression/SelfEvaluating.pm |    8 ++++++++
 lib/LCore/Expression/Variable.pm       |    8 ++++++++
 3 files changed, 24 insertions(+), 0 deletions(-)

- Log -----------------------------------------------------------------
commit 3cce490baac91e5b18eb04407c7a6d5599076ca5
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Tue Oct 6 11:07:26 2009 +0800

    serialization for application/self-evaluating/variable.

diff --git a/lib/LCore/Expression/Application.pm b/lib/LCore/Expression/Application.pm
index 6882583..5211967 100644
--- a/lib/LCore/Expression/Application.pm
+++ b/lib/LCore/Expression/Application.pm
@@ -8,6 +8,14 @@ has operator => (is => "ro", isa => "LCore::Expression|CodeRef");
 # details with get_operands.
 has operands => (is => "ro", isa => "HashRef|ArrayRef[LCore::Expression|CodeRef]");
 
+sub to_hash {
+    my ($self) = shift;
+    return { type => 'application',
+             operator => $self->operator->to_hash,
+             operands => [ map { $_->to_hash } @{$self->operands } ],
+         };
+}
+
 sub analyze {
     my ($class, $env, $exp) = @_;
 
diff --git a/lib/LCore/Expression/SelfEvaluating.pm b/lib/LCore/Expression/SelfEvaluating.pm
index 106f3d5..27317b0 100644
--- a/lib/LCore/Expression/SelfEvaluating.pm
+++ b/lib/LCore/Expression/SelfEvaluating.pm
@@ -5,6 +5,14 @@ extends 'LCore::Expression';
 
 has value => (is => "ro", isa => "Str");
 
+sub to_hash {
+    my ($self) = shift;
+    return { type => 'self_evaluating',
+             value => $self->value,
+         };
+}
+
+
 __PACKAGE__->meta->make_immutable;
 no Moose;
 1;
diff --git a/lib/LCore/Expression/Variable.pm b/lib/LCore/Expression/Variable.pm
index 0925e25..f67b141 100644
--- a/lib/LCore/Expression/Variable.pm
+++ b/lib/LCore/Expression/Variable.pm
@@ -5,6 +5,14 @@ extends 'LCore::Expression';
 
 has name => (is => "ro", isa => "Str");
 
+sub to_hash {
+    my ($self) = shift;
+    return { type => 'variable',
+             name => $self->name,
+         };
+}
+
+
 __PACKAGE__->meta->make_immutable;
 no Moose;
 1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list