mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Merge branch 'upsilon-dev' into logic-toolbox
This commit is contained in:
@@ -159,7 +159,7 @@ public:
|
||||
Expression() : TreeHandle() {}
|
||||
Expression clone() const;
|
||||
static Expression Parse(char const * string, Context * context, bool addMissingParenthesis = true);
|
||||
static Expression ExpressionFromAddress(const void * address, size_t size);
|
||||
static Expression ExpressionFromAddress(const void * address, size_t size, const void * record=nullptr);
|
||||
|
||||
/* Circuit breaker */
|
||||
typedef bool (*CircuitBreaker)();
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -41,11 +43,19 @@ public:
|
||||
if (((uint64_t)mantissa >> (size()-k_mantissaNbBits-2)) & 1) {
|
||||
u.ui += 1;
|
||||
}
|
||||
return u.f;
|
||||
if (sizeof(T) == sizeof(float)) {
|
||||
return u.f32.f;
|
||||
} else {
|
||||
return u.f64.f;
|
||||
}
|
||||
}
|
||||
static int exponent(T f) {
|
||||
uint_float u;
|
||||
u.f = f;
|
||||
if (sizeof(T) == sizeof(float)) {
|
||||
u.f32.f = f;
|
||||
} else {
|
||||
u.f64.f = f;
|
||||
}
|
||||
constexpr uint16_t oneOnExponentsBits = maxExponent();
|
||||
int exp = (u.ui >> k_mantissaNbBits) & oneOnExponentsBits;
|
||||
exp -= exponentOffset();
|
||||
@@ -75,10 +85,28 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
#ifdef _BIG_ENDIAN
|
||||
union uint_float {
|
||||
uint64_t ui;
|
||||
T f;
|
||||
struct {
|
||||
uint32_t padding;
|
||||
float f;
|
||||
} f32;
|
||||
struct {
|
||||
double f;
|
||||
} f64;
|
||||
};
|
||||
#else
|
||||
union uint_float {
|
||||
uint64_t ui;
|
||||
struct {
|
||||
float f;
|
||||
} f32;
|
||||
struct {
|
||||
double f;
|
||||
} f64;
|
||||
};
|
||||
#endif
|
||||
|
||||
constexpr static size_t k_signNbBits = 1;
|
||||
constexpr static size_t k_exponentNbBits = sizeof(T) == sizeof(float) ? 8 : 11;
|
||||
|
||||
@@ -5,6 +5,14 @@
|
||||
#include <assert.h>
|
||||
#include <poincare/horizontal_layout.h>
|
||||
|
||||
#ifdef _FXCG
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class ExpressionLayout;
|
||||
@@ -13,12 +21,17 @@ class LayoutNode;
|
||||
class Integer;
|
||||
struct IntegerDivision;
|
||||
|
||||
#ifdef _3DS
|
||||
#if (defined _3DS) || (defined _FXCG) || defined NSPIRE_NEWLIB
|
||||
typedef unsigned short half_native_uint_t;
|
||||
static_assert(sizeof(half_native_uint_t) == sizeof(uint16_t));
|
||||
typedef int native_int_t;
|
||||
static_assert(sizeof(native_int_t) == sizeof(int32_t));
|
||||
typedef long long int double_native_int_t;
|
||||
static_assert(sizeof(double_native_int_t) == sizeof(int64_t));
|
||||
typedef unsigned int native_uint_t;
|
||||
static_assert(sizeof(native_uint_t) == sizeof(uint32_t));
|
||||
typedef unsigned long long int double_native_uint_t;
|
||||
static_assert(sizeof(double_native_uint_t) == sizeof(uint64_t));
|
||||
#else
|
||||
typedef uint16_t half_native_uint_t;
|
||||
typedef int32_t native_int_t;
|
||||
@@ -215,7 +228,12 @@ private:
|
||||
if (i >= numberOfHalfDigits()) {
|
||||
return 0;
|
||||
}
|
||||
return (usesImmediateDigit() ? ((half_native_uint_t *)&m_digit)[i] : ((half_native_uint_t *)digits())[i]);
|
||||
native_uint_t d = usesImmediateDigit() ? m_digit : digits()[i/2];
|
||||
if (i % 2 == 0) {
|
||||
return d & 0xFFFF;
|
||||
} else {
|
||||
return d >> 16;
|
||||
}
|
||||
}
|
||||
|
||||
native_uint_t digit(uint8_t i) const {
|
||||
|
||||
@@ -138,7 +138,7 @@ private:
|
||||
private:
|
||||
uint16_t m_currentIndex;
|
||||
uint16_t m_availableIdentifiers[MaxNumberOfNodes];
|
||||
static_assert(MaxNumberOfNodes < INT16_MAX && sizeof(m_availableIdentifiers[0] == sizeof(uint16_t)), "Tree node identifiers do not have the right data size.");
|
||||
static_assert(MaxNumberOfNodes < INT16_MAX && sizeof(m_availableIdentifiers[0]) == sizeof(uint16_t), "Tree node identifiers do not have the right data size.");
|
||||
};
|
||||
|
||||
void freePoolFromNode(TreeNode * firstNodeToDiscard);
|
||||
|
||||
Reference in New Issue
Block a user