mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
@@ -135,7 +135,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)();
|
||||
|
||||
@@ -21,7 +21,7 @@ class LayoutNode;
|
||||
class Integer;
|
||||
struct IntegerDivision;
|
||||
|
||||
#if (defined _3DS) || (defined _FXCG)
|
||||
#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;
|
||||
|
||||
@@ -38,10 +38,42 @@ Expression Expression::Parse(char const * string, Context * context, bool addPar
|
||||
return expression;
|
||||
}
|
||||
|
||||
Expression Expression::ExpressionFromAddress(const void * address, size_t size) {
|
||||
Expression Expression::ExpressionFromAddress(const void * address, size_t size, const void * record) {
|
||||
if (address == nullptr || size == 0) {
|
||||
return Expression();
|
||||
}
|
||||
#ifdef STRING_STORAGE
|
||||
// Check that expression was stored as a string in record
|
||||
size_t i;
|
||||
const char * ptr=(const char *) address;
|
||||
for (i=1;i<size && ptr[i];++i){
|
||||
if (ptr[i]=='"')
|
||||
break;
|
||||
}
|
||||
if (i < 1024 && ptr[0]=='"' && i > 0 && i < size && ptr[i] == '"') {
|
||||
((char *)ptr)[i] = 0;
|
||||
Expression e = Expression::Parse(ptr + 1, nullptr);
|
||||
((char *)ptr)[i] = '"';
|
||||
address = e.addressInPool();
|
||||
size = e.size();
|
||||
if (record) {
|
||||
const char * name = ((const Ion::Storage::Record *)record)->fullName();
|
||||
char repl = 0;
|
||||
int l = strlen(name);
|
||||
if (strncmp(name+l-4,".seq",4) == 0) {
|
||||
repl='n';
|
||||
} else if (strncmp(name+l-5,".func",5) == 0) {
|
||||
repl='x';
|
||||
}
|
||||
if (repl){
|
||||
e=e.replaceSymbolWithExpression(Symbol::Builder(repl),Symbol::Builder(UCodePointUnknown));
|
||||
address= e.addressInPool();
|
||||
size=e.size();
|
||||
}
|
||||
}
|
||||
return Expression(static_cast<ExpressionNode *>(TreePool::sharedPool()->copyTreeFromAddress(address, size))); // must be done before e is destroyed
|
||||
}
|
||||
#endif
|
||||
// Build the Expression in the Tree Pool
|
||||
return Expression(static_cast<ExpressionNode *>(TreePool::sharedPool()->copyTreeFromAddress(address, size)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user