Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / astexpr.h
blob3e60e972e82f01a9729a738e687585ecf4b29436
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #pragma once
21 #include "ast.h"
23 namespace Shapes
25 namespace Ast
28 class UnaryExpr : public Expression
30 public:
31 UnaryExpr( const Ast::SourceLocation & loc );
32 virtual ~UnaryExpr( );
33 virtual RefCountPtr< const Lang::Value > throwNotApplicable( const Lang::Value * arg ) const = 0;
34 DEFAULTUNARYOPDECL;
37 class UnaryPrefixExpr : public UnaryExpr
39 protected:
40 Ast::SourceLocation opLoc_;
41 Ast::Expression * expr_;
42 public:
43 UnaryPrefixExpr( const Ast::SourceLocation & loc, const Ast::SourceLocation & opLoc, Ast::Expression * expr );
44 UnaryPrefixExpr( const Ast::SourceLocation & opLoc, Ast::Expression * expr );
45 virtual ~UnaryPrefixExpr( );
46 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
47 virtual void eval( Kernel::EvalState * evalState ) const;
48 virtual RefCountPtr< const Lang::Value > throwNotApplicable( const Lang::Value * arg ) const;
51 class UnaryPostfixExpr : public UnaryExpr
53 protected:
54 Ast::SourceLocation opLoc_;
55 Ast::Expression * expr_;
56 public:
57 UnaryPostfixExpr( const Ast::SourceLocation & opLoc, Ast::Expression * expr );
58 virtual ~UnaryPostfixExpr( );
59 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
60 virtual void eval( Kernel::EvalState * evalState ) const;
61 virtual RefCountPtr< const Lang::Value > throwNotApplicable( const Lang::Value * arg ) const;
64 class BinaryInfixExpr : public Expression
66 protected:
67 Ast::SourceLocation opLoc_;
68 Ast::Expression * expr1_;
69 Ast::Expression * expr2_;
70 public:
71 BinaryInfixExpr( const Ast::SourceLocation & opLoc, Ast::Expression * expr1, Ast::Expression * expr2 );
72 virtual ~BinaryInfixExpr( );
73 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
74 virtual void eval( Kernel::EvalState * evalState ) const;
75 virtual RefCountPtr< const Lang::Value > throwNotApplicable( const Lang::Value * arg1, const Lang::Value * arg2 ) const;
76 const Ast::Expression * get_expr2( ) const { return expr2_; } /* to be used by the continuation */
77 DEFAULTBINARYOPDECL;
82 namespace Kernel
85 class UnaryCont_1 : public Kernel::Continuation
87 const Ast::UnaryExpr * op_;
88 Kernel::PassedDyn dyn_;
89 Kernel::ContRef cont_;
90 public:
91 UnaryCont_1( const Ast::UnaryExpr * op, const Kernel::PassedDyn & dyn, const Kernel::ContRef & cont, const Ast::SourceLocation & traceLoc );
92 virtual ~UnaryCont_1( );
93 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
94 virtual Kernel::ContRef up( ) const;
95 virtual RefCountPtr< const char > description( ) const;
96 virtual void gcMark( Kernel::GCMarkedSet & marked );
99 class BinaryInfixCont_2 : public Kernel::Continuation
101 const Ast::BinaryInfixExpr * op_;
102 Kernel::ValueRef val1_;
103 Kernel::PassedDyn dyn_;
104 Kernel::ContRef cont_;
105 public:
106 BinaryInfixCont_2( const Ast::BinaryInfixExpr * op, const Kernel::ValueRef & val1, const Kernel::PassedDyn & dyn, const Kernel::ContRef & cont, const Ast::SourceLocation & traceLoc );
107 virtual ~BinaryInfixCont_2( );
108 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
109 virtual Kernel::ContRef up( ) const;
110 virtual RefCountPtr< const char > description( ) const;
111 virtual void gcMark( Kernel::GCMarkedSet & marked );
114 class BinaryInfixCont_1 : public Kernel::Continuation
116 const Ast::BinaryInfixExpr * op_;
117 Kernel::PassedEnv env_;
118 Kernel::PassedDyn dyn_;
119 Kernel::ContRef cont_;
120 public:
121 BinaryInfixCont_1( const Ast::BinaryInfixExpr * op, Kernel::EvalState & evalState, const Ast::SourceLocation & traceLoc );
122 virtual ~BinaryInfixCont_1( );
123 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
124 virtual Kernel::ContRef up( ) const;
125 virtual RefCountPtr< const char > description( ) const;
126 virtual void gcMark( Kernel::GCMarkedSet & marked );