mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 16:20:49 +01:00
Update functions to use the clone interface.
Change-Id: I6b4d6be5b1d963bc7d97851432e40844d3619d8d
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
}
|
||||
#include <poincare/function.h>
|
||||
#include "layout/function_layout.h"
|
||||
|
||||
Function::Function(Expression * arg, char* function_name, bool clone_operands) {
|
||||
m_arg = (Expression *)malloc(sizeof(Expression));
|
||||
m_function_name = function_name;
|
||||
if (clone_operands) {
|
||||
m_arg = arg->clone();
|
||||
} else {
|
||||
m_arg = arg;
|
||||
}
|
||||
}
|
||||
|
||||
Function::~Function() {
|
||||
delete m_arg;
|
||||
}
|
||||
@@ -8,3 +21,15 @@ Function::~Function() {
|
||||
ExpressionLayout * Function::createLayout(ExpressionLayout * parent) {
|
||||
return new FunctionLayout(parent, m_function_name, m_arg);
|
||||
}
|
||||
|
||||
Expression * Function::operand(int i) {
|
||||
if (i==0) {
|
||||
return m_arg;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
int Function::numberOfOperands() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user