Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elkhound/glr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ STATICDEF bool GLR

// some debugging streams so the TRSPARSE etc. macros work
bool trParse = glr.trParse;
ostream &trsParse = glr.trsParse;
std::ostream &trsParse = glr.trsParse;
#endif
for (;;) {
// debugging
Expand Down
90 changes: 90 additions & 0 deletions elkhound/glrconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// glrconfig.h see license.txt for copyright and terms of use
// compile-time configuration options which affect the generated
// GLR parser, and the interface to the user actions

#ifndef GLRCONFIG_H
#define GLRCONFIG_H


// when NO_GLR_SOURCELOC is #defined, we disable all support for
// automatically propagating source location information in the
// parser; user actions can still refer to 'loc', but they just get
// a dummy no-location value
#ifndef GLR_SOURCELOC
#define GLR_SOURCELOC 1 // set by ./configure
#endif

#if GLR_SOURCELOC
#define SOURCELOC(stuff) stuff
#define ENDSOURCELOC(stuff) stuff

// this one adds a leading comma (I can't put that into the
// argument <stuff>, because then it looks like the macro is
// being passed 2 arguments)
#define SOURCELOCARG(stuff) , stuff
#define ENDSOURCELOCARG(stuff) , stuff

#define NOSOURCELOC(stuff)
#else
#define SOURCELOC(stuff)
#define SOURCELOCARG(stuff)
#define NOSOURCELOC(stuff) stuff
#endif


// when enabled, NODE_COLUMN tracks in each stack node the
// appropriate column to display it for in debugging dump.
// in the new RWL core, this is required to always be 1.
#ifndef ENABLE_NODE_COLUMNS
#define ENABLE_NODE_COLUMNS 1
#endif
#if ENABLE_NODE_COLUMNS
#define NODE_COLUMN(stuff) stuff
#else
#define NODE_COLUMN(stuff)
#endif


// when enabled, YIELD_COUNT keeps track of the number of times a
// given semantic value is yielded; this is useful for warning the
// user when a merge is performed but one of the merged values has
// already been yielded to another semantic action, which implies
// that the induced parse forest is incomplete
#ifndef ENABLE_YIELD_COUNT
#define ENABLE_YIELD_COUNT 1
#endif
#if ENABLE_YIELD_COUNT
#define YIELD_COUNT(stuff) stuff
#else
#define YIELD_COUNT(stuff)
#endif


// when true, error entries in the action table are extracted into
// their own bitmap; this then enables compression on the action
// table, since it makes it sparse
#ifndef ENABLE_EEF_COMPRESSION
#define ENABLE_EEF_COMPRESSION 0
#endif

// when true, the action and goto tables are compressed using
// graph coloring
#ifndef ENABLE_GCS_COMPRESSION
#define ENABLE_GCS_COMPRESSION 0
#endif

// when true, action and goto *columns* are merged during GCS;
// otherwise, only rows are merged
#ifndef ENABLE_GCS_COLUMN_COMPRESSION
#define ENABLE_GCS_COLUMN_COMPRESSION 0
#endif

// when true, entries in the action and goto tables are a
// 1-byte index into an appropriate map
#ifndef ENABLE_CRS_COMPRESSION
#define ENABLE_CRS_COMPRESSION 0
#endif



#endif // GLRCONFIG_H
4 changes: 2 additions & 2 deletions elsa/baselexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#else
// should work on any compiler that implements the C++98 standard
// (istrstream is deprecated but still standard)
#include <strstream.h> // istrstream
#include <strstream> // istrstream

inline std::istream *construct_istrstream(char const *buf, int len)
{
return new istrstream(buf, len);
return new std::istrstream(buf, len);
}
#endif

Expand Down
6 changes: 4 additions & 2 deletions elsa/cc_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ void fromXml(CVFlags &out, char const *str);
ENUM_BITWISE_OPS(CVFlags, CV_ALL)

// experiment: superset operator
inline bool operator>= (CVFlags cv1, CVFlags cv2)
// replaced 'operator >=' with 'superset()' to solve VisualStudio enum operator overloading bug
inline bool superset(CVFlags cv1, CVFlags cv2)
{ return (cv1 & cv2) == cv2; }


Expand Down Expand Up @@ -143,7 +144,8 @@ void fromXml(DeclFlags &out, char const *str);

ENUM_BITWISE_OPS(DeclFlags, ALL_DECLFLAGS)

inline bool operator>= (DeclFlags df1, DeclFlags df2)
// replaced 'operator >=' with 'superset()' to solve VisualStudio enum operator overloading bug
inline bool superset(DeclFlags df1, DeclFlags df2)
{ return (df1 & df2) == df2; }

// helper of possibly general purpose
Expand Down
8 changes: 4 additions & 4 deletions elsa/cc_tcheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ void Function::tcheck(Env &env, Variable *instV)

// supply DF_DEFINITION?
DeclFlags dfDefn = (checkBody? DF_DEFINITION : DF_NONE);
if (dflags >= (DF_EXTERN | DF_INLINE) &&
if (superset(dflags, (DF_EXTERN | DF_INLINE)) &&
env.lang.handleExternInlineSpecially &&
handleExternInline_asPrototype()) {
// gcc treats extern-inline function definitions specially:
Expand Down Expand Up @@ -674,7 +674,7 @@ void Function::tcheckBody(Env &env)
// stop extending the named scope, if there was one
env.retractScopeSeq(qualifierScopes);

if (dflags >= (DF_EXTERN | DF_INLINE) &&
if (superset(dflags, (DF_EXTERN | DF_INLINE)) &&
env.lang.handleExternInlineSpecially &&
handleExternInline_asPrototype()) {
// more extern-inline nonsense; skip 'funcDefn' setting
Expand Down Expand Up @@ -3572,7 +3572,7 @@ void Declarator::mid_tcheck(Env &env, Tcheck &dt)
// DF_FRIEND gets turned off by 'declareNewVariable' ...
bool isFriend = !!(dt.dflags & DF_FRIEND);

if ((dt.dflags >= (DF_EXTERN | DF_INLINE)) && env.lang.handleExternInlineSpecially) {
if (superset(dt.dflags, (DF_EXTERN | DF_INLINE)) && env.lang.handleExternInlineSpecially) {
// dsw: We want to add a flag saying that this isn't really an
// extern inline. This is necessary because sometimes we still
// need to know later that it started off as an extern inline even
Expand Down Expand Up @@ -8467,7 +8467,7 @@ Type *attemptCondConversion(Env &env, ImplicitConversion &ic /*OUT*/,
t2Class->hasBaseClass(t1Class))) {
// bullet 2.1
if (t1Class->hasBaseClass(t2Class) &&
t2->asRval()->getCVFlags() >= t1->asRval()->getCVFlags()) {
superset(t2->asRval()->getCVFlags(), t1->asRval()->getCVFlags())) {
ic.addStdConv(SC_IDENTITY);
return t2->asRval();
}
Expand Down
3 changes: 3 additions & 0 deletions elsa/configure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

# defaults
@LDFLAGS = ("-g -Wall");
@CCFLAGS = "-DXML";
$AST = "../ast";
$ELKHOUND = "../elkhound";
$USE_GNU = "1";
Expand Down Expand Up @@ -152,6 +153,7 @@ package options:
$summary .= <<"OUTER_EOF";
cat <<EOF
LDFLAGS: @LDFLAGS
CCFLAGS: @CCFLAGS
SMBASE: $SMBASE
AST: $AST
ELKHOUND: $ELKHOUND
Expand All @@ -169,6 +171,7 @@ package options:

# ------------------- config.status ------------------
writeConfigStatus("LDFLAGS" => "@LDFLAGS",
"CCFLAGS" => "@CCFLAGS",
"SMBASE" => "$SMBASE",
"AST" => "$AST",
"ELKHOUND" => "$ELKHOUND",
Expand Down
17 changes: 12 additions & 5 deletions elsa/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
#include "smregexp.h" // regexpMatch
#include "cc_elaborate.h" // ElabVisitor
#include "integrity.h" // IntegrityVisitor
#include "xml_file_writer.h" // XmlFileWriter
#include "xml_reader.h" // xmlDanglingPointersAllowed
#include "xml_do_read.h" // xmlDoRead()
#include "xml_type_writer.h" // XmlTypeWriter
#if XML
# include "xml_file_writer.h" // XmlFileWriter
# include "xml_reader.h" // xmlDanglingPointersAllowed
# include "xml_do_read.h" // xmlDoRead()
# include "xml_type_writer.h" // XmlTypeWriter
#endif
#include "bpprint.h" // bppTranslationUnit
#include "cc2c.h" // cc_to_c

Expand Down Expand Up @@ -395,14 +397,17 @@ void doit(int argc, char **argv)

int parseWarnings = 0;
long parseTime = 0;
#if XML
if (tracingSys("parseXml")) {
if (tracingSys("parseXml-no-danglingPointers")) {
xmlDanglingPointersAllowed = false;
}
unit = xmlDoRead(strTable, inputFname);
if (!unit) return;
}
else {
else
#endif
{
SectionTimer timer(parseTime);
SemanticValue treeTop;
ParseTreeAndTokens tree(lang, treeTop, strTable, inputFname);
Expand Down Expand Up @@ -723,6 +728,7 @@ void doit(int argc, char **argv)
bppTranslationUnit(std::cout, *unit);
}

#if XML
// dsw: xml printing of the raw ast
if (tracingSys("xmlPrintAST")) {
traceProgress() << "dsw xml print...\n";
Expand Down Expand Up @@ -762,6 +768,7 @@ void doit(int argc, char **argv)
std::cout << "---- STOP ----" << std::endl;
traceProgress() << "dsw xml print... done\n";
}
#endif

// test AST cloning
if (tracingSys("testClone")) {
Expand Down
6 changes: 3 additions & 3 deletions elsa/mtype.cc
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ bool IMType::equalWithAppliedCV(Type const *conc, Binding *binding, CVFlags cv,
if (!( flags & MF_OK_DIFFERENT_CV )) {
// The 'cv' flags supplied are subtracted from those in 'conc'.
CVFlags concCV = conc->getCVFlags();
if (concCV >= cv) {
if (superset(concCV, cv)) {
// example:
// conc = 'struct B volatile const'
// binding = 'struct B'
Expand Down Expand Up @@ -934,7 +934,7 @@ bool IMType::imatchCVFlags(CVFlags conc, CVFlags pat, MatchFlags flags)
// TODO: this is wrong, as it does not correctly implement
// 14.8.2.1; I am only implementing this because it emulates
// what matchtype does right now
if (pat >= conc) {
if (superset(pat, conc)) {
return true;
}
else {
Expand Down Expand Up @@ -966,7 +966,7 @@ bool IMType::imatchReferenceType(ReferenceType const *conc, ReferenceType const
// this only approximates 14.8.2.1, but emulates current matchtype
// behavior (actually, it emulates only the intended matchtype
// behavior; see comment added 2005-08-03 to MatchTypes::match_ref)
if (pat->atType->getCVFlags() >= conc->atType->getCVFlags()) {
if (superset(pat->atType->getCVFlags(), conc->atType->getCVFlags())) {
// disable further comparison of these cv-flags
flags |= MF_IGNORE_TOP_CV;
}
Expand Down
5 changes: 4 additions & 1 deletion smbase/ckheap.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ extern "C" {
#endif


#ifdef __WIN32__
#if defined(__WIN32__) || defined(_WIN32)
// don't want to try to get dlmalloc working...
// don't want to try to get dlmalloc working...
#define checkHeapNode(n) /*nothing*/
#define checkHeap() /*nothing*/
#define numMallocCalls() /*nothing*/
#define malloc_stats() ((void)0)
#else

Expand Down
2 changes: 2 additions & 0 deletions smbase/cycles.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void getCycles(unsigned *lowp, unsigned *highp);
// if we're using gcc, so the 'long long' type is available,
// here's a more convenient version
unsigned long long getCycles_ll(void);
#else
inline unsigned long long getCycles_ll(void) { return 0; } // !!!
#endif


Expand Down
Loading