Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into msvc-support
Browse files Browse the repository at this point in the history
  • Loading branch information
jamievlin committed Apr 11, 2024
2 parents da0ecbd + 8371bce commit b2f03f0
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 81 deletions.
23 changes: 9 additions & 14 deletions doc/asymptote.texi
Original file line number Diff line number Diff line change
Expand Up @@ -4424,13 +4424,13 @@ the total system cputime followed by ``S''.
@cindex inheritance
@cindex virtual functions
Much like in C++, casting (@pxref{Casts}) provides for an elegant
implementation of structure inheritance, including virtual functions:
implementation of structure inheritance, including a virtual function @code{v}:
@verbatim
struct parent {
real x;
void operator init(int x) {this.x=x;}
void virtual(int) {write(0);}
void f() {virtual(1);}
void v(int) {write(0);}
void f() {v(1);}
}
void write(parent p) {write(p.x);}
Expand All @@ -4439,8 +4439,8 @@ struct child {
parent parent;
real y=3;
void operator init(int x) {parent.operator init(x);}
void virtual(int x) {write(x);}
parent.virtual=virtual;
void v(int x) {write(x);}
parent.v=v;
void f()=parent.f;
}
Expand Down Expand Up @@ -9628,19 +9628,14 @@ produced using the @code{-f} option (or @code{outformat} setting).

@cindex @code{SVG}
@cindex @code{dvisvgm}
@cindex @code{libgs}
@cindex @code{graphic}
To produce @acronym{SVG} output, you will need @code{dvisvgm} (version
2.6.3 or later) from @url{https://dvisvgm.de}.
You might need to adjust the configuration variable @code{libgs} to
point to the location of your @code{Ghostscript} library
@code{libgs.so} (or to an empty string, depending on how
@code{dvisvgm} was configured). The 2.13.1 version (or later) of
@code{dvisvgm} can display @acronym{SVG} output (used by the
3.2.1 or later) from @url{https://dvisvgm.de},
which can display @acronym{SVG} output (used by the
@code{xasy} editor) for embedded @acronym{EPS}, @acronym{PDF},
@acronym{PNG}, and @acronym{JPEG} images included with the
@code{graphic()} function. You can optimize the generated output with
@code{settings.dvisvgmOptions="--optimize"}.
@code{graphic()} function. The generated output is optimized
with the default setting @code{settings.dvisvgmOptions="--optimize"}.

@code{Asymptote} can also produce any output format supported
by the @code{ImageMagick} @code{convert} program (version 6.3.5 or
Expand Down
9 changes: 6 additions & 3 deletions include/dec.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ class block : public runnable {
types::record *transAsFile(genv& ge, symbol id);

types::record *transAsTemplatedFile(
genv& ge, symbol id, mem::vector<absyntax::namedTyEntry*> *args
genv& ge,
symbol id,
mem::vector<absyntax::namedTyEntry*> *args,
trans::frame *parent
);

// If the block can be interpreted as a single vardec, return that vardec
Expand Down Expand Up @@ -618,7 +621,7 @@ class typeParam : public absyn {
typeParam(position pos, symbol paramSym)
: absyn(pos), paramSym(paramSym) {}

bool transAsParamMatcher(coenv &e, namedTyEntry *arg);
bool transAsParamMatcher(coenv &e, record *r, namedTyEntry *arg);

void prettyprint(ostream &out, Int indent);
};
Expand All @@ -631,7 +634,7 @@ class typeParamList : public absyn {

void add(typeParam *tp);

bool transAsParamMatcher(coenv &e, mem::vector<namedTyEntry*> *args);
bool transAsParamMatcher(coenv &e, record *r, mem::vector<namedTyEntry*> *args);

void prettyprint(ostream &out, Int indent);
};
Expand Down
3 changes: 2 additions & 1 deletion include/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ class env : public protoenv {
record *getTemplatedModule(symbol id,
string filename,
string index,
mem::vector<absyntax::namedTyEntry*> *args
mem::vector<absyntax::namedTyEntry*> *args,
trans::frame *parent
);
};

Expand Down
4 changes: 2 additions & 2 deletions include/fileio.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "common.h"

#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
#include "xstream.h"
#endif

Expand Down Expand Up @@ -642,7 +642,7 @@ class obfile : public ofile {
void writeline() {}
};

#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC

class ixfile : public file {
protected:
Expand Down
12 changes: 8 additions & 4 deletions include/genv.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ class genv : public gc {
// Translate a module to build the record type.
record *loadModule(symbol name, string s);
record *loadTemplatedModule(
symbol name, string s, mem::vector<absyntax::namedTyEntry*> *args
symbol id,
string filename,
mem::vector<absyntax::namedTyEntry*> *args,
trans::frame *parent
);

public:
Expand All @@ -54,10 +57,11 @@ class genv : public gc {
// Get an imported module, translating if necessary.
record *getModule(symbol name, string s);
record *getTemplatedModule(
symbol name,
string s,
symbol id,
string filename,
string sigHandle,
mem::vector<absyntax::namedTyEntry*> *args
mem::vector<absyntax::namedTyEntry*> *args,
frame *parent
);

// Uses the filename->record map to build a filename->initializer map to be
Expand Down
4 changes: 2 additions & 2 deletions include/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "common.h"
#include "angle.h"

#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
#include "xstream.h"
#endif

Expand Down Expand Up @@ -235,7 +235,7 @@ class pair : public gc {
return out;
}

#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
friend xdr::oxstream& operator << (xdr::oxstream& out, pair const& v)
{
out << v.x << v.y;
Expand Down
4 changes: 2 additions & 2 deletions include/processutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "transform.h"
#include "parser.h"

#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
#include "xstream.h"
#endif

Expand Down Expand Up @@ -116,7 +116,7 @@ struct processDataStruct {

terminator<std::ofstream> ofile;
terminator<std::fstream> ifile;
#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
terminator<xdr::ixstream> ixfile;
terminator<xdr::oxstream> oxfile;
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class statistics {
return stdev(varH,2.0);
}
double stderror() {
return stdev()/sqrt(N);
return stdev()/sqrt((double) N);
}
double median() {
if(!computeMedian) {
Expand Down
5 changes: 2 additions & 3 deletions include/symbolmaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,8 @@ namespace AsymptoteLsp
ExternalRefs(ExternalRefs const& exRef) = default;
ExternalRefs& operator=(ExternalRefs const& exRef) = default;

ExternalRefs(ExternalRefs&& exRef) noexcept = default;
ExternalRefs& operator=(ExternalRefs&& exRef) noexcept = default;

// ExternalRefs(ExternalRefs&& exRef) noexcept = default;
// ExternalRefs& operator=(ExternalRefs&& exRef) noexcept = default;

void clear()
{
Expand Down
4 changes: 2 additions & 2 deletions include/triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "angle.h"
#include "pair.h"

#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
#include "xstream.h"
#endif

Expand Down Expand Up @@ -332,7 +332,7 @@ class triple : virtual public gc {
}


#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
friend xdr::oxstream& operator << (xdr::oxstream& out, triple const& v)
{
out << v.x << v.y << v.z;
Expand Down
1 change: 1 addition & 0 deletions include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ struct signature : public gc {
return n >= formals.size() - numKeywordOnly;
}

friend string toString(const signature& s);
friend ostream& operator<< (ostream& out, const signature& s);

friend bool equivalent(const signature *s1, const signature *s2);
Expand Down
2 changes: 1 addition & 1 deletion include/v3dfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "common.h"

#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC

#include "abs3doutfile.h"
#include "xstream.h"
Expand Down
4 changes: 2 additions & 2 deletions prc/include/prc/oPRCFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "writePRC.h"


#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
#include "xstream.h"
#endif

Expand Down Expand Up @@ -94,7 +94,7 @@ struct RGBAColour
friend RGBAColour operator * (const double d, const RGBAColour& a)
{ return RGBAColour(a.R*d,a.G*d,a.B*d,a.A*d); }

#ifdef HAVE_RPC_RPC_H
#ifdef HAVE_LIBTIRPC
friend xdr::oxstream& operator<<(xdr::oxstream& out, RGBAColour const& col)
{
out << (float) col.R << (float) col.G << (float) col.B << (float) col.A;
Expand Down
2 changes: 1 addition & 1 deletion resources/asymptote.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%global __python %{__python3}

Name: asymptote
Version: 2.87
Version: 2.89
Release: 1%{?dist}
Summary: Descriptive vector graphics language

Expand Down
34 changes: 26 additions & 8 deletions src/dec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,13 @@ record *block::transAsFile(genv& ge, symbol id)
}

record *block::transAsTemplatedFile(
genv& ge, symbol id, mem::vector<absyntax::namedTyEntry*>* args
genv& ge,
symbol id,
mem::vector<absyntax::namedTyEntry*>* args,
frame *parent
) {
// Create the new module.
record *r = new record(id, new frame(id,0,0));
record *r = new record(id, new frame(id,parent,0));

// Create coder and environment to translate the module.
// File-level modules have dynamic fields by default.
Expand Down Expand Up @@ -908,7 +911,11 @@ varEntry *accessTemplatedModule(position pos, coenv &e, record *r, symbol id,
));
}

record *imp=e.e.getTemplatedModule(id, (string) id, sigHandle, computedArgs);
record *imp=e.e.getTemplatedModule(id,
(string) id,
sigHandle,
computedArgs,
e.c.getFrame());
if (!imp) {
em.error(pos);
em << "could not load module '" << id << "'";
Expand Down Expand Up @@ -1054,7 +1061,7 @@ void typeParam::prettyprint(ostream &out, Int indent) {
out << "typeParam (" << paramSym << ")\n";
}

bool typeParam::transAsParamMatcher(coenv &e, namedTyEntry* arg) {
bool typeParam::transAsParamMatcher(coenv &e, record *r, namedTyEntry* arg) {
if (arg->dest != paramSym) {
em.error(arg->pos);
em << "template argument name does not match module: passed "
Expand All @@ -1063,7 +1070,18 @@ bool typeParam::transAsParamMatcher(coenv &e, namedTyEntry* arg) {
<< paramSym;
return false;
}
e.e.addType(paramSym, arg->ent);
addTypeWithPermission(e, r, arg->ent, paramSym);
types::ty *t = arg->ent->t;
if (t->kind == types::ty_record) {
record *local = dynamic_cast<record *>(t);
// copied from recorddecc::addPostRecordEnvironment, mutatis mutandis
if (r) {
r->e.add(local->postdefenv, 0, e.c);
}
e.e.add(local->postdefenv, 0, e.c);
}

//e.e.addType(paramSym, arg->ent);
// The code below would add e.g. operator== to the context, but potentially
// ignore overrides of operator==:
//
Expand Down Expand Up @@ -1098,7 +1116,7 @@ void typeParamList::add(typeParam *tp) {
}

bool typeParamList::transAsParamMatcher(
coenv &e, mem::vector<namedTyEntry*> *args
coenv &e, record *r, mem::vector<namedTyEntry*> *args
) {
if (args->size() != params.size()) {
position pos = getPos();
Expand All @@ -1116,7 +1134,7 @@ bool typeParamList::transAsParamMatcher(
return false;
}
for (size_t i = 0; i < params.size(); ++i) {
bool succeeded = params[i]->transAsParamMatcher(e, (*args)[i]);
bool succeeded = params[i]->transAsParamMatcher(e, r, (*args)[i]);
if (!succeeded) return false;
}
return true;
Expand All @@ -1136,7 +1154,7 @@ symbol templatedSymbol() {
bool receiveTypedefDec::transAsParamMatcher(
coenv& e, record *r, mem::vector<namedTyEntry*> *args
) {
bool succeeded = params->transAsParamMatcher(e, args);
bool succeeded = params->transAsParamMatcher(e, r, args);

types::ty *intTy = e.e.lookupType(intSymbol());
assert(intTy);
Expand Down
5 changes: 3 additions & 2 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@ record *env::getModule(symbol id, string filename)
record *env::getTemplatedModule(symbol id,
string filename,
string index,
mem::vector<absyntax::namedTyEntry*>* args)
mem::vector<absyntax::namedTyEntry*>* args,
trans::frame *parent)
{
return ge.getTemplatedModule(id, filename, index, args);
return ge.getTemplatedModule(id, filename, index, args, parent);
}


Expand Down
4 changes: 2 additions & 2 deletions src/exp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,10 @@ void callExp::reportMismatch(function *ft, signature *source)
em << "without parameters";
break;
case 1:
em << "with parameter '" << *source << "'";
em << "with parameter '" << toString(*source) << "'";
break;
default:
em << "with parameters\n'" << *source << "'";
em << "with parameters\n'" << toString(*source) << "'";
}
}

Expand Down
Loading

0 comments on commit b2f03f0

Please sign in to comment.