-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLambda.cpp
46 lines (38 loc) · 976 Bytes
/
Lambda.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "Lambda.h"
#include "SValue.h"
Lambda::Lambda() = default;
Lambda::Lambda( Environment e, std::unique_ptr< SValue > formals, std::unique_ptr< SValue > body )
: env( std::move( e ) ), formals( std::move( formals ) ), body( std::move( body ) )
{}
Lambda::Lambda( const Lambda& other )
{
*this = other;
}
Lambda& Lambda::operator=( const Lambda& other )
{
if ( this != &other )
{
env = other.env;
formals = std::make_unique< SValue >( *other.formals );
body = std::make_unique< SValue >( *other.body );
}
return *this;
}
Lambda::Lambda( Lambda&& other ) noexcept
{
*this = std::move( other );
}
Lambda& Lambda::operator=( Lambda&& other ) noexcept
{
if ( this != &other )
{
env = std::move( other.env );
formals = std::move( other.formals );
body = std::move( other.body );
}
return *this;
}
bool Lambda::operator==( const Lambda& other ) const
{
return ( *formals == *other.formals ) && ( *body == *other.body );
}