Poincare: Add a LeafExpression class

Parent of Symbol, Integer, Float

Change-Id: I866ec888b007ea8e486f5627039f934bddcc9ace
This commit is contained in:
Romain Goyet
2016-03-24 15:48:11 +01:00
parent 59092a66df
commit aa3595ad54
5 changed files with 27 additions and 10 deletions

View File

@@ -1,17 +1,19 @@
SFLAGS += -Ipoincare/include
objs += $(addprefix poincare/src/,\
addition.o\
binary_operation.o\
commutative_operation.o\
context.o\
expression.o\
float.o\
integer.o\
fraction.o\
expression_lexer.o\
expression_parser.o\
subtraction.o\
float.o\
fraction.o\
integer.o\
leaf_expression.o\
power.o\
product.o\
subtraction.o\
symbol.o\
)
objs += $(addprefix poincare/src/layout/,\
@@ -31,6 +33,7 @@ tests += $(addprefix poincare/test/,\
integer.cpp\
product.cpp\
simplify.cpp\
simplify_addition_integer.cpp\
subtraction.cpp\
)

View File

@@ -1,9 +1,9 @@
#ifndef POINCARE_FLOAT_H
#define POINCARE_FLOAT_H
#include <poincare/expression.h>
#include <poincare/leaf_expression.h>
class Float : public Expression {
class Float : public LeafExpression {
public:
Float(float f);
~Float();

View File

@@ -1,14 +1,14 @@
#ifndef POINCARE_INTEGER_H
#define POINCARE_INTEGER_H
#include <poincare/expression.h>
#include <poincare/leaf_expression.h>
#include <stdint.h>
typedef int32_t native_int_t;
typedef uint32_t native_uint_t;
typedef uint64_t double_native_uint_t;
class Integer : public Expression {
class Integer : public LeafExpression {
public:
Integer(native_int_t i);
Integer(Integer&& other); // C++11 move constructor

View File

@@ -1,9 +1,9 @@
#ifndef POINCARE_SYMBOL_H
#define POINCARE_SYMBOL_H
#include <poincare/expression.h>
#include <poincare/leaf_expression.h>
class Symbol : public Expression {
class Symbol : public LeafExpression {
public:
Symbol(char * name);
~Symbol();

View File

@@ -0,0 +1,14 @@
#include <poincare/leaf_expression.h>
extern "C" {
#include <assert.h>
#include <stdlib.h>
}
int LeafExpression::numberOfOperands() {
return 0;
}
Expression * LeafExpression::operand(int i) {
assert(false);
return nullptr;
}