* Implementation of GiNaC's parser. */
/*
- * GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "lexer.h"
#include "debug.h"
#include "mul.h"
-#include "function.h"
#include "constant.h"
+#include "function.h"
#include <sstream>
#include <stdexcept>
Parse_error_("no function \"" << name << "\" with " <<
args.size() << " arguments");
}
- ex ret = function(reader->second, args);
- return ret;
+ // dirty hack to distinguish between serial numbers of functions and real
+ // pointers.
+ GiNaC::function* f = NULL;
+ try {
+ unsigned serial = (unsigned)(unsigned long)(void *)(reader->second);
+ f = new GiNaC::function(serial, args);
+ }
+ catch ( std::runtime_error ) {
+ if ( f ) delete f;
+ ex ret = reader->second(args);
+ return ret;
+ }
+ return f->setflag(status_flags::dynallocated);
}
/// paren_expr: '(' expression ')'