File: BinaryExpression.h

package info (click to toggle)
guavac 1.0-5
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 2,716 kB
  • ctags: 2,357
  • sloc: cpp: 19,765; yacc: 1,629; makefile: 492; lex: 348; ansic: 284; sh: 280
file content (45 lines) | stat: -rw-r--r-- 1,753 bytes parent folder | download | duplicates (2)
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
// Copyright (c) 1996  David Engberg  All rights reserved
// $Id: BinaryExpression.h,v 1.4 1997/04/28 19:25:03 geppetto Exp $
#ifndef _BinaryExpression_h
#define _BinaryExpression_h
#pragma interface

#include "Expression.h"
#include "JavaTypeSignature.h"

//
//  Class name : CBinaryExpression
//  Description : Represents an expression composed of a pair of expressions
//    joined with a binary operator.  Stores the operator and both expressions.
//    I put this in a separate file since it's so ungodly huge.
//
class CBinaryExpression : public CExpression {
  DynamicCastDeclarations;
public:
  CBinaryExpression(CExpression* leftExpression, unsigned short binaryOperator,
		    CExpression* rightExpression);
  CBinaryExpression(const CBinaryExpression& source);
  virtual ~CBinaryExpression();
  virtual CExpression* Clone() const { return new CBinaryExpression(*this); }
  virtual CCompileError* CreateConstantExpression(CExpression*& result,
			  CCompileContext& context) const;
  virtual CCompileError* GenerateCode(CCodeSequence& code,
		   CCompileContext& context, unsigned short& stackUsed,
	           bool isStatement = false);
  const CExpression* GetLeftArgument() const { return fLeft; }
  const CExpression* GetRightArgument() const { return fRight; }
protected:
  virtual CCompileError* HandleEvaluateType(CCompileContext& context,
					    CJavaTypeSignature& setType);
  CCompileError* AppendToStringBuffer(CCodeSequence& code,
	      CExpression* childExpression, CCompileContext& compiler,
	      unsigned short& stackUsed);
private:
  void ReduceInteger(CCodeSequence& code, CJavaTypeSignature::JavaType type);

  CExpression* fLeft;
  CExpression* fRight;
  unsigned short fOperator;   // taken from parser.y/h
};

#endif