Merge remote-tracking branch 'openscad/master'

This commit is contained in:
frankenstein 2017-03-01 13:13:27 -05:00
commit 113a8a9efb
9 changed files with 22 additions and 5391 deletions

View file

@ -41,7 +41,8 @@ public:
QTime renderingTime;
ModuleContext top_ctx;
FileModule *root_module; // Result of parsing
FileModule *root_module; // Result of parsing
FileModule *last_good_module; // Last successful parse for include list
ModuleInstantiation root_inst; // Top level instance
AbstractNode *absolute_root_node; // Result of tree evaluation
AbstractNode *root_node; // Root if the root modifier (!) is used

View file

@ -60,6 +60,7 @@ time_t ModuleCache::evaluate(const std::string &filename, FileModule *&module)
// Initialize entry, if new
if (!found) {
entry.module = nullptr;
entry.last_good_module = nullptr;
entry.cache_id = cache_id;
entry.includes_mtime = st.st_mtime;
}
@ -71,11 +72,10 @@ time_t ModuleCache::evaluate(const std::string &filename, FileModule *&module)
if (entry.cache_id == cache_id) {
shouldCompile = false;
// Recompile if includes changed
if (lib_mod) {
time_t mtime = lib_mod->includesChanged();
if (entry.last_good_module) {
time_t mtime = entry.last_good_module->includesChanged();
if (mtime > entry.includes_mtime) {
entry.includes_mtime = mtime;
lib_mod = nullptr;
shouldCompile = true;
}
}
@ -111,15 +111,14 @@ time_t ModuleCache::evaluate(const std::string &filename, FileModule *&module)
print_messages_push();
FileModule *oldmodule = lib_mod;
fs::path pathname = fs::path(filename);
lib_mod = parse(textbuf.str().c_str(), pathname, false);
PRINTDB(" compiled module: %p", lib_mod);
// We defer deletion so we can ensure that the new module won't
// have the same address as the old
if (oldmodule) delete oldmodule;
if (lib_mod) { // parse successful
delete entry.last_good_module;
entry.last_good_module = lib_mod;
}
entry.module = lib_mod;
entry.cache_id = cache_id;

View file

@ -24,6 +24,7 @@ private:
struct cache_entry {
class FileModule *module;
class FileModule *last_good_module; // the last version that parsed correctly for include list
std::string cache_id;
time_t mtime; // time file last modified
time_t includes_mtime; // time the includes last changed

View file

@ -239,6 +239,7 @@ MainWindow::MainWindow(const QString &filename)
top_ctx.registerBuiltin();
root_module = NULL;
last_good_module = NULL;
absolute_root_node = NULL;
#ifdef ENABLE_CGAL
this->cgalRenderer = NULL;
@ -735,8 +736,9 @@ void MainWindow::updateReorderMode(bool reorderMode)
MainWindow::~MainWindow()
{
if (root_module) delete root_module;
if (root_node) delete root_node;
delete root_module;
delete last_good_module;
delete root_node;
#ifdef ENABLE_CGAL
this->root_geom.reset();
delete this->cgalRenderer;
@ -972,8 +974,8 @@ void MainWindow::compile(bool reload, bool forcedone)
shouldcompiletoplevel = true;
}
if (!shouldcompiletoplevel && this->root_module) {
time_t mtime = this->root_module->includesChanged();
if (!shouldcompiletoplevel && this->last_good_module) {
time_t mtime = this->last_good_module->includesChanged();
if (mtime > this->includes_mtime) {
this->includes_mtime = mtime;
shouldcompiletoplevel = true;
@ -1776,12 +1778,13 @@ void MainWindow::compileTopLevelDocument()
std::string(this->last_compiled_doc.toUtf8().constData()) +
"\n" + commandline_commands;
delete this->root_module;
this->root_module = NULL;
auto fnameba = this->fileName.toLocal8Bit();
const char* fname = this->fileName.isEmpty() ? "" : fnameba;
this->root_module = parse(fulltext.c_str(), fs::path(fname), false);
if (this->root_module) {
delete this->last_good_module;
this->last_good_module = this->root_module;
}
if (Feature::ExperimentalCustomizer.is_enabled()) {
if (this->root_module!=NULL) {

View file

@ -1,5 +1,5 @@
//error.scad
a=10; // syntax error
a=10 // syntax error
b=2;
module errmod() { cube(a); }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,123 +0,0 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_PARSER_USERS_KINTEL_CODE_OPENSCAD_OPENSCAD_TESTS_PARSER_HXX_INCLUDED
# define YY_PARSER_USERS_KINTEL_CODE_OPENSCAD_OPENSCAD_TESTS_PARSER_HXX_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int parserdebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
TOK_ERROR = 258,
TOK_MODULE = 259,
TOK_FUNCTION = 260,
TOK_IF = 261,
TOK_ELSE = 262,
TOK_FOR = 263,
TOK_LET = 264,
TOK_ASSERT = 265,
TOK_ECHO = 266,
TOK_EACH = 267,
TOK_ID = 268,
TOK_STRING = 269,
TOK_USE = 270,
TOK_NUMBER = 271,
TOK_TRUE = 272,
TOK_FALSE = 273,
TOK_UNDEF = 274,
LE = 275,
GE = 276,
EQ = 277,
NE = 278,
AND = 279,
OR = 280,
LET = 281,
LOW_PRIO_RIGHT = 282,
LOW_PRIO_LEFT = 283,
HIGH_PRIO_RIGHT = 284,
HIGH_PRIO_LEFT = 285
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 75 "../src/parser.y" /* yacc.c:1909 */
char *text;
double number;
class Value *value;
class Expression *expr;
class Vector *vec;
class ModuleInstantiation *inst;
class IfElseModuleInstantiation *ifelse;
class Assignment *arg;
AssignmentList *args;
#line 97 "/Users/kintel/code/OpenSCAD/openscad/tests/parser.hxx" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
/* Location type. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE YYLTYPE;
struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE parserlval;
extern YYLTYPE parserlloc;
int parserparse (void);
#endif /* !YY_PARSER_USERS_KINTEL_CODE_OPENSCAD_OPENSCAD_TESTS_PARSER_HXX_INCLUDED */

View file

@ -1,123 +0,0 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_PARSER_USERS_KINTEL_CODE_OPENSCAD_OPENSCAD_TESTS_PARSER_YACC_H_INCLUDED
# define YY_PARSER_USERS_KINTEL_CODE_OPENSCAD_OPENSCAD_TESTS_PARSER_YACC_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int parserdebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
TOK_ERROR = 258,
TOK_MODULE = 259,
TOK_FUNCTION = 260,
TOK_IF = 261,
TOK_ELSE = 262,
TOK_FOR = 263,
TOK_LET = 264,
TOK_ASSERT = 265,
TOK_ECHO = 266,
TOK_EACH = 267,
TOK_ID = 268,
TOK_STRING = 269,
TOK_USE = 270,
TOK_NUMBER = 271,
TOK_TRUE = 272,
TOK_FALSE = 273,
TOK_UNDEF = 274,
LE = 275,
GE = 276,
EQ = 277,
NE = 278,
AND = 279,
OR = 280,
LET = 281,
LOW_PRIO_RIGHT = 282,
LOW_PRIO_LEFT = 283,
HIGH_PRIO_RIGHT = 284,
HIGH_PRIO_LEFT = 285
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 75 "../src/parser.y" /* yacc.c:1909 */
char *text;
double number;
class Value *value;
class Expression *expr;
class Vector *vec;
class ModuleInstantiation *inst;
class IfElseModuleInstantiation *ifelse;
class Assignment *arg;
AssignmentList *args;
#line 97 "/Users/kintel/code/OpenSCAD/openscad/tests/parser_yacc.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
/* Location type. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE YYLTYPE;
struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE parserlval;
extern YYLTYPE parserlloc;
int parserparse (void);
#endif /* !YY_PARSER_USERS_KINTEL_CODE_OPENSCAD_OPENSCAD_TESTS_PARSER_YACC_H_INCLUDED */