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
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, 2014 Henrik Tidefelt
28 class UnaryExpr
: public Expression
31 UnaryExpr( const Ast::SourceLocation
& loc
);
32 UnaryExpr( const Ast::SourceLocation
& firstLoc
, const Ast::SourceLocation
& lastLoc
);
33 virtual ~UnaryExpr( );
34 virtual RefCountPtr
< const Lang::Value
> throwNotApplicable( const Lang::Value
* arg
) const = 0;
38 class UnaryPrefixExpr
: public UnaryExpr
41 Ast::SourceLocation opLoc_
; /* Note: Not a const reference. */
42 Ast::Expression
* expr_
;
44 UnaryPrefixExpr( const Ast::SourceLocation
& loc
, const Ast::SourceLocation
& opLoc
, Ast::Expression
* expr
);
45 UnaryPrefixExpr( const Ast::SourceLocation
& opLoc
, Ast::Expression
* expr
);
46 virtual ~UnaryPrefixExpr( );
47 virtual void analyze_impl( Ast::Node
* parent
, Ast::AnalysisEnvironment
* env
, Ast::StateIDSet
* freeStatesDst
);
48 virtual void eval( Kernel::EvalState
* evalState
) const;
49 virtual RefCountPtr
< const Lang::Value
> throwNotApplicable( const Lang::Value
* arg
) const;
52 class UnaryPostfixExpr
: public UnaryExpr
55 Ast::SourceLocation opLoc_
; /* Note: Not a const reference. */
56 Ast::Expression
* expr_
;
58 UnaryPostfixExpr( const Ast::SourceLocation
& opLoc
, Ast::Expression
* expr
);
59 virtual ~UnaryPostfixExpr( );
60 virtual void analyze_impl( Ast::Node
* parent
, Ast::AnalysisEnvironment
* env
, Ast::StateIDSet
* freeStatesDst
);
61 virtual void eval( Kernel::EvalState
* evalState
) const;
62 virtual RefCountPtr
< const Lang::Value
> throwNotApplicable( const Lang::Value
* arg
) const;
65 class BinaryInfixExpr
: public Expression
68 Ast::SourceLocation opLoc_
; /* Note: Not a const reference. */
69 Ast::Expression
* expr1_
;
70 Ast::Expression
* expr2_
;
72 BinaryInfixExpr( const Ast::SourceLocation
& opLoc
, Ast::Expression
* expr1
, Ast::Expression
* expr2
);
73 virtual ~BinaryInfixExpr( );
74 virtual void analyze_impl( Ast::Node
* parent
, Ast::AnalysisEnvironment
* env
, Ast::StateIDSet
* freeStatesDst
);
75 virtual void eval( Kernel::EvalState
* evalState
) const;
76 virtual RefCountPtr
< const Lang::Value
> throwNotApplicable( const Lang::Value
* arg1
, const Lang::Value
* arg2
) const;
77 const Ast::Expression
* get_expr2( ) const { return expr2_
; } /* to be used by the continuation */
86 class UnaryCont_1
: public Kernel::Continuation
88 const Ast::UnaryExpr
* op_
;
89 Kernel::PassedDyn dyn_
;
90 Kernel::ContRef cont_
;
92 UnaryCont_1( const Ast::UnaryExpr
* op
, const Kernel::PassedDyn
& dyn
, const Kernel::ContRef
& cont
, const Ast::SourceLocation
& traceLoc
);
93 virtual ~UnaryCont_1( );
94 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & val
, Kernel::EvalState
* evalState
, bool dummy
) const;
95 virtual Kernel::ContRef
up( ) const;
96 virtual RefCountPtr
< const char > description( ) const;
97 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
100 class BinaryInfixCont_2
: public Kernel::Continuation
102 const Ast::BinaryInfixExpr
* op_
;
103 Kernel::ValueRef val1_
;
104 Kernel::PassedDyn dyn_
;
105 Kernel::ContRef cont_
;
107 BinaryInfixCont_2( const Ast::BinaryInfixExpr
* op
, const Kernel::ValueRef
& val1
, const Kernel::PassedDyn
& dyn
, const Kernel::ContRef
& cont
, const Ast::SourceLocation
& traceLoc
);
108 virtual ~BinaryInfixCont_2( );
109 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & val
, Kernel::EvalState
* evalState
, bool dummy
) const;
110 virtual Kernel::ContRef
up( ) const;
111 virtual RefCountPtr
< const char > description( ) const;
112 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
115 class BinaryInfixCont_1
: public Kernel::Continuation
117 const Ast::BinaryInfixExpr
* op_
;
118 Kernel::PassedEnv env_
;
119 Kernel::PassedDyn dyn_
;
120 Kernel::ContRef cont_
;
122 BinaryInfixCont_1( const Ast::BinaryInfixExpr
* op
, Kernel::EvalState
& evalState
, const Ast::SourceLocation
& traceLoc
);
123 virtual ~BinaryInfixCont_1( );
124 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & val
, Kernel::EvalState
* evalState
, bool dummy
) const;
125 virtual Kernel::ContRef
up( ) const;
126 virtual RefCountPtr
< const char > description( ) const;
127 virtual void gcMark( Kernel::GCMarkedSet
& marked
);