#include "d-tree.h"
-/* Return the GCC location for the D frontend location LOC. */
+/* Return the GCC location for the D frontend source location LOC. */
location_t
-make_location_t (const Loc &loc)
+make_location_t (const SourceLoc &loc)
{
location_t gcc_location = input_location;
- if (const char *filename = loc.filename ())
+ if (loc.filename.length != 0)
{
- linemap_add (line_table, LC_ENTER, 0, filename, loc.linnum ());
- linemap_line_start (line_table, loc.linnum (), 0);
- gcc_location = linemap_position_for_column (line_table, loc.charnum ());
+ linemap_add (line_table, LC_ENTER, 0, loc.filename.ptr, loc.line);
+ linemap_line_start (line_table, loc.line, 0);
+ gcc_location = linemap_position_for_column (line_table, loc.column);
linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
}
return gcc_location;
}
+/* Likewise, but converts LOC from a compact opaque location. */
+
+location_t
+make_location_t (const Loc loc)
+{
+ const SourceLoc sloc = loc.toSourceLoc ();
+ return make_location_t (sloc);
+}
+
/* Return the DECL_CONTEXT for symbol DSYM. */
tree
front-end, which does not get translated by the gcc diagnostic routines. */
static void ATTRIBUTE_GCC_DIAG(3,0)
-d_diagnostic_report_diagnostic (const Loc &loc, int opt, const char *format,
- va_list ap, diagnostic_t kind, bool verbatim)
+d_diagnostic_report_diagnostic (const SourceLoc &loc, int opt,
+ const char *format, va_list ap,
+ diagnostic_t kind, bool verbatim)
{
va_list argp;
va_copy (argp, ap);
- if (loc.filename () || !verbatim)
+ if (loc.filename.length != 0 || !verbatim)
{
rich_location rich_loc (line_table, make_location_t (loc));
diagnostic_info diagnostic;
error count depending on how KIND is treated. */
void D_ATTRIBUTE_FORMAT(2,0) ATTRIBUTE_GCC_DIAG(2,0)
-verrorReport (const Loc& loc, const char *format, va_list ap, ErrorKind kind,
- const char *prefix1, const char *prefix2)
+verrorReport (const SourceLoc loc, const char *format, va_list ap,
+ ErrorKind kind, const char *prefix1, const char *prefix2)
{
diagnostic_t diag_kind = DK_UNSPECIFIED;
int opt = 0;
explicit location LOC. This doesn't increase the global error count. */
void D_ATTRIBUTE_FORMAT(2,0) ATTRIBUTE_GCC_DIAG(2,0)
-verrorReportSupplemental (const Loc& loc, const char* format, va_list ap,
+verrorReportSupplemental (const SourceLoc loc, const char* format, va_list ap,
ErrorKind kind)
{
if (kind == ErrorKind::error)
Return result; NULL if cannot evaluate it. */
Expression *
-eval_builtin (const Loc &loc, FuncDeclaration *fd, Expressions *arguments)
+eval_builtin (Loc loc, FuncDeclaration *fd, Expressions *arguments)
{
if (fd->builtin == BUILTIN::unimp)
return NULL;
/* Build and return typeinfo type for TYPE. */
Type *
-getTypeInfoType (const Loc &loc, Type *type, Scope *sc)
+getTypeInfoType (Loc loc, Type *type, Scope *sc)
{
gcc_assert (type->ty != TY::Terror);
check_typeinfo_type (loc, sc);
if (count < 0)
{
- error (Loc ("stdin", 0, 0), "%s", xstrerror (errno));
+ error (Loc::singleFilename ("stdin"), "%s", xstrerror (errno));
free (buffer);
continue;
}
/* Returns a Type for the va_list type of the target. */
Type *
-Target::va_listType (const Loc &, Scope *)
+Target::va_listType (Loc, Scope *)
{
if (this->tvalist)
return this->tvalist;
LOC is the location to use for the returned expression. */
Expression *
-Target::getTargetInfo (const char *key, const Loc &loc)
+Target::getTargetInfo (const char *key, Loc loc)
{
unsigned ix;
d_target_info_spec *spec;
extern void d_init_versions (void);
/* In d-codegen.cc. */
-extern location_t make_location_t (const Loc &);
+extern location_t make_location_t (const SourceLoc &);
+extern location_t make_location_t (const Loc);
extern tree d_decl_context (Dsymbol *);
extern tree copy_aggregate_type (tree);
extern bool declaration_reference_p (Declaration *);
if (d->loc.filename ())
input_location = make_location_t (d->loc);
else
- input_location = make_location_t (Loc ("<no_file>", 1, 0));
+ input_location = make_location_t (Loc::singleFilename ("<no_file>"));
DeclVisitor v = DeclVisitor ();
v.build_dsymbol (d);
-d29e3eca45edaeef63b31f78c9846fc6e2870c49
+ffbad272b649b7ae3e88cfdc85688bfef3168994
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
bool disableNew; /// disallow allocations using `new`
Sizeok sizeok = Sizeok.none; /// set when structsize contains valid data
- final extern (D) this(const ref Loc loc, Identifier id)
+ final extern (D) this(Loc loc, Identifier id)
{
super(loc, id);
visibility = Visibility(Visibility.Kind.public_);
abstract void finalizeSize();
- override final uinteger_t size(const ref Loc loc)
+ override final uinteger_t size(Loc loc)
{
//printf("+AggregateDeclaration::size() %s, scope = %p, sizeok = %d\n", toChars(), _scope, sizeok);
bool ok = determineSize(this, loc);
{
FuncDeclaration *search_toString(StructDeclaration *sd);
void semanticTypeInfoMembers(StructDeclaration *sd);
- bool fill(StructDeclaration* sd, const Loc &loc, Expressions &elements, bool ctorinit);
+ bool fill(StructDeclaration* sd, Loc loc, Expressions &elements, bool ctorinit);
}
enum class ClassKind : uint8_t
virtual Scope *newScope(Scope *sc);
virtual void finalizeSize() = 0;
- uinteger_t size(const Loc &loc) override final;
+ uinteger_t size(Loc loc) override final;
Type *getType() override final;
bool isDeprecated() const override final; // is aggregate deprecated?
bool isNested() const;
private:
uint16_t bitFields;
public:
- static StructDeclaration *create(const Loc &loc, Identifier *id, bool inObject);
+ static StructDeclaration *create(Loc loc, Identifier *id, bool inObject);
StructDeclaration *syntaxCopy(Dsymbol *s) override;
const char *kind() const override;
void finalizeSize() override final;
ObjcClassDeclaration objc; // Data for a class declaration that is needed for the Objective-C integration
Symbol *cpp_type_info_ptr_sym; // cached instance of class Id.cpp_type_info_ptr
- static ClassDeclaration *create(const Loc &loc, Identifier *id, BaseClasses *baseclasses, Dsymbols *members, bool inObject);
+ static ClassDeclaration *create(Loc loc, Identifier *id, BaseClasses *baseclasses, Dsymbols *members, bool inObject);
const char *toPrettyChars(bool QualifyTypes = false) override;
ClassDeclaration *syntaxCopy(Dsymbol *s) override;
Scope *newScope(Scope *sc) override;
/// Whether this `alias this` is deprecated or not
bool isDeprecated_;
- extern (D) this(const ref Loc loc, Identifier ident) @safe
+ extern (D) this(Loc loc, Identifier ident) @safe
{
super(loc, null); // it's anonymous (no identifier)
this.ident = ident;
this.decl = decl;
}
- extern (D) this(const ref Loc loc, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, Dsymbols* decl) @safe
{
super(loc, null);
this.decl = decl;
}
- extern (D) this(const ref Loc loc, Identifier ident, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, Identifier ident, Dsymbols* decl) @safe
{
super(loc, ident);
this.decl = decl;
this.stc = stc;
}
- extern (D) this(const ref Loc loc, StorageClass stc, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, StorageClass stc, Dsymbols* decl) @safe
{
super(loc, decl);
this.stc = stc;
{
LINK linkage; /// either explicitly set or `default_`
- extern (D) this(const ref Loc loc, LINK linkage, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, LINK linkage, Dsymbols* decl) @safe
{
super(loc, null, decl);
//printf("LinkDeclaration(linkage = %d, decl = %p)\n", linkage, decl);
this.linkage = linkage;
}
- static LinkDeclaration create(const ref Loc loc, LINK p, Dsymbols* decl) @safe
+ static LinkDeclaration create(Loc loc, LINK p, Dsymbols* decl) @safe
{
return new LinkDeclaration(loc, p, decl);
}
{
CPPMANGLE cppmangle;
- extern (D) this(const ref Loc loc, CPPMANGLE cppmangle, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, CPPMANGLE cppmangle, Dsymbols* decl) @safe
{
super(loc, null, decl);
//printf("CPPMangleDeclaration(cppmangle = %d, decl = %p)\n", cppmangle, decl);
/// CTFE-able expression, resolving to `TupleExp` or `StringExp`
Expression exp;
- extern (D) this(const ref Loc loc, Identifier ident, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, Identifier ident, Dsymbols* decl) @safe
{
super(loc, ident, decl);
}
- extern (D) this(const ref Loc loc, Expression exp, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, Expression exp, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.exp = exp;
}
- extern (D) this(const ref Loc loc, Identifier ident, Expression exp, Dsymbols* decl,
+ extern (D) this(Loc loc, Identifier ident, Expression exp, Dsymbols* decl,
CPPNamespaceDeclaration parent) @safe
{
super(loc, ident, decl);
* visibility = visibility attribute data
* decl = declarations which are affected by this visibility attribute
*/
- extern (D) this(const ref Loc loc, Visibility visibility, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, Visibility visibility, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.visibility = visibility;
* pkg_identifiers = list of identifiers for a qualified package name
* decl = declarations which are affected by this visibility attribute
*/
- extern (D) this(const ref Loc loc, Identifier[] pkg_identifiers, Dsymbols* decl)
+ extern (D) this(Loc loc, Identifier[] pkg_identifiers, Dsymbols* decl)
{
super(loc, null, decl);
this.visibility.kind = Visibility.Kind.package_;
structalign_t salign;
- extern (D) this(const ref Loc loc, Expression exp, Dsymbols* decl)
+ extern (D) this(Loc loc, Expression exp, Dsymbols* decl)
{
super(loc, null, decl);
if (exp)
}
}
- extern (D) this(const ref Loc loc, Expressions* exps, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, Expressions* exps, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.exps = exps;
}
- extern (D) this(const ref Loc loc, structalign_t salign, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, structalign_t salign, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.salign = salign;
uint anonstructsize; /// size of anonymous struct
uint anonalignsize; /// size of anonymous struct for alignment purposes
- extern (D) this(const ref Loc loc, bool isunion, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, bool isunion, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.isunion = isunion;
{
Expressions* args; /// parameters of this pragma
- extern (D) this(const ref Loc loc, Identifier ident, Expressions* args, Dsymbols* decl) @safe
+ extern (D) this(Loc loc, Identifier ident, Expressions* args, Dsymbols* decl) @safe
{
super(loc, ident, decl);
this.args = args;
Condition condition; /// condition deciding whether decl or elsedecl applies
Dsymbols* elsedecl; /// array of Dsymbol's for else block
- extern (D) this(const ref Loc loc, Condition condition, Dsymbols* decl, Dsymbols* elsedecl) @safe
+ extern (D) this(Loc loc, Condition condition, Dsymbols* decl, Dsymbols* elsedecl) @safe
{
super(loc, null, decl);
//printf("ConditionalDeclaration::ConditionalDeclaration()\n");
bool addisdone = false; /// true if members have been added to scope
bool onStack = false; /// true if a call to `include` is currently active
- extern (D) this(const ref Loc loc, Condition condition, Dsymbols* decl, Dsymbols* elsedecl) @safe
+ extern (D) this(Loc loc, Condition condition, Dsymbols* decl, Dsymbols* elsedecl) @safe
{
super(loc, condition, decl, elsedecl);
//printf("StaticIfDeclaration::StaticIfDeclaration()\n");
ScopeDsymbol scopesym;
bool compiled;
- extern (D) this(const ref Loc loc, Expressions* exps) @safe
+ extern (D) this(Loc loc, Expressions* exps) @safe
{
super(loc, null, null);
//printf("MixinDeclaration(loc = %d)\n", loc.linnum);
public:
LINK linkage;
- static LinkDeclaration *create(const Loc &loc, LINK p, Dsymbols *decl);
+ static LinkDeclaration *create(Loc loc, LINK p, Dsymbols *decl);
LinkDeclaration *syntaxCopy(Dsymbol *s) override;
void accept(Visitor *v) override { v->visit(this); }
};
+
+ Returns: `BE.[err]throw` depending on the type of `exp`
+/
-BE checkThrow(ref const Loc loc, Expression exp, FuncDeclaration func, ErrorSink eSink)
+BE checkThrow(Loc loc, Expression exp, FuncDeclaration func, ErrorSink eSink)
{
Type t = exp.type.toBasetype();
ClassDeclaration cd = t.isClassHandle();
* Evaluate builtin function.
* Return result; NULL if cannot evaluate it.
*/
-public extern (C++) Expression eval_builtin(const ref Loc loc, FuncDeclaration fd, Expressions* arguments);
+public extern (C++) Expression eval_builtin(Loc loc, FuncDeclaration fd, Expressions* arguments);
* https://www.cplusplus.com/reference/cstdio/printf/
*/
public
-bool checkPrintfFormat(ref const Loc loc, scope const char[] format, scope Expression[] args, bool isVa_list, ErrorSink eSink)
+bool checkPrintfFormat(Loc loc, scope const char[] format, scope Expression[] args, bool isVa_list, ErrorSink eSink)
{
//printf("checkPrintFormat('%.*s')\n", cast(int)format.length, format.ptr);
size_t n; // index in args
* https://www.cplusplus.com/reference/cstdio/scanf/
*/
public
-bool checkScanfFormat(ref const Loc loc, scope const char[] format, scope Expression[] args, bool isVa_list, ErrorSink eSink)
+bool checkScanfFormat(Loc loc, scope const char[] format, scope Expression[] args, bool isVa_list, ErrorSink eSink)
{
size_t n = 0;
for (size_t i = 0; i < format.length;)
return DYNCAST.condition;
}
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
this.loc = loc;
}
*/
bool needExpansion = false;
- extern (D) this(const ref Loc loc, ForeachStatement aggrfe, ForeachRangeStatement rangefe) @safe
+ extern (D) this(Loc loc, ForeachStatement aggrfe, ForeachRangeStatement rangefe) @safe
{
assert(!!aggrfe ^ !!rangefe);
* Returns:
* AST of the expression `(){ s; }()` with location loc.
*/
- private extern(D) Expression wrapAndCall(const ref Loc loc, Statement s)
+ private extern(D) Expression wrapAndCall(Loc loc, Statement s)
{
auto tf = new TypeFunction(ParameterList(), null, LINK.default_, 0);
auto fd = new FuncLiteralDeclaration(loc, loc, tf, TOK.reserved, null);
* `foreach (parameters; lower .. upper) s;`
* Where aggregate/lower, upper are as for the current StaticForeach.
*/
- private extern(D) Statement createForeach(const ref Loc loc, Parameters* parameters, Statement s)
+ private extern(D) Statement createForeach(Loc loc, Parameters* parameters, Statement s)
{
if (aggrfe)
{
* }
*/
- private extern(D) TypeStruct createTupleType(const ref Loc loc, Expressions* e, Scope* sc)
+ private extern(D) TypeStruct createTupleType(Loc loc, Expressions* e, Scope* sc)
{ // TODO: move to druntime?
auto sid = Identifier.generateId("Tuple");
auto sdecl = new StructDeclaration(loc, sid, false);
* An AST for the expression `Tuple(e)`.
*/
- private extern(D) Expression createTuple(const ref Loc loc, TypeStruct type, Expressions* e) @safe
+ private extern(D) Expression createTuple(Loc loc, TypeStruct type, Expressions* e) @safe
{ // TODO: move to druntime?
return new CallExp(loc, new TypeExp(loc, type), e);
}
Identifier ident;
Module mod;
- extern (D) this(const ref Loc loc, Module mod, Identifier ident) @safe
+ extern (D) this(Loc loc, Module mod, Identifier ident) @safe
{
super(loc);
this.mod = mod;
* If `null`, this conditiion will use an integer level.
* loc = Location in the source file
*/
- extern (D) this(const ref Loc loc, Module mod, Identifier ident) @safe
+ extern (D) this(Loc loc, Module mod, Identifier ident) @safe
{
super(loc, mod, ident);
}
* loc = Where the identifier is set
* ident = identifier being checked (ident[$] must be '\0')
*/
- extern(D) static void checkReserved(const ref Loc loc, const(char)[] ident)
+ extern(D) static void checkReserved(Loc loc, const(char)[] ident)
{
if (isReserved(ident))
error(loc, "version identifier `%s` is reserved and cannot be set",
* If `null`, this conditiion will use an integer level.
* loc = Location in the source file
*/
- extern (D) this(const ref Loc loc, Module mod, Identifier ident) @safe
+ extern (D) this(Loc loc, Module mod, Identifier ident) @safe
{
super(loc, mod, ident);
}
{
Expression exp;
- extern (D) this(const ref Loc loc, Expression exp) @safe
+ extern (D) this(Loc loc, Expression exp) @safe
{
super(loc);
this.exp = exp;
return ue;
}
-UnionExp Add(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Add(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
static if (LOG)
return ue;
}
-UnionExp Min(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Min(Loc loc, Type type, Expression e1, Expression e2)
{
// Compute e1-e2 as e1+(-e2)
UnionExp neg = Neg(e2.type, e2);
return ue;
}
-UnionExp Mul(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Mul(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
if (type.isFloating())
return ue;
}
-UnionExp Div(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Div(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
if (type.isFloating())
return ue;
}
-UnionExp Mod(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Mod(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
if (type.isFloating())
return ue;
}
-UnionExp Pow(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Pow(Loc loc, Type type, Expression e1, Expression e2)
{
//printf("Pow()\n");
UnionExp ue;
return ue;
}
-UnionExp Shl(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Shl(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
emplaceExp!(IntegerExp)(&ue, loc, e1.toInteger() << e2.toInteger(), type);
return ue;
}
-UnionExp Shr(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Shr(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
dinteger_t value = e1.toInteger();
return ue;
}
-UnionExp Ushr(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Ushr(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
dinteger_t value = e1.toInteger();
return ue;
}
-UnionExp And(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp And(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
emplaceExp!(IntegerExp)(&ue, loc, e1.toInteger() & e2.toInteger(), type);
return ue;
}
-UnionExp Or(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Or(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
emplaceExp!(IntegerExp)(&ue, loc, e1.toInteger() | e2.toInteger(), type);
return ue;
}
-UnionExp Xor(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Xor(Loc loc, Type type, Expression e1, Expression e2)
{
//printf("Xor(linnum = %d, e1 = %s, e2 = %s)\n", loc.linnum, e1.toChars(), e2.toChars());
UnionExp ue = void;
/* Also returns EXP.cantExpression if cannot be computed.
*/
-UnionExp Equal(EXP op, const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Equal(EXP op, Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
int cmp = 0;
return ue;
}
-UnionExp Identity(EXP op, const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Identity(EXP op, Loc loc, Type type, Expression e1, Expression e2)
{
//printf("Identity %s %s\n", e1.toChars(), e2.toChars());
UnionExp ue = void;
return ue;
}
-UnionExp Cmp(EXP op, const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Cmp(EXP op, Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
dinteger_t n;
* to: type to cast to
* type: type to paint the result
*/
-UnionExp Cast(const ref Loc loc, Type type, Type to, Expression e1)
+UnionExp Cast(Loc loc, Type type, Type to, Expression e1)
{
UnionExp ue = void;
Type tb = to.toBasetype();
/* Also return EXP.cantExpression if this fails
*/
-UnionExp Cat(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp Cat(Loc loc, Type type, Expression e1, Expression e2)
{
UnionExp ue = void;
Expression e = CTFEExp.cantexp;
* Params:
* startloc = location to use for error messages
*/
- private void uupragmaDirective(const ref Loc startloc)
+ private void uupragmaDirective(Loc startloc)
{
const loc = startloc;
nextToken(); // move past __pragma
* the preprocessed output. Ignore them.
* Upon return, p is at start of next line.
*/
- private void pragmaDirective(const ref Loc loc)
+ private void pragmaDirective(Loc loc)
{
Token n;
scan(&n);
* startloc = location to use for error messages
* useScan = use scan() to retrieve next token, instead of nextToken()
*/
- private void pragmaPack(const ref Loc startloc, bool useScan)
+ private void pragmaPack(Loc startloc, bool useScan)
{
const loc = startloc;
* Params:
* startloc = location to use for error messages
*/
- private void pragmaAttribute(const ref Loc startloc)
+ private void pragmaAttribute(Loc startloc)
{
const loc = startloc;
while (*p)
++p;
++p; // advance to start of next line
- scanloc.linnum = scanloc.linnum + 1;
}
if (newSymbols.length)
* Returns:
* Constructed ArrayLiteralExp
*/
-ArrayLiteralExp createBlockDuplicatedArrayLiteral(UnionExp* pue, const ref Loc loc, Type type, Expression elem, size_t dim)
+ArrayLiteralExp createBlockDuplicatedArrayLiteral(UnionExp* pue, Loc loc, Type type, Expression elem, size_t dim)
{
if (type.ty == Tsarray && type.nextOf().ty == Tsarray && elem.type.ty != Tsarray)
{
* Helper for NewExp
* Create a string literal consisting of 'value' duplicated 'dim' times.
*/
-StringExp createBlockDuplicatedStringLiteral(UnionExp* pue, const ref Loc loc, Type type, dchar value, size_t dim, ubyte sz)
+StringExp createBlockDuplicatedStringLiteral(UnionExp* pue, Loc loc, Type type, dchar value, size_t dim, ubyte sz)
{
auto s = cast(char*)mem.xcalloc(dim, sz);
foreach (elemi; 0 .. dim)
}
// return e1 - e2 as an integer, or error if not possible
-Expression pointerDifference(UnionExp* pue, const ref Loc loc, Type type, Expression e1, Expression e2)
+Expression pointerDifference(UnionExp* pue, Loc loc, Type type, Expression e1, Expression e2)
{
dinteger_t ofs1, ofs2;
Expression agg1 = getAggregateFromPointer(e1, &ofs1);
// Return eptr op e2, where eptr is a pointer, e2 is an integer,
// and op is EXP.add or EXP.min
-Expression pointerArithmetic(UnionExp* pue, const ref Loc loc, EXP op, Type type, Expression eptr, Expression e2)
+Expression pointerArithmetic(UnionExp* pue, Loc loc, EXP op, Type type, Expression eptr, Expression e2)
{
if (eptr.type.nextOf().ty == Tvoid)
{
* Returns:
* -1,0,1
*/
-private int ctfeCmpArrays(const ref Loc loc, Expression e1, Expression e2, uinteger_t len)
+private int ctfeCmpArrays(Loc loc, Expression e1, Expression e2, uinteger_t len)
{
// Resolve slices, if necessary
uinteger_t lo1 = 0;
* For strings, return <0 if e1 < e2, 0 if e1==e2, >0 if e1 > e2.
* For all other types, return 0 if e1 == e2, !=0 if e1 != e2.
*/
-private int ctfeRawCmp(const ref Loc loc, Expression e1, Expression e2, bool identity = false)
+private int ctfeRawCmp(Loc loc, Expression e1, Expression e2, bool identity = false)
{
if (e1.op == EXP.classReference || e2.op == EXP.classReference)
{
}
/// Evaluate ==, !=. Resolves slices before comparing. Returns 0 or 1
-bool ctfeEqual(const ref Loc loc, EXP op, Expression e1, Expression e2)
+bool ctfeEqual(Loc loc, EXP op, Expression e1, Expression e2)
{
return !ctfeRawCmp(loc, e1, e2) ^ (op == EXP.notEqual);
}
/// Evaluate is, !is. Resolves slices before comparing. Returns 0 or 1
-bool ctfeIdentity(const ref Loc loc, EXP op, Expression e1, Expression e2)
+bool ctfeIdentity(Loc loc, EXP op, Expression e1, Expression e2)
{
//printf("ctfeIdentity %s %s\n", e1.toChars(), e2.toChars());
//printf("ctfeIdentity op = '%s', e1 = %s %s, e2 = %s %s\n", EXPtoString(op).ptr,
}
/// Evaluate >,<=, etc. Resolves slices before comparing. Returns 0 or 1
-bool ctfeCmp(const ref Loc loc, EXP op, Expression e1, Expression e2)
+bool ctfeCmp(Loc loc, EXP op, Expression e1, Expression e2)
{
Type t1 = e1.type.toBasetype();
Type t2 = e2.type.toBasetype();
return intSignedCmp(op, e1.toInteger(), e2.toInteger());
}
-UnionExp ctfeCat(const ref Loc loc, Type type, Expression e1, Expression e2)
+UnionExp ctfeCat(Loc loc, Type type, Expression e1, Expression e2)
{
Type t1 = e1.type.toBasetype();
Type t2 = e2.type.toBasetype();
/* Given an AA literal 'ae', and a key 'e2':
* Return ae[e2] if present, or NULL if not found.
*/
-Expression findKeyInAA(const ref Loc loc, AssocArrayLiteralExp ae, Expression e2)
+Expression findKeyInAA(Loc loc, AssocArrayLiteralExp ae, Expression e2)
{
/* Search the keys backwards, in case there are duplicate keys
*/
* dynamic arrays, and strings. We know that e1 is an
* interpreted CTFE expression, so it cannot have side-effects.
*/
-Expression ctfeIndex(UnionExp* pue, const ref Loc loc, Type type, Expression e1, uinteger_t indx)
+Expression ctfeIndex(UnionExp* pue, Loc loc, Type type, Expression e1, uinteger_t indx)
{
//printf("ctfeIndex(e1 = %s)\n", e1.toChars());
assert(e1.type);
assert(0);
}
-Expression ctfeCast(UnionExp* pue, const ref Loc loc, Type type, Type to, Expression e, bool explicitCast = false)
+Expression ctfeCast(UnionExp* pue, Loc loc, Type type, Type to, Expression e, bool explicitCast = false)
{
Expression paint()
{
}
// Given an AA literal aae, set aae[index] = newval and return newval.
-Expression assignAssocArrayElement(const ref Loc loc, AssocArrayLiteralExp aae, Expression index, Expression newval)
+Expression assignAssocArrayElement(Loc loc, AssocArrayLiteralExp aae, Expression index, Expression newval)
{
/* Create new associative array literal reflecting updated key/value
*/
/// Given array literal oldval of type ArrayLiteralExp or StringExp, of length
/// oldlen, change its length to newlen. If the newlen is longer than oldlen,
/// all new elements will be set to the default initializer for the element type.
-Expression changeArrayLiteralLength(UnionExp* pue, const ref Loc loc, TypeArray arrayType, Expression oldval, size_t oldlen, size_t newlen)
+Expression changeArrayLiteralLength(UnionExp* pue, Loc loc, TypeArray arrayType, Expression oldval, size_t oldlen, size_t newlen)
{
Type elemType = arrayType.next;
assert(elemType);
return dmd.dsymbolsem.addMember(dsym, sc, sds);
}
-Dsymbol search(Dsymbol d, const ref Loc loc, Identifier ident, SearchOptFlags
+Dsymbol search(Dsymbol d, Loc loc, Identifier ident, SearchOptFlags
flags = SearchOpt.all)
{
import dmd.dsymbolsem;
/***********************************************************
* enumsem.d
*/
-Expression getDefaultValue(EnumDeclaration ed, const ref Loc loc)
+Expression getDefaultValue(EnumDeclaration ed, Loc loc)
{
import dmd.enumsem;
return dmd.enumsem.getDefaultValue(ed, loc);
return dmd.expressionsem.expressionSemantic(e, sc);
}
-bool fill(StructDeclaration sd, const ref Loc loc,
+bool fill(StructDeclaration sd, Loc loc,
ref Expressions elements, bool ctorinit)
{
import dmd.expressionsem;
return dmd.typesem.hasPointers(t);
}
-Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
+Type typeSemantic(Type type, Loc loc, Scope* sc)
{
import dmd.typesem;
return dmd.typesem.typeSemantic(type, loc, sc);
}
-Type trySemantic(Type type, const ref Loc loc, Scope* sc)
+Type trySemantic(Type type, Loc loc, Scope* sc)
{
import dmd.typesem;
return dmd.typesem.trySemantic(type, loc, sc);
return dmd.typesem.merge2(type);
}
-Expression defaultInit(Type mt, const ref Loc loc, const bool isCfile = false)
+Expression defaultInit(Type mt, Loc loc, const bool isCfile = false)
{
import dmd.typesem;
return dmd.typesem.defaultInit(mt, loc, isCfile);
return dmd.typesem.covariant(src, t, pstc, cppCovariant);
}
-bool isZeroInit(Type t, const ref Loc loc)
+bool isZeroInit(Type t, Loc loc)
{
import dmd.typesem;
return dmd.typesem.isZeroInit(t, loc);
return dmd.typesem.size(type);
}
-uinteger_t size(Type type, const ref Loc loc)
+uinteger_t size(Type type, Loc loc)
{
import dmd.typesem;
return dmd.typesem.size(type, loc);
/***********************************************************
* typinf.d
*/
-bool genTypeInfo(Expression e, const ref Loc loc, Type torig, Scope* sc)
+bool genTypeInfo(Expression e, Loc loc, Type torig, Scope* sc)
{
import dmd.typinf;
return dmd.typinf.genTypeInfo(e, loc, torig, sc);
if (auto tsa = tb.isTypeSArray())
{
if (e.elements.length != tsa.dim.toInteger())
- goto L1;
+ return visit(ae);
}
ae = e.copy().isArrayLiteralExp();
const edim = e.elements.length;
const tbasedim = tbase.dim.toInteger();
if (edim > tbasedim)
- goto L1;
+ return visit(ae);
ae = e.copy().isArrayLiteralExp();
ae.type = tbase; // https://issues.dlang.org/show_bug.cgi?id=12642
ev = ev.expressionSemantic(sc);
return ev;
}
- L1:
return visit(ae);
}
Symbol* cpp_type_info_ptr_sym; // cached instance of class Id.cpp_type_info_ptr
- final extern (D) this(const ref Loc loc, Identifier id, BaseClasses* baseclasses, Dsymbols* members, bool inObject)
+ final extern (D) this(Loc loc, Identifier id, BaseClasses* baseclasses, Dsymbols* members, bool inObject)
{
objc = ObjcClassDeclaration(this);
.error(loc, fmt, kind, toPrettyChars, arg);
}
- static ClassDeclaration create(const ref Loc loc, Identifier id, BaseClasses* baseclasses, Dsymbols* members, bool inObject)
+ static ClassDeclaration create(Loc loc, Identifier id, BaseClasses* baseclasses, Dsymbols* members, bool inObject)
{
return new ClassDeclaration(loc, id, baseclasses, members, inObject);
}
*/
extern (C++) final class InterfaceDeclaration : ClassDeclaration
{
- extern (D) this(const ref Loc loc, Identifier id, BaseClasses* baseclasses)
+ extern (D) this(Loc loc, Identifier id, BaseClasses* baseclasses)
{
super(loc, id, baseclasses, null, false);
if (id == Id.IUnknown) // IUnknown is the root of all COM interfaces
visibility = Visibility(Visibility.Kind.undefined);
}
- final extern (D) this(const ref Loc loc, Identifier ident) @safe
+ final extern (D) this(Loc loc, Identifier ident) @safe
{
super(loc, ident);
visibility = Visibility(Visibility.Kind.undefined);
return "declaration";
}
- override final uinteger_t size(const ref Loc loc)
+ override final uinteger_t size(Loc loc)
{
assert(type);
const sz = type.size();
bool isexp; // true: expression tuple
bool building; // it's growing in AliasAssign semantic
- extern (D) this(const ref Loc loc, Identifier ident, Objects* objects) @safe
+ extern (D) this(Loc loc, Identifier ident, Objects* objects) @safe
{
super(loc, ident);
this.objects = objects;
Dsymbol overnext; // next in overload list
Dsymbol _import; // !=null if unresolved internal alias for selective import
- extern (D) this(const ref Loc loc, Identifier ident, Type type) @safe
+ extern (D) this(Loc loc, Identifier ident, Type type) @safe
{
super(loc, ident);
//debug printf("AliasDeclaration(id = '%s', type = `%s`, %p)\n", ident.toChars(), dmd.hdrgen.toChars(type), type.isTypeIdentifier());
assert(type);
}
- extern (D) this(const ref Loc loc, Identifier ident, Dsymbol s) @safe
+ extern (D) this(Loc loc, Identifier ident, Dsymbol s) @safe
{
super(loc, ident);
//debug printf("AliasDeclaration(id = '%s', s = `%s`)\n", ident.toChars(), s.toChars());
assert(s);
}
- static AliasDeclaration create(const ref Loc loc, Identifier id, Type type) @safe
+ static AliasDeclaration create(Loc loc, Identifier id, Type type) @safe
{
return new AliasDeclaration(loc, id, type);
}
byte canassign; // it can be assigned to
ubyte isdataseg; // private data for isDataseg 0 unset, 1 true, 2 false
- final extern (D) this(const ref Loc loc, Type type, Identifier ident, Initializer _init, StorageClass storage_class = STC.undefined_)
+ final extern (D) this(Loc loc, Type type, Identifier ident, Initializer _init, StorageClass storage_class = STC.undefined_)
in
{
assert(ident);
this.storage_class = storage_class;
}
- static VarDeclaration create(const ref Loc loc, Type type, Identifier ident, Initializer _init, StorageClass storage_class = STC.undefined_)
+ static VarDeclaration create(Loc loc, Type type, Identifier ident, Initializer _init, StorageClass storage_class = STC.undefined_)
{
return new VarDeclaration(loc, type, ident, _init, storage_class);
}
uint fieldWidth;
uint bitOffset;
- final extern (D) this(const ref Loc loc, Type type, Identifier ident, Expression width)
+ final extern (D) this(Loc loc, Type type, Identifier ident, Expression width)
{
super(loc, type, ident, null);
{
AggregateDeclaration dsym;
- extern (D) this(const ref Loc loc, AggregateDeclaration dsym) @safe
+ extern (D) this(Loc loc, AggregateDeclaration dsym) @safe
{
super(loc, dsym.ident);
this.dsym = dsym;
*/
extern (C++) final class ThisDeclaration : VarDeclaration
{
- extern (D) this(const ref Loc loc, Type t)
+ extern (D) this(Loc loc, Type t)
{
super(loc, t, Id.This, null);
storage_class |= STC.nodtor;
DString mangleOverride; // overridden symbol with pragma(mangle, "...")
const char *kind() const override;
- uinteger_t size(const Loc &loc) override final;
+ uinteger_t size(Loc loc) override final;
bool isStatic() const { return (storage_class & STCstatic) != 0; }
Dsymbol *overnext; // next in overload list
Dsymbol *_import; // !=NULL if unresolved internal alias for selective import
- static AliasDeclaration *create(const Loc &loc, Identifier *id, Type *type);
+ static AliasDeclaration *create(Loc loc, Identifier *id, Type *type);
AliasDeclaration *syntaxCopy(Dsymbol *) override;
bool overloadInsert(Dsymbol *s) override;
const char *kind() const override;
#endif
bool systemInferred() const;
bool systemInferred(bool v);
- static VarDeclaration *create(const Loc &loc, Type *t, Identifier *id, Initializer *init, StorageClass storage_class = STCundefined);
+ static VarDeclaration *create(Loc loc, Type *t, Identifier *id, Initializer *init, StorageClass storage_class = STCundefined);
VarDeclaration *syntaxCopy(Dsymbol *) override;
const char *kind() const override;
AggregateDeclaration *isThis() override final;
toPrecReal
};
-Expression *eval_builtin(const Loc &loc, FuncDeclaration *fd, Expressions *arguments);
+Expression *eval_builtin(Loc loc, FuncDeclaration *fd, Expressions *arguments);
BUILTIN isBuiltin(FuncDeclaration *fd);
struct ContractInfo;
// integration.
ObjcFuncDeclaration objc;
- static FuncDeclaration *create(const Loc &loc, const Loc &endloc, Identifier *id, StorageClass storage_class, Type *type, bool noreturn = false);
+ static FuncDeclaration *create(Loc loc, Loc endloc, Identifier *id, StorageClass storage_class, Type *type, bool noreturn = false);
FuncDeclaration *syntaxCopy(Dsymbol *) override;
Statements *frequires();
Ensures *fensures();
bool overloadInsert(Dsymbol *s) override;
bool inUnittest();
- LabelDsymbol *searchLabel(Identifier *ident, const Loc &loc);
+ LabelDsymbol *searchLabel(Identifier *ident, Loc loc);
const char *toPrettyChars(bool QualifyTypes = false) override;
const char *toFullSignature(); // for diagnostics, e.g. 'int foo(int x, int y) pure'
bool isMain() const;
Symbol* sinit;
- extern (D) this(const ref Loc loc, Identifier ident, Type memtype)
+ extern (D) this(Loc loc, Identifier ident, Type memtype)
{
super(loc, ident);
//printf("EnumDeclaration() %p %s : %s\n", this, toChars(), memtype.toChars());
EnumDeclaration ed;
- extern (D) this(const ref Loc loc, Identifier id, Expression value, Type origType)
+ extern (D) this(Loc loc, Identifier id, Expression value, Type origType)
{
super(loc, null, id ? id : Id.empty, new ExpInitializer(loc, value));
this.origValue = value;
// corresponding AliasDeclarations for alias=name pairs
AliasDeclarations aliasdecls;
- extern (D) this(const ref Loc loc, Identifier[] packages, Identifier id, Identifier aliasId, int isstatic)
+ extern (D) this(Loc loc, Identifier[] packages, Identifier id, Identifier aliasId, int isstatic)
{
Identifier selectIdent()
{
}
/// used to collect coverage information in ctfe
-void incUsageCtfe(InterState* istate, const ref Loc loc)
+void incUsageCtfe(InterState* istate, Loc loc)
{
if (global.params.ctfe_cov && istate)
{
}
}
- static Expression getVarExp(const ref Loc loc, InterState* istate, Declaration d, CTFEGoal goal)
+ static Expression getVarExp(Loc loc, InterState* istate, Declaration d, CTFEGoal goal)
{
Expression e = CTFEExp.cantexp;
if (VarDeclaration v = d.isVarDeclaration())
// Create an array literal of type 'newtype' with dimensions given by
// 'arguments'[argnum..$]
- static Expression recursivelyCreateArrayLiteral(UnionExp* pue, const ref Loc loc, Type newtype, InterState* istate, Expressions* arguments, int argnum)
+ static Expression recursivelyCreateArrayLiteral(UnionExp* pue, Loc loc, Type newtype, InterState* istate, Expressions* arguments, int argnum)
{
Expression lenExpr = interpret(pue, (*arguments)[argnum], istate);
if (exceptionOrCantInterpret(lenExpr))
}
}
- private alias fp_t = extern (D) UnionExp function(const ref Loc loc, Type, Expression, Expression);
- private alias fp2_t = extern (D) bool function(const ref Loc loc, EXP, Expression, Expression);
+ private alias fp_t = extern (D) UnionExp function(Loc loc, Type, Expression, Expression);
+ private alias fp2_t = extern (D) bool function(Loc loc, EXP, Expression, Expression);
extern (D) private void interpretCommon(BinExp e, fp_t fp)
{
/// Interpret `throw <exp>` found at the specified location `loc`
private
-void interpretThrow(ref Expression result, Expression exp, const ref Loc loc, InterState* istate)
+void interpretThrow(ref Expression result, Expression exp, Loc loc, InterState* istate)
{
incUsageCtfe(istate, loc);
true if it is safe to return, false if an error was generated.
*/
private
-bool stopPointersEscaping(const ref Loc loc, Expression e)
+bool stopPointersEscaping(Loc loc, Expression e)
{
import dmd.typesem : hasPointers;
if (!e.type.hasPointers())
// Check all elements of an array for escaping local variables. Return false if error
private
-bool stopPointersEscapingFromArray(const ref Loc loc, Expressions* elems)
+bool stopPointersEscapingFromArray(Loc loc, Expressions* elems)
{
foreach (e; *elems)
{
* 1. all slices must be resolved.
* 2. all .ownedByCtfe set to OwnedBy.code
*/
-private Expression scrubReturnValue(const ref Loc loc, Expression e)
+private Expression scrubReturnValue(Loc loc, Expression e)
{
/* Returns: true if e is void,
* or is an array literal or struct literal of void elements.
/* If this is a built-in function, return the interpreted result,
* Otherwise, return NULL.
*/
-private Expression evaluateIfBuiltin(UnionExp* pue, InterState* istate, const ref Loc loc, FuncDeclaration fd, Expressions* arguments, Expression pthis)
+private Expression evaluateIfBuiltin(UnionExp* pue, InterState* istate, Loc loc, FuncDeclaration fd, Expressions* arguments, Expression pthis)
{
Expression e = null;
size_t nargs = arguments ? arguments.length : 0;
uint tag; // auto incremented tag, used to mask package tree in scopes
Module mod; // !=null if isPkgMod == PKG.module_
- final extern (D) this(const ref Loc loc, Identifier ident) nothrow
+ final extern (D) this(Loc loc, Identifier ident) nothrow
{
super(loc, ident);
__gshared uint packageTag;
size_t nameoffset; // offset of module name from start of ModuleInfo
size_t namelen; // length of module name in characters
- extern (D) this(const ref Loc loc, const(char)[] filename, Identifier ident, int doDocComment, int doHdrGen)
+ extern (D) this(Loc loc, const(char)[] filename, Identifier ident, int doDocComment, int doHdrGen)
{
super(loc, ident);
const(char)[] srcfilename;
return ret;
}
- extern (C++) static Module load(const ref Loc loc, Identifiers* packages, Identifier ident)
+ extern (C++) static Module load(Loc loc, Identifiers* packages, Identifier ident)
{
return load(loc, packages ? (*packages)[] : null, ident);
}
- extern (D) static Module load(const ref Loc loc, Identifier[] packages, Identifier ident, ImportPathInfo pathInfo = ImportPathInfo.init)
+ extern (D) static Module load(Loc loc, Identifier[] packages, Identifier ident, ImportPathInfo pathInfo = ImportPathInfo.init)
{
//printf("Module::load(ident = '%s')\n", ident.toChars());
// Build module filename by turning:
* Params:
* loc = The location at which the file read originated (e.g. import)
*/
- private void onFileReadError(const ref Loc loc)
+ private void onFileReadError(Loc loc)
{
const name = srcfile.toString();
if (FileName.equals(name, "object.d"))
*
* Returns: `true` if successful
*/
- bool read(const ref Loc loc)
+ bool read(Loc loc)
{
if (this.src)
return true; // already read
checkCompiledImport();
members = p.parseModule();
assert(!p.md); // C doesn't have module declarations
- numlines = p.scanloc.linnum;
+ numlines = p.linnum;
}
else
{
checkCompiledImport();
members = p.parseModuleContent();
- numlines = p.scanloc.linnum;
+ numlines = p.linnum;
}
/* The symbol table into which the module is to be inserted.
* sc = the scope into which we are imported
* loc = the location of the import statement
*/
- void checkImportDeprecation(const ref Loc loc, Scope* sc)
+ void checkImportDeprecation(Loc loc, Scope* sc)
{
if (md && md.isdeprecated && !sc.isDeprecated)
{
bool isdeprecated; // if it is a deprecated module
Expression msg;
- extern (D) this(const ref Loc loc, Identifier[] packages, Identifier id, Expression msg, bool isdeprecated) @safe
+ extern (D) this(Loc loc, Identifier[] packages, Identifier id, Expression msg, bool isdeprecated) @safe
{
this.loc = loc;
this.packages = packages;
VarDeclaration varDecl; /// variable we are in during semantic2
Dsymbol parent; /// parent to use
LabelStatement slabel; /// enclosing labelled statement
- SwitchStatement sw; /// enclosing switch statement
+ SwitchStatement switchStatement;/// enclosing switch statement
Statement tryBody; /// enclosing _body of TryCatchStatement or TryFinallyStatement
- TryFinallyStatement tf; /// enclosing try finally statement
- ScopeGuardStatement os; /// enclosing scope(xxx) statement
+ TryFinallyStatement tryFinally; /// enclosing try finally statement
+ ScopeGuardStatement scopeGuard; /// enclosing scope(xxx) statement
Statement sbreak; /// enclosing statement that supports "break"
Statement scontinue; /// enclosing statement that supports "continue"
ForeachStatement fes; /// if nested function for ForeachStatement, this is it
* loc = for error messages
* ctorflow = flow results to merge in
*/
- extern (D) void merge(const ref Loc loc, const ref CtorFlow ctorflow)
+ extern (D) void merge(Loc loc, const ref CtorFlow ctorflow)
{
if (!mergeCallSuper(this.ctorflow.callSuper, ctorflow.callSuper))
error(loc, "one path skips constructor");
* Returns:
* symbol if found, null if not
*/
- extern (C++) Dsymbol search(const ref Loc loc, Identifier ident, out Dsymbol pscopesym, SearchOptFlags flags = SearchOpt.all)
+ extern (C++) Dsymbol search(Loc loc, Identifier ident, out Dsymbol pscopesym, SearchOptFlags flags = SearchOpt.all)
{
version (LOGSEARCH)
{
import dmd.common.bitfields : generateBitFields;
mixin(generateBitFields!(BitFields, ushort));
- extern (D) this(const ref Loc loc, Identifier id, bool inObject)
+ extern (D) this(Loc loc, Identifier id, bool inObject)
{
super(loc, id);
zeroInit = false; // assume false until we do semantic processing
}
}
- static StructDeclaration create(const ref Loc loc, Identifier id, bool inObject)
+ static StructDeclaration create(Loc loc, Identifier id, bool inObject)
{
return new StructDeclaration(loc, id, inObject);
}
*/
extern (C++) final class UnionDeclaration : StructDeclaration
{
- extern (D) this(const ref Loc loc, Identifier id)
+ extern (D) this(Loc loc, Identifier id)
{
super(loc, id, false);
}
this.ident = ident;
}
- final extern (D) this(const ref Loc loc, Identifier ident) nothrow @safe
+ final extern (D) this(Loc loc, Identifier ident) nothrow @safe
{
//printf("Dsymbol::Dsymbol(%p, ident)\n", this);
this.loc = loc;
* Returns:
* SIZE_INVALID when the size cannot be determined
*/
- uinteger_t size(const ref Loc loc)
+ uinteger_t size(Loc loc)
{
.error(loc, "%s `%s` symbol `%s` has no size", kind, toPrettyChars, toChars());
return SIZE_INVALID;
super(ident);
}
- final extern (D) this(const ref Loc loc, Identifier ident) nothrow @safe
+ final extern (D) this(Loc loc, Identifier ident) nothrow @safe
{
super(loc, ident);
}
return (members is null);
}
- static void multiplyDefined(const ref Loc loc, Dsymbol s1, Dsymbol s2)
+ static void multiplyDefined(Loc loc, Dsymbol s1, Dsymbol s2)
{
version (none)
{
Dsymbol aliassym; /// replace previous RHS of AliasDeclaration with `aliassym`
/// only one of type and aliassym can be != null
- extern (D) this(const ref Loc loc, Identifier ident, Type type, Dsymbol aliassym) nothrow @safe
+ extern (D) this(Loc loc, Identifier ident, Type type, Dsymbol aliassym) nothrow @safe
{
super(loc, null);
this.ident = ident;
virtual Dsymbol *toAlias(); // resolve real symbol
virtual Dsymbol *toAlias2();
virtual bool overloadInsert(Dsymbol *s);
- virtual uinteger_t size(const Loc &loc);
+ virtual uinteger_t size(Loc loc);
virtual bool isforwardRef();
virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member
virtual bool isExport() const; // is Dsymbol exported?
virtual void importScope(Dsymbol *s, Visibility visibility);
virtual bool isPackageAccessible(Package *p, Visibility visibility, SearchOptFlags flags = (SearchOptFlags)SearchOpt::all);
bool isforwardRef() override final;
- static void multiplyDefined(const Loc &loc, Dsymbol *s1, Dsymbol *s2);
+ static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2);
const char *kind() const override;
virtual Dsymbol *symtabInsert(Dsymbol *s);
virtual Dsymbol *symtabLookup(Dsymbol *s, Identifier *id);
namespace dmd
{
void addMember(Dsymbol *dsym, Scope *sc, ScopeDsymbol *sds);
- Dsymbol *search(Dsymbol *d, const Loc &loc, Identifier *ident, SearchOptFlags flags = (SearchOptFlags)SearchOpt::localsOnly);
+ Dsymbol *search(Dsymbol *d, Loc loc, Identifier *ident, SearchOptFlags flags = (SearchOptFlags)SearchOpt::localsOnly);
Dsymbols *include(Dsymbol *d, Scope *sc);
void setScope(Dsymbol *d, Scope *sc);
void importAll(Dsymbol *d, Scope *sc);
return dd.msgstr;
}
-bool checkDeprecated(Dsymbol d, const ref Loc loc, Scope* sc)
+bool checkDeprecated(Dsymbol d, Loc loc, Scope* sc)
{
if (global.params.useDeprecated == DiagnosticReporting.off)
return false;
/*********************************
* Check type to see if it is based on a deprecated symbol.
*/
-private void checkDeprecated(Type type, const ref Loc loc, Scope* sc)
+private void checkDeprecated(Type type, Loc loc, Scope* sc)
{
if (Dsymbol s = type.toDsymbol(sc))
{
* Returns:
* Whether the alias this was reported as deprecated.
*/
-private bool checkDeprecatedAliasThis(AliasThis at, const ref Loc loc, Scope* sc)
+private bool checkDeprecatedAliasThis(AliasThis at, Loc loc, Scope* sc)
{
if (global.params.useDeprecated != DiagnosticReporting.off
&& at.isDeprecated() && !sc.isDeprecated())
buf.writeByte(0);
const str = buf.extractSlice()[0 .. len];
const bool doUnittests = global.params.parsingUnittestsRequired();
- auto loc = adjustLocForMixin(str, cd.loc, global.params.mixinOut);
- scope p = new Parser!ASTCodegen(loc, sc._module, str, false, global.errorSink, &global.compileEnv, doUnittests);
+ scope p = new Parser!ASTCodegen(sc._module, str, false, global.errorSink, &global.compileEnv, doUnittests);
+ adjustLocForMixin(str, cd.loc, *p.baseLoc, global.params.mixinOut);
+ p.linnum = p.baseLoc.startLine;
p.nextToken();
auto d = p.parseDeclDefs(0);
* Set up loc for a parse of a mixin. Append the input text to the mixin.
* Params:
* input = mixin text
- * loc = location to adjust
+ * loc = location of expansion
+ * baseLoc = location to adjust
* mixinOut = sink for mixin text data
* Returns:
* adjusted loc suitable for Parser
*/
-Loc adjustLocForMixin(const(char)[] input, ref const Loc loc, ref Output mixinOut)
+void adjustLocForMixin(const(char)[] input, Loc loc, ref BaseLoc baseLoc, ref Output mixinOut)
{
- Loc result;
if (mixinOut.doOutput)
{
const lines = mixinOut.bufferLines;
writeMixin(input, loc, mixinOut.bufferLines, *mixinOut.buffer);
- result = Loc(mixinOut.name.ptr, lines + 2, loc.charnum);
+ baseLoc.startLine = lines + 2;
+ baseLoc.filename = mixinOut.name;
+ return;
}
- else if (loc.filename)
+
+ SourceLoc sl = SourceLoc(loc);
+ if (sl.filename.length == 0)
{
- /* Create a pseudo-filename for the mixin string, as it may not even exist
- * in the source file.
- */
- auto len = strlen(loc.filename) + 7 + (loc.linnum).sizeof * 3 + 1;
- char* filename = cast(char*)mem.xmalloc(len);
- snprintf(filename, len, "%s-mixin-%d", loc.filename, cast(int)loc.linnum);
- result = Loc(filename, loc.linnum, loc.charnum);
+ // Rare case of compiler-generated mixin exp, e.g. __xtoHash
+ baseLoc.filename = "";
+ return;
}
- else
- result = loc;
- return result;
+
+ /* Create a pseudo-filename for the mixin string, as it may not even exist
+ * in the source file.
+ */
+ auto len = sl.filename.length + 7 + (sl.linnum).sizeof * 3 + 1;
+ char* filename = cast(char*) mem.xmalloc(len);
+ snprintf(filename, len, "%.*s-mixin-%d", cast(int) sl.filename.length, sl.filename.ptr, cast(int) sl.linnum);
+ baseLoc.startLine = sl.line;
+ baseLoc.filename = filename.toDString;
}
/**************************************
* lines = line count to update
* output = sink for output
*/
-private void writeMixin(const(char)[] s, ref const Loc loc, ref int lines, ref OutBuffer buf)
+private void writeMixin(const(char)[] s, Loc loc, ref int lines, ref OutBuffer buf)
{
buf.writestring("// expansion at ");
buf.writestring(loc.toChars());
* Returns:
* null if not found
*/
-Dsymbol search(Dsymbol d, const ref Loc loc, Identifier ident, SearchOptFlags flags = SearchOpt.all)
+Dsymbol search(Dsymbol d, Loc loc, Identifier ident, SearchOptFlags flags = SearchOpt.all)
{
scope v = new SearchVisitor(loc, ident, flags);
d.accept(v);
SearchOptFlags flags;
Dsymbol result;
- this(const ref Loc loc, Identifier ident, SearchOptFlags flags) @safe
+ this(Loc loc, Identifier ident, SearchOptFlags flags) @safe
{
this.loc = loc;
this.ident = ident;
VarDeclaration* pvar;
Expression ce;
- static Dsymbol dollarFromTypeTuple(const ref Loc loc, TypeTuple tt, Scope* sc)
+ static Dsymbol dollarFromTypeTuple(Loc loc, TypeTuple tt, Scope* sc)
{
/* $ gives the number of type entries in the type tuple
* Returns:
* false if failed to determine the size.
*/
-bool determineSize(AggregateDeclaration ad, const ref Loc loc)
+bool determineSize(AggregateDeclaration ad, Loc loc)
{
//printf("AggregateDeclaration::determineSize() %s, sizeok = %d\n", toChars(), sizeok);
Array!Expression lastConstraintNegs; /// its negative parts
Objects* lastConstraintTiargs; /// template instance arguments for `lastConstraint`
- extern (D) this(const ref Loc loc, Identifier ident, TemplateParameters* parameters, Expression constraint, Dsymbols* decldefs, bool ismixin = false, bool literal = false)
+ extern (D) this(Loc loc, Identifier ident, TemplateParameters* parameters, Expression constraint, Dsymbols* decldefs, bool ismixin = false, bool literal = false)
{
super(loc, ident);
static if (LOG)
bool dependent;
/* ======================== TemplateParameter =============================== */
- extern (D) this(const ref Loc loc, Identifier ident) @safe
+ extern (D) this(Loc loc, Identifier ident) @safe
{
this.loc = loc;
this.ident = ident;
abstract RootObject specialization();
- abstract RootObject defaultArg(const ref Loc instLoc, Scope* sc);
+ abstract RootObject defaultArg(Loc instLoc, Scope* sc);
abstract bool hasDefaultArg();
extern (D) __gshared Type tdummy = null;
- extern (D) this(const ref Loc loc, Identifier ident, Type specType, Type defaultType) @safe
+ extern (D) this(Loc loc, Identifier ident, Type specType, Type defaultType) @safe
{
super(loc, ident);
this.specType = specType;
return specType;
}
- override final RootObject defaultArg(const ref Loc instLoc, Scope* sc)
+ override final RootObject defaultArg(Loc instLoc, Scope* sc)
{
Type t = defaultType;
if (t)
*/
extern (C++) final class TemplateThisParameter : TemplateTypeParameter
{
- extern (D) this(const ref Loc loc, Identifier ident, Type specType, Type defaultType) @safe
+ extern (D) this(Loc loc, Identifier ident, Type specType, Type defaultType) @safe
{
super(loc, ident, specType, defaultType);
}
extern (D) __gshared Expression[void*] edummies;
- extern (D) this(const ref Loc loc, Identifier ident, Type valType,
+ extern (D) this(Loc loc, Identifier ident, Type valType,
Expression specValue, Expression defaultValue) @safe
{
super(loc, ident);
return specValue;
}
- override RootObject defaultArg(const ref Loc instLoc, Scope* sc)
+ override RootObject defaultArg(Loc instLoc, Scope* sc)
{
Expression e = defaultValue;
if (!e)
extern (D) __gshared Dsymbol sdummy = null;
- extern (D) this(const ref Loc loc, Identifier ident, Type specType, RootObject specAlias, RootObject defaultAlias) @safe
+ extern (D) this(Loc loc, Identifier ident, Type specType, RootObject specAlias, RootObject defaultAlias) @safe
{
super(loc, ident);
this.specType = specType;
return specAlias;
}
- override RootObject defaultArg(const ref Loc instLoc, Scope* sc)
+ override RootObject defaultArg(Loc instLoc, Scope* sc)
{
RootObject da = defaultAlias;
if (auto ta = isType(defaultAlias))
*/
extern (C++) final class TemplateTupleParameter : TemplateParameter
{
- extern (D) this(const ref Loc loc, Identifier ident) @safe
+ extern (D) this(Loc loc, Identifier ident) @safe
{
super(loc, ident);
}
return null;
}
- override RootObject defaultArg(const ref Loc instLoc, Scope* sc)
+ override RootObject defaultArg(Loc instLoc, Scope* sc)
{
return null;
}
}
}
- extern (D) this(const ref Loc loc, Identifier ident, Objects* tiargs) scope
+ extern (D) this(Loc loc, Identifier ident, Objects* tiargs) scope
{
super(loc, null);
static if (LOG)
* This constructor is only called when we figured out which function
* template to instantiate.
*/
- extern (D) this(const ref Loc loc, TemplateDeclaration td, Objects* tiargs) scope
+ extern (D) this(Loc loc, TemplateDeclaration td, Objects* tiargs) scope
{
super(loc, null);
static if (LOG)
* Returns:
* false if one or more arguments have errors.
*/
- extern (D) static bool semanticTiargs(const ref Loc loc, Scope* sc, Objects* tiargs, int flags, TupleDeclaration atd = null)
+ extern (D) static bool semanticTiargs(Loc loc, Scope* sc, Objects* tiargs, int flags, TupleDeclaration atd = null)
{
// Run semantic on each argument, place results in tiargs[]
//printf("+TemplateInstance.semanticTiargs()\n");
{
TypeQualified tqual;
- extern (D) this(const ref Loc loc, Identifier ident, TypeQualified tqual, Objects* tiargs)
+ extern (D) this(Loc loc, Identifier ident, TypeQualified tqual, Objects* tiargs)
{
super(loc,
tqual.idents.length ? cast(Identifier)tqual.idents[tqual.idents.length - 1] : (cast(TypeIdentifier)tqual).ident,
*/
extern (C++) final class DebugSymbol : Dsymbol
{
- extern (D) this(const ref Loc loc, Identifier ident) @safe
+ extern (D) this(Loc loc, Identifier ident) @safe
{
super(loc, ident);
}
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, null);
}
extern (C++) final class VersionSymbol : Dsymbol
{
- extern (D) this(const ref Loc loc, Identifier ident) @safe
+ extern (D) this(Loc loc, Identifier ident) @safe
{
super(loc, ident);
}
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, null);
}
namespace dmd
{
// in enumsem.d
- Expression *getDefaultValue(EnumDeclaration *ed, const Loc &loc);
+ Expression *getDefaultValue(EnumDeclaration *ed, Loc loc);
}
class EnumDeclaration final : public ScopeDsymbol
//printf("members = %s\n", members.toChars());
}
-Expression getDefaultValue(EnumDeclaration ed, const ref Loc loc)
+Expression getDefaultValue(EnumDeclaration ed, Loc loc)
{
Expression handleErrors(){
ed.defaultval = ErrorExp.get();
return handleErrors();
}
-Type getMemtype(EnumDeclaration ed, const ref Loc loc)
+Type getMemtype(EnumDeclaration ed, Loc loc)
{
if (ed._scope)
{
import dmd.errorsink;
import dmd.globals;
import dmd.location;
+import dmd.root.string;
nothrow:
extern (C++):
override:
- void verror(const ref Loc loc, const(char)* format, va_list ap)
+ void verror(Loc loc, const(char)* format, va_list ap)
{
verrorReport(loc, format, ap, ErrorKind.error);
}
- void verrorSupplemental(const ref Loc loc, const(char)* format, va_list ap)
+ void verrorSupplemental(Loc loc, const(char)* format, va_list ap)
{
verrorReportSupplemental(loc, format, ap, ErrorKind.error);
}
- void vwarning(const ref Loc loc, const(char)* format, va_list ap)
+ void vwarning(Loc loc, const(char)* format, va_list ap)
{
verrorReport(loc, format, ap, ErrorKind.warning);
}
- void vwarningSupplemental(const ref Loc loc, const(char)* format, va_list ap)
+ void vwarningSupplemental(Loc loc, const(char)* format, va_list ap)
{
verrorReportSupplemental(loc, format, ap, ErrorKind.warning);
}
- void vdeprecation(const ref Loc loc, const(char)* format, va_list ap)
+ void vdeprecation(Loc loc, const(char)* format, va_list ap)
{
verrorReport(loc, format, ap, ErrorKind.deprecation);
}
- void vdeprecationSupplemental(const ref Loc loc, const(char)* format, va_list ap)
+ void vdeprecationSupplemental(Loc loc, const(char)* format, va_list ap)
{
verrorReportSupplemental(loc, format, ap, ErrorKind.deprecation);
}
- void vmessage(const ref Loc loc, const(char)* format, va_list ap)
+ void vmessage(Loc loc, const(char)* format, va_list ap)
{
verrorReport(loc, format, ap, ErrorKind.message);
}
static if (__VERSION__ < 2092)
- private extern (C++) void noop(const ref Loc loc, const(char)* format, ...) {}
+ private extern (C++) void noop(Loc loc, const(char)* format, ...) {}
else
- pragma(printf) private extern (C++) void noop(const ref Loc loc, const(char)* format, ...) {}
+ pragma(printf) private extern (C++) void noop(Loc loc, const(char)* format, ...) {}
package auto previewErrorFunc(bool isDeprecated, FeatureState featureState) @safe @nogc pure nothrow
* ... = printf-style variadic arguments
*/
static if (__VERSION__ < 2092)
- extern (C++) void error(const ref Loc loc, const(char)* format, ...)
+ extern (C++) void error(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
else
- pragma(printf) extern (C++) void error(const ref Loc loc, const(char)* format, ...)
+ pragma(printf) extern (C++) void error(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
static if (__VERSION__ < 2092)
extern (C++) void error(const(char)* filename, uint linnum, uint charnum, const(char)* format, ...)
{
- const loc = Loc(filename, linnum, charnum);
+ const loc = SourceLoc(filename.toDString, linnum, charnum);
va_list ap;
va_start(ap, format);
verrorReport(loc, format, ap, ErrorKind.error);
else
pragma(printf) extern (C++) void error(const(char)* filename, uint linnum, uint charnum, const(char)* format, ...)
{
- const loc = Loc(filename, linnum, charnum);
+ const loc = SourceLoc(filename.toDString, linnum, charnum);
va_list ap;
va_start(ap, format);
verrorReport(loc, format, ap, ErrorKind.error);
/// Callback for when the backend wants to report an error
extern(C++) void errorBackend(const(char)* filename, uint linnum, uint charnum, const(char)* format, ...)
{
- const loc = Loc(filename, linnum, charnum);
+ const loc = SourceLoc(filename.toDString, linnum, charnum);
va_list ap;
va_start(ap, format);
verrorReport(loc, format, ap, ErrorKind.error);
* ... = printf-style variadic arguments
*/
static if (__VERSION__ < 2092)
- extern (C++) void errorSupplemental(const ref Loc loc, const(char)* format, ...)
+ extern (C++) void errorSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
else
- pragma(printf) extern (C++) void errorSupplemental(const ref Loc loc, const(char)* format, ...)
+ pragma(printf) extern (C++) void errorSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
* ... = printf-style variadic arguments
*/
static if (__VERSION__ < 2092)
- extern (C++) void warning(const ref Loc loc, const(char)* format, ...)
+ extern (C++) void warning(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
else
- pragma(printf) extern (C++) void warning(const ref Loc loc, const(char)* format, ...)
+ pragma(printf) extern (C++) void warning(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
* ... = printf-style variadic arguments
*/
static if (__VERSION__ < 2092)
- extern (C++) void warningSupplemental(const ref Loc loc, const(char)* format, ...)
+ extern (C++) void warningSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
else
- pragma(printf) extern (C++) void warningSupplemental(const ref Loc loc, const(char)* format, ...)
+ pragma(printf) extern (C++) void warningSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
* ... = printf-style variadic arguments
*/
static if (__VERSION__ < 2092)
- extern (C++) void deprecation(const ref Loc loc, const(char)* format, ...)
+ extern (C++) void deprecation(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
else
- pragma(printf) extern (C++) void deprecation(const ref Loc loc, const(char)* format, ...)
+ pragma(printf) extern (C++) void deprecation(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
* ... = printf-style variadic arguments
*/
static if (__VERSION__ < 2092)
- extern (C++) void deprecationSupplemental(const ref Loc loc, const(char)* format, ...)
+ extern (C++) void deprecationSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
else
- pragma(printf) extern (C++) void deprecationSupplemental(const ref Loc loc, const(char)* format, ...)
+ pragma(printf) extern (C++) void deprecationSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
* ... = printf-style variadic arguments
*/
static if (__VERSION__ < 2092)
- extern (C++) void message(const ref Loc loc, const(char)* format, ...)
+ extern (C++) void message(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
else
- pragma(printf) extern (C++) void message(const ref Loc loc, const(char)* format, ...)
+ pragma(printf) extern (C++) void message(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
* p1 = additional message prefix
* p2 = additional message prefix
*/
-private extern(C++) void verrorReport(const ref Loc loc, const(char)* format, va_list ap, ErrorKind kind, const(char)* p1 = null, const(char)* p2 = null);
+private extern(C++) void verrorReport(Loc loc, const(char)* format, va_list ap, ErrorKind kind, const(char)* p1 = null, const(char)* p2 = null)
+{
+ return verrorReport(loc.SourceLoc, format, ap, kind, p1, p2);
+}
/// ditto
private extern(C++) void verrorReport(const SourceLoc loc, const(char)* format, va_list ap, ErrorKind kind, const(char)* p1 = null, const(char)* p2 = null);
* ap = printf-style variadic arguments
* kind = kind of error being printed
*/
-private extern(C++) void verrorReportSupplemental(const ref Loc loc, const(char)* format, va_list ap, ErrorKind kind);
+private extern(C++) void verrorReportSupplemental(Loc loc, const(char)* format, va_list ap, ErrorKind kind)
+{
+ return verrorReportSupplemental(loc.SourceLoc, format, ap, kind);
+}
/// ditto
private extern(C++) void verrorReportSupplemental(const SourceLoc loc, const(char)* format, va_list ap, ErrorKind kind);
#endif
// Print a warning, deprecation, or error, accepts printf-like format specifiers.
-D_ATTRIBUTE_FORMAT(2, 3) void warning(const Loc& loc, const char *format, ...);
-D_ATTRIBUTE_FORMAT(2, 3) void warningSupplemental(const Loc& loc, const char *format, ...);
-D_ATTRIBUTE_FORMAT(2, 3) void deprecation(const Loc& loc, const char *format, ...);
-D_ATTRIBUTE_FORMAT(2, 3) void deprecationSupplemental(const Loc& loc, const char *format, ...);
-D_ATTRIBUTE_FORMAT(2, 3) void error(const Loc& loc, const char *format, ...);
+D_ATTRIBUTE_FORMAT(2, 3) void warning(Loc loc, const char *format, ...);
+D_ATTRIBUTE_FORMAT(2, 3) void warningSupplemental(Loc loc, const char *format, ...);
+D_ATTRIBUTE_FORMAT(2, 3) void deprecation(Loc loc, const char *format, ...);
+D_ATTRIBUTE_FORMAT(2, 3) void deprecationSupplemental(Loc loc, const char *format, ...);
+D_ATTRIBUTE_FORMAT(2, 3) void error(Loc loc, const char *format, ...);
D_ATTRIBUTE_FORMAT(4, 5) void error(const char *filename, unsigned linnum, unsigned charnum, const char *format, ...);
-D_ATTRIBUTE_FORMAT(2, 3) void errorSupplemental(const Loc& loc, const char *format, ...);
+D_ATTRIBUTE_FORMAT(2, 3) void errorSupplemental(Loc loc, const char *format, ...);
D_ATTRIBUTE_FORMAT(1, 2) void message(const char *format, ...);
-D_ATTRIBUTE_FORMAT(2, 3) void message(const Loc& loc, const char *format, ...);
+D_ATTRIBUTE_FORMAT(2, 3) void message(Loc loc, const char *format, ...);
D_ATTRIBUTE_FORMAT(1, 2) void tip(const char *format, ...);
#if defined(__GNUC__) || defined(__clang__)
nothrow:
extern (C++):
- void verror(const ref Loc loc, const(char)* format, va_list ap);
- void verrorSupplemental(const ref Loc loc, const(char)* format, va_list ap);
- void vwarning(const ref Loc loc, const(char)* format, va_list ap);
- void vwarningSupplemental(const ref Loc loc, const(char)* format, va_list ap);
- void vmessage(const ref Loc loc, const(char)* format, va_list ap);
- void vdeprecation(const ref Loc loc, const(char)* format, va_list ap);
- void vdeprecationSupplemental(const ref Loc loc, const(char)* format, va_list ap);
-
- void error(const ref Loc loc, const(char)* format, ...)
+ void verror(Loc loc, const(char)* format, va_list ap);
+ void verrorSupplemental(Loc loc, const(char)* format, va_list ap);
+ void vwarning(Loc loc, const(char)* format, va_list ap);
+ void vwarningSupplemental(Loc loc, const(char)* format, va_list ap);
+ void vmessage(Loc loc, const(char)* format, va_list ap);
+ void vdeprecation(Loc loc, const(char)* format, va_list ap);
+ void vdeprecationSupplemental(Loc loc, const(char)* format, va_list ap);
+
+ void error(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
- void errorSupplemental(const ref Loc loc, const(char)* format, ...)
+ void errorSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
- void warning(const ref Loc loc, const(char)* format, ...)
+ void warning(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
- void warningSupplemental(const ref Loc loc, const(char)* format, ...)
+ void warningSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
- void message(const ref Loc loc, const(char)* format, ...)
+ void message(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
- void deprecation(const ref Loc loc, const(char)* format, ...)
+ void deprecation(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
}
- void deprecationSupplemental(const ref Loc loc, const(char)* format, ...)
+ void deprecationSupplemental(Loc loc, const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
extern (C++):
override:
- void verror(const ref Loc loc, const(char)* format, va_list ap) { }
+ void verror(Loc loc, const(char)* format, va_list ap) { }
- void verrorSupplemental(const ref Loc loc, const(char)* format, va_list ap) { }
+ void verrorSupplemental(Loc loc, const(char)* format, va_list ap) { }
- void vwarning(const ref Loc loc, const(char)* format, va_list ap) { }
+ void vwarning(Loc loc, const(char)* format, va_list ap) { }
- void vwarningSupplemental(const ref Loc loc, const(char)* format, va_list ap) { }
+ void vwarningSupplemental(Loc loc, const(char)* format, va_list ap) { }
- void vmessage(const ref Loc loc, const(char)* format, va_list ap) { }
+ void vmessage(Loc loc, const(char)* format, va_list ap) { }
- void vdeprecation(const ref Loc loc, const(char)* format, va_list ap) { }
+ void vdeprecation(Loc loc, const(char)* format, va_list ap) { }
- void vdeprecationSupplemental(const ref Loc loc, const(char)* format, va_list ap) { }
+ void vdeprecationSupplemental(Loc loc, const(char)* format, va_list ap) { }
}
/*****************************************
bool sawErrors;
- void verror(const ref Loc loc, const(char)* format, va_list ap) { sawErrors = true; }
+ void verror(Loc loc, const(char)* format, va_list ap) { sawErrors = true; }
}
/*****************************************
extern (C++):
override:
- void verror(const ref Loc loc, const(char)* format, va_list ap)
+ void verror(Loc loc, const(char)* format, va_list ap)
{
fputs("Error: ", stderr);
const p = loc.toChars();
fputc('\n', stderr);
}
- void verrorSupplemental(const ref Loc loc, const(char)* format, va_list ap) { }
+ void verrorSupplemental(Loc loc, const(char)* format, va_list ap) { }
- void vwarning(const ref Loc loc, const(char)* format, va_list ap)
+ void vwarning(Loc loc, const(char)* format, va_list ap)
{
fputs("Warning: ", stderr);
const p = loc.toChars();
fputc('\n', stderr);
}
- void vwarningSupplemental(const ref Loc loc, const(char)* format, va_list ap) { }
+ void vwarningSupplemental(Loc loc, const(char)* format, va_list ap) { }
- void vdeprecation(const ref Loc loc, const(char)* format, va_list ap)
+ void vdeprecation(Loc loc, const(char)* format, va_list ap)
{
fputs("Deprecation: ", stderr);
const p = loc.toChars();
fputc('\n', stderr);
}
- void vmessage(const ref Loc loc, const(char)* format, va_list ap)
+ void vmessage(Loc loc, const(char)* format, va_list ap)
{
const p = loc.toChars();
if (*p)
fputc('\n', stderr);
}
- void vdeprecationSupplemental(const ref Loc loc, const(char)* format, va_list ap) { }
+ void vdeprecationSupplemental(Loc loc, const(char)* format, va_list ap) { }
}
* (foo).size
* cast(foo).size
*/
-DotIdExp typeDotIdExp(const ref Loc loc, Type type, Identifier ident) @safe
+DotIdExp typeDotIdExp(Loc loc, Type type, Identifier ident) @safe
{
return new DotIdExp(loc, new TypeExp(loc, type), ident);
}
import dmd.common.bitfields;
mixin(generateBitFields!(BitFields, ubyte));
- extern (D) this(const ref Loc loc, EXP op) scope @safe
+ extern (D) this(Loc loc, EXP op) scope @safe
{
//printf("Expression::Expression(op = %d) this = %p\n", op, this);
this.loc = loc;
{
private dinteger_t value;
- extern (D) this(const ref Loc loc, dinteger_t value, Type type)
+ extern (D) this(Loc loc, dinteger_t value, Type type)
{
super(loc, EXP.int64);
//printf("IntegerExp(value = %lld, type = '%s')\n", value, type ? type.toChars() : "");
this.value = cast(int)value;
}
- static IntegerExp create(const ref Loc loc, dinteger_t value, Type type)
+ static IntegerExp create(Loc loc, dinteger_t value, Type type)
{
return new IntegerExp(loc, value, type);
}
{
real_t value;
- extern (D) this(const ref Loc loc, real_t value, Type type) @safe
+ extern (D) this(Loc loc, real_t value, Type type) @safe
{
super(loc, EXP.float64);
//printf("RealExp::RealExp(%Lg)\n", value);
this.type = type;
}
- static RealExp create(const ref Loc loc, real_t value, Type type) @safe
+ static RealExp create(Loc loc, real_t value, Type type) @safe
{
return new RealExp(loc, value, type);
}
{
complex_t value;
- extern (D) this(const ref Loc loc, complex_t value, Type type) @safe
+ extern (D) this(Loc loc, complex_t value, Type type) @safe
{
super(loc, EXP.complex80);
this.value = value;
//printf("ComplexExp::ComplexExp(%s)\n", toChars());
}
- static ComplexExp create(const ref Loc loc, complex_t value, Type type) @safe
+ static ComplexExp create(Loc loc, complex_t value, Type type) @safe
{
return new ComplexExp(loc, value, type);
}
{
Identifier ident;
- extern (D) this(const ref Loc loc, Identifier ident) scope @safe
+ extern (D) this(Loc loc, Identifier ident) scope @safe
{
super(loc, EXP.identifier);
this.ident = ident;
}
- static IdentifierExp create(const ref Loc loc, Identifier ident) @safe
+ static IdentifierExp create(Loc loc, Identifier ident) @safe
{
return new IdentifierExp(loc, ident);
}
*/
extern (C++) final class DollarExp : IdentifierExp
{
- extern (D) this(const ref Loc loc)
+ extern (D) this(Loc loc)
{
super(loc, Id.dollar);
}
Dsymbol s;
bool hasOverloads;
- extern (D) this(const ref Loc loc, Dsymbol s, bool hasOverloads = true) @safe
+ extern (D) this(Loc loc, Dsymbol s, bool hasOverloads = true) @safe
{
super(loc, EXP.dSymbol);
this.s = s;
{
VarDeclaration var;
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, EXP.this_);
//printf("ThisExp::ThisExp() loc = %d\n", loc.linnum);
}
- this(const ref Loc loc, const EXP tok) @safe
+ this(Loc loc, const EXP tok) @safe
{
super(loc, tok);
//printf("ThisExp::ThisExp() loc = %d\n", loc.linnum);
*/
extern (C++) final class SuperExp : ThisExp
{
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, EXP.super_);
}
*/
extern (C++) final class NullExp : Expression
{
- extern (D) this(const ref Loc loc, Type type = null) scope @safe
+ extern (D) this(Loc loc, Type type = null) scope @safe
{
super(loc, EXP.null_);
this.type = type;
enum char NoPostfix = 0;
- extern (D) this(const ref Loc loc, const(void)[] string) scope
+ extern (D) this(Loc loc, const(void)[] string) scope
{
super(loc, EXP.string_);
this.string = cast(char*)string.ptr; // note that this.string should be const
this.sz = 1; // work around LDC bug #1286
}
- extern (D) this(const ref Loc loc, const(void)[] string, size_t len, ubyte sz, char postfix = NoPostfix) scope
+ extern (D) this(Loc loc, const(void)[] string, size_t len, ubyte sz, char postfix = NoPostfix) scope
{
super(loc, EXP.string_);
this.string = cast(char*)string.ptr; // note that this.string should be const
this.postfix = postfix;
}
- static StringExp create(const ref Loc loc, const(char)* s)
+ static StringExp create(Loc loc, const(char)* s)
{
return new StringExp(loc, s.toDString());
}
- static StringExp create(const ref Loc loc, const(void)* string, size_t len)
+ static StringExp create(Loc loc, const(void)* string, size_t len)
{
return new StringExp(loc, string[0 .. len]);
}
enum char NoPostfix = 0;
- extern (D) this(const ref Loc loc, InterpolatedSet* set, char postfix = NoPostfix) scope @safe
+ extern (D) this(Loc loc, InterpolatedSet* set, char postfix = NoPostfix) scope @safe
{
super(loc, EXP.interpolated);
this.interpolatedSet = set;
Expressions* exps;
- extern (D) this(const ref Loc loc, Expression e0, Expressions* exps) @safe
+ extern (D) this(Loc loc, Expression e0, Expressions* exps) @safe
{
super(loc, EXP.tuple);
//printf("TupleExp(this = %p)\n", this);
this.exps = exps;
}
- extern (D) this(const ref Loc loc, Expressions* exps) @safe
+ extern (D) this(Loc loc, Expressions* exps) @safe
{
super(loc, EXP.tuple);
//printf("TupleExp(this = %p)\n", this);
this.exps = exps;
}
- extern (D) this(const ref Loc loc, TupleDeclaration tup)
+ extern (D) this(Loc loc, TupleDeclaration tup)
{
super(loc, EXP.tuple);
this.exps = new Expressions();
}
}
- static TupleExp create(const ref Loc loc, Expressions* exps) @safe
+ static TupleExp create(Loc loc, Expressions* exps) @safe
{
return new TupleExp(loc, exps);
}
Expressions* elements;
- extern (D) this(const ref Loc loc, Type type, Expressions* elements) @safe
+ extern (D) this(Loc loc, Type type, Expressions* elements) @safe
{
super(loc, EXP.arrayLiteral);
this.type = type;
this.elements = elements;
}
- extern (D) this(const ref Loc loc, Type type, Expression e)
+ extern (D) this(Loc loc, Type type, Expression e)
{
super(loc, EXP.arrayLiteral);
this.type = type;
elements.push(e);
}
- extern (D) this(const ref Loc loc, Type type, Expression basis, Expressions* elements) @safe
+ extern (D) this(Loc loc, Type type, Expression basis, Expressions* elements) @safe
{
super(loc, EXP.arrayLiteral);
this.type = type;
this.elements = elements;
}
- static ArrayLiteralExp create(const ref Loc loc, Expressions* elements) @safe
+ static ArrayLiteralExp create(Loc loc, Expressions* elements) @safe
{
return new ArrayLiteralExp(loc, null, elements);
}
/// Lower to core.internal.newaa for static initializaton
Expression lowering;
- extern (D) this(const ref Loc loc, Expressions* keys, Expressions* values) @safe
+ extern (D) this(Loc loc, Expressions* keys, Expressions* values) @safe
{
super(loc, EXP.assocArrayLiteral);
assert(keys.length == values.length);
toCBuffer = 0x20 /// toCBuffer is running
}
- extern (D) this(const ref Loc loc, StructDeclaration sd, Expressions* elements, Type stype = null) @safe
+ extern (D) this(Loc loc, StructDeclaration sd, Expressions* elements, Type stype = null) @safe
{
super(loc, EXP.structLiteral);
this.sd = sd;
//printf("StructLiteralExp::StructLiteralExp(%s)\n", toChars());
}
- static StructLiteralExp create(const ref Loc loc, StructDeclaration sd, void* elements, Type stype = null)
+ static StructLiteralExp create(Loc loc, StructDeclaration sd, void* elements, Type stype = null)
{
return new StructLiteralExp(loc, sd, cast(Expressions*)elements, stype);
}
{
Initializer initializer; /// initializer-list
- extern (D) this(const ref Loc loc, Type type_name, Initializer initializer) @safe
+ extern (D) this(Loc loc, Type type_name, Initializer initializer) @safe
{
super(loc, EXP.compoundLiteral);
super.type = type_name;
*/
extern (C++) final class TypeExp : Expression
{
- extern (D) this(const ref Loc loc, Type type) @safe
+ extern (D) this(Loc loc, Type type) @safe
{
super(loc, EXP.type);
//printf("TypeExp::TypeExp(%s)\n", type.toChars());
{
ScopeDsymbol sds;
- extern (D) this(const ref Loc loc, ScopeDsymbol sds) @safe
+ extern (D) this(Loc loc, ScopeDsymbol sds) @safe
{
super(loc, EXP.scope_);
//printf("ScopeExp::ScopeExp(sds = '%s')\n", sds.toChars());
TemplateDeclaration td;
FuncDeclaration fd;
- extern (D) this(const ref Loc loc, TemplateDeclaration td, FuncDeclaration fd = null) @safe
+ extern (D) this(Loc loc, TemplateDeclaration td, FuncDeclaration fd = null) @safe
{
super(loc, EXP.template_);
//printf("TemplateExp(): %s\n", td.toChars());
/// The fields are still separate for backwards compatibility
extern (D) ArgumentList argumentList() { return ArgumentList(arguments, names); }
- extern (D) this(const ref Loc loc, Expression thisexp, Type newtype, Expressions* arguments, Identifiers* names = null) @safe
+ extern (D) this(Loc loc, Expression thisexp, Type newtype, Expressions* arguments, Identifiers* names = null) @safe
{
super(loc, EXP.new_);
this.thisexp = thisexp;
this.names = names;
}
- static NewExp create(const ref Loc loc, Expression thisexp, Type newtype, Expressions* arguments) @safe
+ static NewExp create(Loc loc, Expression thisexp, Type newtype, Expressions* arguments) @safe
{
return new NewExp(loc, thisexp, newtype, arguments);
}
ClassDeclaration cd; // class being instantiated
Expressions* arguments; // Array of Expression's to call class constructor
- extern (D) this(const ref Loc loc, Expression thisexp, ClassDeclaration cd, Expressions* arguments) @safe
+ extern (D) this(Loc loc, Expression thisexp, ClassDeclaration cd, Expressions* arguments) @safe
{
super(loc, EXP.newAnonymousClass);
this.thisexp = thisexp;
Dsymbol originalScope; // original scope before inlining
bool hasOverloads;
- extern (D) this(const ref Loc loc, EXP op, Declaration var, bool hasOverloads) @safe
+ extern (D) this(Loc loc, EXP op, Declaration var, bool hasOverloads) @safe
{
super(loc, op);
assert(var);
{
dinteger_t offset;
- extern (D) this(const ref Loc loc, Declaration var, dinteger_t offset, bool hasOverloads = true)
+ extern (D) this(Loc loc, Declaration var, dinteger_t offset, bool hasOverloads = true)
{
if (auto v = var.isVarDeclaration())
{
extern (C++) final class VarExp : SymbolExp
{
bool delegateWasExtracted;
- extern (D) this(const ref Loc loc, Declaration var, bool hasOverloads = true) @safe
+ extern (D) this(Loc loc, Declaration var, bool hasOverloads = true) @safe
{
if (var.isVarDeclaration())
hasOverloads = false;
this.type = var.type;
}
- static VarExp create(const ref Loc loc, Declaration var, bool hasOverloads = true) @safe
+ static VarExp create(Loc loc, Declaration var, bool hasOverloads = true) @safe
{
return new VarExp(loc, var, hasOverloads);
}
{
OverloadSet vars;
- extern (D) this(const ref Loc loc, OverloadSet s)
+ extern (D) this(Loc loc, OverloadSet s)
{
super(loc, EXP.overloadSet);
//printf("OverExp(this = %p, '%s')\n", this, var.toChars());
TemplateDeclaration td;
TOK tok; // TOK.reserved, TOK.delegate_, TOK.function_
- extern (D) this(const ref Loc loc, Dsymbol s)
+ extern (D) this(Loc loc, Dsymbol s)
{
super(loc, EXP.function_);
this.td = s.isTemplateDeclaration();
{
Dsymbol declaration;
- extern (D) this(const ref Loc loc, Dsymbol declaration) @safe
+ extern (D) this(Loc loc, Dsymbol declaration) @safe
{
super(loc, EXP.declaration);
this.declaration = declaration;
{
RootObject obj;
- extern (D) this(const ref Loc loc, RootObject o) @safe
+ extern (D) this(Loc loc, RootObject o) @safe
{
super(loc, EXP.typeid_);
this.obj = o;
Identifier ident;
Objects* args;
- extern (D) this(const ref Loc loc, Identifier ident, Objects* args) @safe
+ extern (D) this(Loc loc, Identifier ident, Objects* args) @safe
{
super(loc, EXP.traits);
this.ident = ident;
*/
extern (C++) final class HaltExp : Expression
{
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, EXP.halt);
}
TOK tok; // ':' or '=='
TOK tok2; // 'struct', 'union', etc.
- extern (D) this(const ref Loc loc, Type targ, Identifier id, TOK tok, Type tspec, TOK tok2, TemplateParameters* parameters) scope @safe
+ extern (D) this(Loc loc, Type targ, Identifier id, TOK tok, Type tspec, TOK tok2, TemplateParameters* parameters) scope @safe
{
super(loc, EXP.is_);
this.targ = targ;
{
Expression e1;
- extern (D) this(const ref Loc loc, EXP op, Expression e1) scope @safe
+ extern (D) this(Loc loc, EXP op, Expression e1) scope @safe
{
super(loc, op);
this.e1 = e1;
Expression e1;
Expression e2;
- extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2) scope @safe
+ extern (D) this(Loc loc, EXP op, Expression e1, Expression e2) scope @safe
{
super(loc, op);
this.e1 = e1;
*/
extern (C++) class BinAssignExp : BinExp
{
- extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2) scope @safe
+ extern (D) this(Loc loc, EXP op, Expression e1, Expression e2) scope @safe
{
super(loc, op, e1, e2);
}
{
Expressions* exps;
- extern (D) this(const ref Loc loc, Expressions* exps) @safe
+ extern (D) this(Loc loc, Expressions* exps) @safe
{
super(loc, EXP.mixin_);
this.exps = exps;
*/
extern (C++) final class ImportExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e) @safe
+ extern (D) this(Loc loc, Expression e) @safe
{
super(loc, EXP.import_, e);
}
{
Expression msg;
- extern (D) this(const ref Loc loc, Expression e, Expression msg = null) @safe
+ extern (D) this(Loc loc, Expression e, Expression msg = null) @safe
{
super(loc, EXP.assert_, e);
this.msg = msg;
*/
extern (C++) final class ThrowExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e)
+ extern (D) this(Loc loc, Expression e)
{
super(loc, EXP.throw_, e);
}
bool wantsym; // do not replace Symbol with its initializer during semantic()
bool arrow; // ImportC: if -> instead of .
- extern (D) this(const ref Loc loc, Expression e, Identifier ident) @safe
+ extern (D) this(Loc loc, Expression e, Identifier ident) @safe
{
super(loc, EXP.dotIdentifier, e);
this.ident = ident;
}
- static DotIdExp create(const ref Loc loc, Expression e, Identifier ident) @safe
+ static DotIdExp create(Loc loc, Expression e, Identifier ident) @safe
{
return new DotIdExp(loc, e, ident);
}
{
TemplateDeclaration td;
- extern (D) this(const ref Loc loc, Expression e, TemplateDeclaration td) @safe
+ extern (D) this(Loc loc, Expression e, TemplateDeclaration td) @safe
{
super(loc, EXP.dotTemplateDeclaration, e);
this.td = td;
Declaration var;
bool hasOverloads;
- extern (D) this(const ref Loc loc, Expression e, Declaration var, bool hasOverloads = true) @safe
+ extern (D) this(Loc loc, Expression e, Declaration var, bool hasOverloads = true) @safe
{
if (var.isVarDeclaration())
hasOverloads = false;
{
TemplateInstance ti;
- extern (D) this(const ref Loc loc, Expression e, Identifier name, Objects* tiargs)
+ extern (D) this(Loc loc, Expression e, Identifier name, Objects* tiargs)
{
super(loc, EXP.dotTemplateInstance, e);
//printf("DotTemplateInstanceExp()\n");
this.ti = new TemplateInstance(loc, name, tiargs);
}
- extern (D) this(const ref Loc loc, Expression e, TemplateInstance ti) @safe
+ extern (D) this(Loc loc, Expression e, TemplateInstance ti) @safe
{
super(loc, EXP.dotTemplateInstance, e);
this.ti = ti;
bool hasOverloads;
VarDeclaration vthis2; // container for multi-context
- extern (D) this(const ref Loc loc, Expression e, FuncDeclaration f, bool hasOverloads = true, VarDeclaration vthis2 = null) @safe
+ extern (D) this(Loc loc, Expression e, FuncDeclaration f, bool hasOverloads = true, VarDeclaration vthis2 = null) @safe
{
super(loc, EXP.delegate_, e);
this.func = f;
{
Dsymbol sym; // symbol that represents a type
- extern (D) this(const ref Loc loc, Expression e, Dsymbol s) @safe
+ extern (D) this(Loc loc, Expression e, Dsymbol s) @safe
{
super(loc, EXP.dotType, e);
this.sym = s;
/// The fields are still separate for backwards compatibility
extern (D) ArgumentList argumentList() { return ArgumentList(arguments, names); }
- extern (D) this(const ref Loc loc, Expression e, Expressions* exps, Identifiers* names = null) @safe
+ extern (D) this(Loc loc, Expression e, Expressions* exps, Identifiers* names = null) @safe
{
super(loc, EXP.call, e);
this.arguments = exps;
this.names = names;
}
- extern (D) this(const ref Loc loc, Expression e) @safe
+ extern (D) this(Loc loc, Expression e) @safe
{
super(loc, EXP.call, e);
}
- extern (D) this(const ref Loc loc, Expression e, Expression earg1)
+ extern (D) this(Loc loc, Expression e, Expression earg1)
{
super(loc, EXP.call, e);
this.arguments = new Expressions();
this.arguments.push(earg1);
}
- extern (D) this(const ref Loc loc, Expression e, Expression earg1, Expression earg2)
+ extern (D) this(Loc loc, Expression e, Expression earg1, Expression earg2)
{
super(loc, EXP.call, e);
auto arguments = new Expressions(2);
* fd = the declaration of the function to call
* earg1 = the function argument
*/
- extern(D) this(const ref Loc loc, FuncDeclaration fd, Expression earg1)
+ extern(D) this(Loc loc, FuncDeclaration fd, Expression earg1)
{
this(loc, new VarExp(loc, fd, false), earg1);
this.f = fd;
}
- static CallExp create(const ref Loc loc, Expression e, Expressions* exps) @safe
+ static CallExp create(Loc loc, Expression e, Expressions* exps) @safe
{
return new CallExp(loc, e, exps);
}
- static CallExp create(const ref Loc loc, Expression e) @safe
+ static CallExp create(Loc loc, Expression e) @safe
{
return new CallExp(loc, e);
}
- static CallExp create(const ref Loc loc, Expression e, Expression earg1)
+ static CallExp create(Loc loc, Expression e, Expression earg1)
{
return new CallExp(loc, e, earg1);
}
* fd = the declaration of the function to call
* earg1 = the function argument
*/
- static CallExp create(const ref Loc loc, FuncDeclaration fd, Expression earg1)
+ static CallExp create(Loc loc, FuncDeclaration fd, Expression earg1)
{
return new CallExp(loc, fd, earg1);
}
*/
extern (C++) final class AddrExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e) @safe
+ extern (D) this(Loc loc, Expression e) @safe
{
super(loc, EXP.address, e);
}
- extern (D) this(const ref Loc loc, Expression e, Type t) @safe
+ extern (D) this(Loc loc, Expression e, Type t) @safe
{
this(loc, e);
type = t;
*/
extern (C++) final class PtrExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e) @safe
+ extern (D) this(Loc loc, Expression e) @safe
{
super(loc, EXP.star, e);
//if (e.type)
// type = ((TypePointer *)e.type).next;
}
- extern (D) this(const ref Loc loc, Expression e, Type t) @safe
+ extern (D) this(Loc loc, Expression e, Type t) @safe
{
super(loc, EXP.star, e);
type = t;
*/
extern (C++) final class NegExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e) @safe
+ extern (D) this(Loc loc, Expression e) @safe
{
super(loc, EXP.negate, e);
}
*/
extern (C++) final class UAddExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e) scope @safe
+ extern (D) this(Loc loc, Expression e) scope @safe
{
super(loc, EXP.uadd, e);
}
*/
extern (C++) final class ComExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e) @safe
+ extern (D) this(Loc loc, Expression e) @safe
{
super(loc, EXP.tilde, e);
}
*/
extern (C++) final class NotExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e) @safe
+ extern (D) this(Loc loc, Expression e) @safe
{
super(loc, EXP.not, e);
}
{
bool isRAII; // true if called automatically as a result of scoped destruction
- extern (D) this(const ref Loc loc, Expression e, bool isRAII) @safe
+ extern (D) this(Loc loc, Expression e, bool isRAII) @safe
{
super(loc, EXP.delete_, e);
this.isRAII = isRAII;
ubyte mod = cast(ubyte)~0; // MODxxxxx
bool trusted; // assume cast is safe
- extern (D) this(const ref Loc loc, Expression e, Type t) @safe
+ extern (D) this(Loc loc, Expression e, Type t) @safe
{
super(loc, EXP.cast_, e);
this.to = t;
/* For cast(const) and cast(immutable)
*/
- extern (D) this(const ref Loc loc, Expression e, ubyte mod) @safe
+ extern (D) this(Loc loc, Expression e, ubyte mod) @safe
{
super(loc, EXP.cast_, e);
this.mod = mod;
uint dim = ~0; // number of elements in the vector
OwnedBy ownedByCtfe = OwnedBy.code;
- extern (D) this(const ref Loc loc, Expression e, Type t) @trusted
+ extern (D) this(Loc loc, Expression e, Type t) @trusted
{
super(loc, EXP.vector, e);
assert(t.ty == Tvector);
to = cast(TypeVector)t;
}
- static VectorExp create(const ref Loc loc, Expression e, Type t) @safe
+ static VectorExp create(Loc loc, Expression e, Type t) @safe
{
return new VectorExp(loc, e, t);
}
*/
extern (C++) final class VectorArrayExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e1) @safe
+ extern (D) this(Loc loc, Expression e1) @safe
{
super(loc, EXP.vectorArray, e1);
}
mixin(generateBitFields!(BitFields, ubyte));
/************************************************************/
- extern (D) this(const ref Loc loc, Expression e1, IntervalExp ie) @safe
+ extern (D) this(Loc loc, Expression e1, IntervalExp ie) @safe
{
super(loc, EXP.slice, e1);
this.upr = ie ? ie.upr : null;
this.lwr = ie ? ie.lwr : null;
}
- extern (D) this(const ref Loc loc, Expression e1, Expression lwr, Expression upr) @safe
+ extern (D) this(Loc loc, Expression e1, Expression lwr, Expression upr) @safe
{
super(loc, EXP.slice, e1);
this.upr = upr;
*/
extern (C++) final class ArrayLengthExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e1) @safe
+ extern (D) this(Loc loc, Expression e1) @safe
{
super(loc, EXP.arrayLength, e1);
}
size_t currentDimension; // for opDollar
VarDeclaration lengthVar;
- extern (D) this(const ref Loc loc, Expression e1, Expression index = null)
+ extern (D) this(Loc loc, Expression e1, Expression index = null)
{
super(loc, EXP.array, e1);
arguments = new Expressions();
arguments.push(index);
}
- extern (D) this(const ref Loc loc, Expression e1, Expressions* args) @safe
+ extern (D) this(Loc loc, Expression e1, Expressions* args) @safe
{
super(loc, EXP.array, e1);
arguments = args;
*/
extern (C++) final class DotExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.dot, e1, e2);
}
bool allowCommaExp;
- extern (D) this(const ref Loc loc, Expression e1, Expression e2, bool generated = true) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2, bool generated = true) @safe
{
super(loc, EXP.comma, e1, e2);
allowCommaExp = isGenerated = generated;
Expression lwr;
Expression upr;
- extern (D) this(const ref Loc loc, Expression lwr, Expression upr) @safe
+ extern (D) this(Loc loc, Expression lwr, Expression upr) @safe
{
super(loc, EXP.interval);
this.lwr = lwr;
*/
extern (C++) final class DelegatePtrExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e1) @safe
+ extern (D) this(Loc loc, Expression e1) @safe
{
super(loc, EXP.delegatePointer, e1);
}
*/
extern (C++) final class DelegateFuncptrExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e1) @safe
+ extern (D) this(Loc loc, Expression e1) @safe
{
super(loc, EXP.delegateFunctionPointer, e1);
}
bool modifiable = false; // assume it is an rvalue
bool indexIsInBounds; // true if 0 <= e2 && e2 <= e1.length - 1
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.index, e1, e2);
//printf("IndexExp::IndexExp('%s')\n", toChars());
}
- extern (D) this(const ref Loc loc, Expression e1, Expression e2, bool indexIsInBounds) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2, bool indexIsInBounds) @safe
{
super(loc, EXP.index, e1, e2);
this.indexIsInBounds = indexIsInBounds;
*/
extern (C++) final class PostExp : BinExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e)
+ extern (D) this(EXP op, Loc loc, Expression e)
{
super(loc, op, e, IntegerExp.literal!1);
assert(op == EXP.minusMinus || op == EXP.plusPlus);
*/
extern (C++) final class PreExp : UnaExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e) @safe
+ extern (D) this(EXP op, Loc loc, Expression e) @safe
{
super(loc, op, e);
assert(op == EXP.preMinusMinus || op == EXP.prePlusPlus);
/************************************************************/
/* op can be EXP.assign, EXP.construct, or EXP.blit */
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.assign, e1, e2);
}
- this(const ref Loc loc, EXP tok, Expression e1, Expression e2) @safe
+ this(Loc loc, EXP tok, Expression e1, Expression e2) @safe
{
super(loc, tok, e1, e2);
}
*/
extern (C++) final class ConstructExp : AssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.construct, e1, e2);
}
// Internal use only. If `v` is a reference variable, the assignment
// will become a reference initialization automatically.
- extern (D) this(const ref Loc loc, VarDeclaration v, Expression e2) @safe
+ extern (D) this(Loc loc, VarDeclaration v, Expression e2) @safe
{
auto ve = new VarExp(loc, v);
assert(v.type && ve.type);
*/
extern (C++) final class BlitExp : AssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.blit, e1, e2);
}
// Internal use only. If `v` is a reference variable, the assinment
// will become a reference rebinding automatically.
- extern (D) this(const ref Loc loc, VarDeclaration v, Expression e2) @safe
+ extern (D) this(Loc loc, VarDeclaration v, Expression e2) @safe
{
auto ve = new VarExp(loc, v);
assert(v.type && ve.type);
*/
extern (C++) final class AddAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.addAssign, e1, e2);
}
*/
extern (C++) final class MinAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.minAssign, e1, e2);
}
*/
extern (C++) final class MulAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.mulAssign, e1, e2);
}
*/
extern (C++) final class DivAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.divAssign, e1, e2);
}
*/
extern (C++) final class ModAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.modAssign, e1, e2);
}
*/
extern (C++) final class AndAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.andAssign, e1, e2);
}
*/
extern (C++) final class OrAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.orAssign, e1, e2);
}
*/
extern (C++) final class XorAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.xorAssign, e1, e2);
}
*/
extern (C++) final class PowAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.powAssign, e1, e2);
}
*/
extern (C++) final class ShlAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.leftShiftAssign, e1, e2);
}
*/
extern (C++) final class ShrAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.rightShiftAssign, e1, e2);
}
*/
extern (C++) final class UshrAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.unsignedRightShiftAssign, e1, e2);
}
{
Expression lowering; // lowered druntime hook `_d_arrayappend{cTX,T}`
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.concatenateAssign, e1, e2);
}
- extern (D) this(const ref Loc loc, EXP tok, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, EXP tok, Expression e1, Expression e2) @safe
{
super(loc, tok, e1, e2);
}
*/
extern (C++) final class CatElemAssignExp : CatAssignExp
{
- extern (D) this(const ref Loc loc, Type type, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Type type, Expression e1, Expression e2) @safe
{
super(loc, EXP.concatenateElemAssign, e1, e2);
this.type = type;
*/
extern (C++) final class CatDcharAssignExp : CatAssignExp
{
- extern (D) this(const ref Loc loc, Type type, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Type type, Expression e1, Expression e2) @safe
{
super(loc, EXP.concatenateDcharAssign, e1, e2);
this.type = type;
*/
extern (C++) final class AddExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.add, e1, e2);
}
*/
extern (C++) final class MinExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.min, e1, e2);
}
{
Expression lowering; // call to druntime hook `_d_arraycatnTX`
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) scope @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) scope @safe
{
super(loc, EXP.concatenate, e1, e2);
}
*/
extern (C++) final class MulExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.mul, e1, e2);
}
*/
extern (C++) final class DivExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.div, e1, e2);
}
*/
extern (C++) final class ModExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.mod, e1, e2);
}
*/
extern (C++) final class PowExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.pow, e1, e2);
}
*/
extern (C++) final class ShlExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.leftShift, e1, e2);
}
*/
extern (C++) final class ShrExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.rightShift, e1, e2);
}
*/
extern (C++) final class UshrExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.unsignedRightShift, e1, e2);
}
*/
extern (C++) final class AndExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.and, e1, e2);
}
*/
extern (C++) final class OrExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.or, e1, e2);
}
*/
extern (C++) final class XorExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.xor, e1, e2);
}
*/
extern (C++) final class LogicalExp : BinExp
{
- extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, EXP op, Expression e1, Expression e2) @safe
{
super(loc, op, e1, e2);
assert(op == EXP.andAnd || op == EXP.orOr);
*/
extern (C++) final class CmpExp : BinExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(EXP op, Loc loc, Expression e1, Expression e2) @safe
{
super(loc, op, e1, e2);
assert(op == EXP.lessThan || op == EXP.lessOrEqual || op == EXP.greaterThan || op == EXP.greaterOrEqual);
*/
extern (C++) final class InExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.in_, e1, e2);
}
*/
extern (C++) final class RemoveExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(Loc loc, Expression e1, Expression e2)
{
super(loc, EXP.remove, e1, e2);
type = Type.tbool;
*/
extern (C++) final class EqualExp : BinExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(EXP op, Loc loc, Expression e1, Expression e2) @safe
{
super(loc, op, e1, e2);
assert(op == EXP.equal || op == EXP.notEqual);
*/
extern (C++) final class IdentityExp : BinExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2) @safe
+ extern (D) this(EXP op, Loc loc, Expression e1, Expression e2) @safe
{
super(loc, op, e1, e2);
assert(op == EXP.identity || op == EXP.notIdentity);
{
Expression econd;
- extern (D) this(const ref Loc loc, Expression econd, Expression e1, Expression e2) scope @safe
+ extern (D) this(Loc loc, Expression econd, Expression e1, Expression e2) scope @safe
{
super(loc, EXP.question, e1, e2);
this.econd = econd;
* op = EXP.prettyFunction, EXP.functionString, EXP.moduleString,
* EXP.line, EXP.file, EXP.fileFullPath
*/
- extern (D) this(const ref Loc loc, EXP op) @safe
+ extern (D) this(Loc loc, EXP op) @safe
{
super(loc, op);
}
*/
extern (C++) final class FileInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc, EXP tok) @safe
+ extern (D) this(Loc loc, EXP tok) @safe
{
super(loc, tok);
}
*/
extern (C++) final class LineInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, EXP.line);
}
*/
extern (C++) final class ModuleInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, EXP.moduleString);
}
*/
extern (C++) final class FuncInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, EXP.functionString);
}
*/
extern (C++) final class PrettyFuncInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, EXP.prettyFunction);
}
{
StructLiteralExp value;
- extern (D) this(const ref Loc loc, StructLiteralExp lit, Type type) @safe
+ extern (D) this(Loc loc, StructLiteralExp lit, Type type) @safe
{
super(loc, EXP.classReference);
assert(lit && lit.sd && lit.sd.isClassDeclaration());
{
ClassReferenceExp thrown; // the thing being tossed
- extern (D) this(const ref Loc loc, ClassReferenceExp victim) @safe
+ extern (D) this(Loc loc, ClassReferenceExp victim) @safe
{
super(loc, EXP.thrownException);
this.thrown = victim;
{
ClassDeclaration classDeclaration;
- extern (D) this(const ref Loc loc, ClassDeclaration classDeclaration) @safe
+ extern (D) this(Loc loc, ClassDeclaration classDeclaration) @safe
{
super(loc, EXP.objcClassReference);
this.classDeclaration = classDeclaration;
Types* types; /// type-names for generic associations (null entry for `default`)
Expressions* exps; /// 1:1 mapping of typeNames to exps
- extern (D) this(const ref Loc loc, Expression cntlExp, Types* types, Expressions* exps) @safe
+ extern (D) this(Loc loc, Expression cntlExp, Types* types, Expressions* exps) @safe
{
super(loc, EXP._Generic);
this.cntlExp = cntlExp;
// in expressionsem.d
Expression *expressionSemantic(Expression *e, Scope *sc);
// in typesem.d
- Expression *defaultInit(Type *mt, const Loc &loc, const bool isCfile = false);
+ Expression *defaultInit(Type *mt, Loc loc, const bool isCfile = false);
// Entry point for CTFE.
// A compile-time result is required. Give an error if not possible
public:
dinteger_t value;
- static IntegerExp *create(const Loc &loc, dinteger_t value, Type *type);
+ static IntegerExp *create(Loc loc, dinteger_t value, Type *type);
bool equals(const RootObject * const o) const override;
dinteger_t toInteger() override;
real_t toReal() override;
public:
real_t value;
- static RealExp *create(const Loc &loc, real_t value, Type *type);
+ static RealExp *create(Loc loc, real_t value, Type *type);
bool equals(const RootObject * const o) const override;
bool isIdentical(const Expression *e) const override;
dinteger_t toInteger() override;
public:
complex_t value;
- static ComplexExp *create(const Loc &loc, complex_t value, Type *type);
+ static ComplexExp *create(Loc loc, complex_t value, Type *type);
bool equals(const RootObject * const o) const override;
bool isIdentical(const Expression *e) const override;
dinteger_t toInteger() override;
public:
Identifier *ident;
- static IdentifierExp *create(const Loc &loc, Identifier *ident);
+ static IdentifierExp *create(Loc loc, Identifier *ident);
bool isLvalue() override final;
void accept(Visitor *v) override { v->visit(this); }
};
d_bool committed; // if type is committed
d_bool hexString; // if string is parsed from a hex string literal
- static StringExp *create(const Loc &loc, const char *s);
- static StringExp *create(const Loc &loc, const void *s, d_size_t len);
+ static StringExp *create(Loc loc, const char *s);
+ static StringExp *create(Loc loc, const void *s, d_size_t len);
bool equals(const RootObject * const o) const override;
char32_t getCodeUnit(d_size_t i) const;
dinteger_t getIndex(d_size_t i) const;
*/
Expressions *exps;
- static TupleExp *create(const Loc &loc, Expressions *exps);
+ static TupleExp *create(Loc loc, Expressions *exps);
TupleExp *syntaxCopy() override;
bool equals(const RootObject * const o) const override;
Expression *basis;
Expressions *elements;
- static ArrayLiteralExp *create(const Loc &loc, Expressions *elements);
+ static ArrayLiteralExp *create(Loc loc, Expressions *elements);
ArrayLiteralExp *syntaxCopy() override;
bool equals(const RootObject * const o) const override;
Expression *getElement(d_size_t i);
StructLiteralExp *origin;
- static StructLiteralExp *create(const Loc &loc, StructDeclaration *sd, void *elements, Type *stype = nullptr);
+ static StructLiteralExp *create(Loc loc, StructDeclaration *sd, void *elements, Type *stype = nullptr);
bool equals(const RootObject * const o) const override;
StructLiteralExp *syntaxCopy() override;
Expression *lowering; // lowered druntime hook: `_d_newclass`
- static NewExp *create(const Loc &loc, Expression *thisexp, Type *newtype, Expressions *arguments);
+ static NewExp *create(Loc loc, Expression *thisexp, Type *newtype, Expressions *arguments);
NewExp *syntaxCopy() override;
void accept(Visitor *v) override { v->visit(this); }
{
public:
d_bool delegateWasExtracted;
- static VarExp *create(const Loc &loc, Declaration *var, bool hasOverloads = true);
+ static VarExp *create(Loc loc, Declaration *var, bool hasOverloads = true);
bool equals(const RootObject * const o) const override;
bool isLvalue() override;
d_bool wantsym; // do not replace Symbol with its initializer during semantic()
d_bool arrow; // ImportC: if -> instead of .
- static DotIdExp *create(const Loc &loc, Expression *e, Identifier *ident);
+ static DotIdExp *create(Loc loc, Expression *e, Identifier *ident);
void accept(Visitor *v) override { v->visit(this); }
};
d_bool isUfcsRewrite; // the first argument was pushed in here by a UFCS rewrite
VarDeclaration *vthis2; // container for multi-context
- static CallExp *create(const Loc &loc, Expression *e, Expressions *exps);
- static CallExp *create(const Loc &loc, Expression *e);
- static CallExp *create(const Loc &loc, Expression *e, Expression *earg1);
- static CallExp *create(const Loc &loc, FuncDeclaration *fd, Expression *earg1);
+ static CallExp *create(Loc loc, Expression *e, Expressions *exps);
+ static CallExp *create(Loc loc, Expression *e);
+ static CallExp *create(Loc loc, Expression *e, Expression *earg1);
+ static CallExp *create(Loc loc, FuncDeclaration *fd, Expression *earg1);
CallExp *syntaxCopy() override;
bool isLvalue() override;
unsigned dim; // number of elements in the vector
OwnedBy ownedByCtfe;
- static VectorExp *create(const Loc &loc, Expression *e, Type *t);
+ static VectorExp *create(Loc loc, Expression *e, Type *t);
VectorExp *syntaxCopy() override;
void accept(Visitor *v) override { v->visit(this); }
};
* Returns:
* `s` turned into an expression, `ErrorExp` if an error occurred
*/
-Expression symbolToExp(Dsymbol s, const ref Loc loc, Scope* sc, bool hasOverloads)
+Expression symbolToExp(Dsymbol s, Loc loc, Scope* sc, bool hasOverloads)
{
static if (LOGSEMANTIC)
{
* Returns:
* Expression representing the `this` for the var
*/
-private Expression getRightThis(const ref Loc loc, Scope* sc, AggregateDeclaration ad, Expression e1, Dsymbol var, int flag = 0)
+private Expression getRightThis(Loc loc, Scope* sc, AggregateDeclaration ad, Expression e1, Dsymbol var, int flag = 0)
{
//printf("\ngetRightThis(e1 = %s, ad = %s, var = %s)\n", e1.toChars(), ad.toChars(), var.toChars());
L1:
* we can only call other pure functions.
* Returns true if error occurs.
*/
-private bool checkPurity(FuncDeclaration f, const ref Loc loc, Scope* sc)
+private bool checkPurity(FuncDeclaration f, Loc loc, Scope* sc)
{
if (!sc.func)
return false;
* check = current check (e.g. whether it's pure)
* checkName = the kind of check (e.g. `"pure"`)
*/
-void checkOverriddenDtor(FuncDeclaration f, Scope* sc, const ref Loc loc,
+void checkOverriddenDtor(FuncDeclaration f, Scope* sc, Loc loc,
scope bool function(DtorDeclaration) check, const string checkName)
{
auto dd = f.isDtorDeclaration();
* Check for purity and safety violations.
* Returns true if error occurs.
*/
-private bool checkPurity(VarDeclaration v, const ref Loc loc, Scope* sc)
+private bool checkPurity(VarDeclaration v, Loc loc, Scope* sc)
{
//printf("v = %s %s\n", v.type.toChars(), v.toChars());
/* Look for purity and safety violations when accessing variable v
return t0;
}
-private Expression opAssignToOp(const ref Loc loc, EXP op, Expression e1, Expression e2) @safe
+private Expression opAssignToOp(Loc loc, EXP op, Expression e1, Expression e2) @safe
{
Expression e;
switch (op)
* Returns:
* true errors happened
*/
-private bool functionParameters(const ref Loc loc, Scope* sc,
+private bool functionParameters(Loc loc, Scope* sc,
TypeFunction tf, Expression ethis, Type tthis, ArgumentList argumentList, FuncDeclaration fd,
Type* prettype, Expression* peprefix)
{
const len = buf.length;
const str = buf.extractChars()[0 .. len];
const bool doUnittests = global.params.parsingUnittestsRequired();
- auto loc = adjustLocForMixin(str, exp.loc, global.params.mixinOut);
- scope p = new Parser!ASTCodegen(loc, sc._module, str, false, global.errorSink, &global.compileEnv, doUnittests);
+ scope p = new Parser!ASTCodegen(sc._module, str, false, global.errorSink, &global.compileEnv, doUnittests);
+ adjustLocForMixin(str, exp.loc, *p.baseLoc, global.params.mixinOut);
+ p.linnum = p.baseLoc.startLine;
p.nextToken();
//printf("p.loc.linnum = %d\n", p.loc.linnum);
// symbol.mangleof
// return mangleof as an Expression
- static Expression dotMangleof(const ref Loc loc, Scope* sc, Dsymbol ds, bool hasOverloads)
+ static Expression dotMangleof(Loc loc, Scope* sc, Dsymbol ds, bool hasOverloads)
{
Expression e;
/****************************************
* Resolve __FILE__, __LINE__, __MODULE__, __FUNCTION__, __PRETTY_FUNCTION__, __FILE_FULL_PATH__ to loc.
*/
-Expression resolveLoc(Expression exp, const ref Loc loc, Scope* sc)
+Expression resolveLoc(Expression exp, Loc loc, Scope* sc)
{
// Don't replace the special keywords, while we are inside a default
// argument. They are replaced later when copied to the call site.
* Returns:
* Expression representing the `this` for the var
*/
-Expression getThisSkipNestedFuncs(const ref Loc loc, Scope* sc, Dsymbol s, AggregateDeclaration ad, Expression e1, Type t, Dsymbol var, bool flag = false)
+Expression getThisSkipNestedFuncs(Loc loc, Scope* sc, Dsymbol s, AggregateDeclaration ad, Expression e1, Type t, Dsymbol var, bool flag = false)
{
int n = 0;
while (s && s.isFuncDeclaration())
* newly created variable such that a closure is made for the variable when
* the address of `fd` is taken.
*/
-private VarDeclaration makeThis2Argument(const ref Loc loc, Scope* sc, FuncDeclaration fd)
+private VarDeclaration makeThis2Argument(Loc loc, Scope* sc, FuncDeclaration fd)
{
Type tthis2 = Type.tvoidptr.sarrayOf(2);
VarDeclaration vthis2 = new VarDeclaration(loc, tthis2, Identifier.generateId("__this"), null);
* Returns:
* a `bool` indicating if the hook is present.
*/
-bool verifyHookExist(const ref Loc loc, ref Scope sc, Identifier id, string description, Identifier module_ = Id.object)
+bool verifyHookExist(Loc loc, ref Scope sc, Identifier id, string description, Identifier module_ = Id.object)
{
Dsymbol pscopesym;
auto rootSymbol = sc.search(loc, Id.empty, pscopesym);
* false if any errors occur,
* otherwise true and elements[] are rewritten for the output.
*/
-private bool fit(StructDeclaration sd, const ref Loc loc, Scope* sc, Expressions* elements, Type stype)
+private bool fit(StructDeclaration sd, Loc loc, Scope* sc, Expressions* elements, Type stype)
{
if (!elements)
return true;
* Returns:
* VarExp referenceing `em` or ErrorExp if `em` if disabled/deprecated
*/
-Expression getVarExp(EnumMember em, const ref Loc loc, Scope* sc)
+Expression getVarExp(EnumMember em, Loc loc, Scope* sc)
{
dsymbolSemantic(em, sc);
if (em.errors)
* false if any errors occur.
* Otherwise, returns true and the missing arguments will be pushed in elements[].
*/
-bool fill(StructDeclaration sd, const ref Loc loc, ref Expressions elements, bool ctorinit)
+bool fill(StructDeclaration sd, Loc loc, ref Expressions elements, bool ctorinit)
{
//printf("AggregateDeclaration::fill() %s\n", toChars());
assert(sd.sizeok == Sizeok.done);
*/
ObjcFuncDeclaration objc;
- extern (D) this(const ref Loc loc, const ref Loc endloc, Identifier ident, StorageClass storage_class, Type type, bool noreturn = false)
+ extern (D) this(Loc loc, Loc endloc, Identifier ident, StorageClass storage_class, Type type, bool noreturn = false)
{
super(loc, ident);
//.printf("FuncDeclaration(id = '%s', type = %s)\n", ident.toChars(), type.toChars());
this.inferRetType = true;
}
- static FuncDeclaration create(const ref Loc loc, const ref Loc endloc, Identifier id, StorageClass storage_class, Type type, bool noreturn = false)
+ static FuncDeclaration create(Loc loc, Loc endloc, Identifier id, StorageClass storage_class, Type type, bool noreturn = false)
{
return new FuncDeclaration(loc, endloc, id, storage_class, type, noreturn);
}
*
* Returns: the `LabelDsymbol` for `ident`
*/
- final LabelDsymbol searchLabel(Identifier ident, const ref Loc loc)
+ final LabelDsymbol searchLabel(Identifier ident, Loc loc)
{
Dsymbol s;
if (!labtab)
// backend
bool deferToObj;
- extern (D) this(const ref Loc loc, const ref Loc endloc, Type type, TOK tok, ForeachStatement fes, Identifier id = null, StorageClass storage_class = STC.undefined_)
+ extern (D) this(Loc loc, Loc endloc, Type type, TOK tok, ForeachStatement fes, Identifier id = null, StorageClass storage_class = STC.undefined_)
{
super(loc, endloc, null, storage_class, type);
this.ident = id ? id : Id.empty;
{
bool isCpCtor; // copy constructor
bool isMoveCtor; // move constructor (aka rvalue constructor)
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc, Type type)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc, Type type)
{
super(loc, endloc, Id.ctor, stc, type);
//printf("CtorDeclaration(loc = %s) %s %p\n", loc.toChars(), toChars(), this);
*/
extern (C++) final class PostBlitDeclaration : FuncDeclaration
{
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc, Identifier id)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc, Identifier id)
{
super(loc, endloc, id, stc, null);
}
*/
extern (C++) final class DtorDeclaration : FuncDeclaration
{
- extern (D) this(const ref Loc loc, const ref Loc endloc)
+ extern (D) this(Loc loc, Loc endloc)
{
super(loc, endloc, Id.dtor, STC.undefined_, null);
}
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc, Identifier id)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc, Identifier id)
{
super(loc, endloc, id, stc, null);
}
*/
extern (C++) class StaticCtorDeclaration : FuncDeclaration
{
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc)
{
super(loc, endloc, Identifier.generateIdWithLoc("_staticCtor", loc), STC.static_ | stc, null);
}
- extern (D) this(const ref Loc loc, const ref Loc endloc, string name, StorageClass stc)
+ extern (D) this(Loc loc, Loc endloc, string name, StorageClass stc)
{
super(loc, endloc, Identifier.generateIdWithLoc(name, loc), STC.static_ | stc, null);
}
/// Exclude this constructor from cyclic dependency check
bool standalone;
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc)
{
super(loc, endloc, "_sharedStaticCtor", stc);
}
{
VarDeclaration vgate; // 'gate' variable
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc)
{
super(loc, endloc, Identifier.generateIdWithLoc("_staticDtor", loc), STC.static_ | stc, null);
}
- extern (D) this(const ref Loc loc, const ref Loc endloc, string name, StorageClass stc)
+ extern (D) this(Loc loc, Loc endloc, string name, StorageClass stc)
{
super(loc, endloc, Identifier.generateIdWithLoc(name, loc), STC.static_ | stc, null);
}
*/
extern (C++) final class SharedStaticDtorDeclaration : StaticDtorDeclaration
{
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc)
{
super(loc, endloc, "_sharedStaticDtor", stc);
}
*/
extern (C++) final class InvariantDeclaration : FuncDeclaration
{
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc, Identifier id, Statement fbody)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc, Identifier id, Statement fbody)
{
// Make a unique invariant for now; we'll fix it up as we add it to the aggregate invariant list.
super(loc, endloc, id ? id : Identifier.generateId("__invariant"), stc, null);
// toObjFile() these nested functions after this one
FuncDeclarations deferredNested;
- extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc, char* codedoc)
+ extern (D) this(Loc loc, Loc endloc, StorageClass stc, char* codedoc)
{
super(loc, endloc, Identifier.generateIdWithLoc("__unittest", loc), stc, null);
this.codedoc = codedoc;
*/
extern (C++) final class NewDeclaration : FuncDeclaration
{
- extern (D) this(const ref Loc loc, StorageClass stc)
+ extern (D) this(Loc loc, StorageClass stc)
{
super(loc, Loc.initial, Id.classNew, STC.static_ | stc, null);
}
string action; /// Action that made the attribute fail to get inferred
- this(ref Loc loc, FuncDeclaration fd) { this.loc = loc; this.fd = fd; }
+ this(Loc loc, FuncDeclaration fd) { this.loc = loc; this.fd = fd; }
- this(ref Loc loc, const(char)* fmt, RootObject[] args)
+ this(Loc loc, const(char)* fmt, RootObject[] args)
{
this.loc = loc;
assert(args.length <= 4); // expand if necessary
* Check that this function type is properly resolved.
* If not, report "forward reference error" and return true.
*/
-extern (D) bool checkForwardRef(FuncDeclaration fd, const ref Loc loc)
+extern (D) bool checkForwardRef(FuncDeclaration fd, Loc loc)
{
if (!functionSemantic(fd))
return true;
* Returns:
* if match is found, then function symbol, else null
*/
-FuncDeclaration resolveFuncCall(const ref Loc loc, Scope* sc, Dsymbol s,
+FuncDeclaration resolveFuncCall(Loc loc, Scope* sc, Dsymbol s,
Objects* tiargs, Type tthis, ArgumentList argumentList, FuncResolveFlag flags)
{
//printf("resolveFuncCall() %s\n", s.toChars());
* declaration = the declaration to print overload candidates for
* showDeprecated = If `false`, `deprecated` function won't be shown
*/
-private void printCandidates(Decl)(const ref Loc loc, Decl declaration, bool showDeprecated)
+private void printCandidates(Decl)(Loc loc, Decl declaration, bool showDeprecated)
{
// max num of overloads to print (-v or -verror-supplements overrides this).
const uint DisplayLimit = global.params.v.errorSupplementCount();
* 4. If there's no candidates, it's "no match" and returns null with error report.
* e.g. If 'tthis' is const but there's no const methods.
*/
-FuncDeclaration overloadModMatch(FuncDeclaration thisfd, const ref Loc loc, Type tthis, ref bool hasOverloads)
+FuncDeclaration overloadModMatch(FuncDeclaration thisfd, Loc loc, Type tthis, ref bool hasOverloads)
{
//printf("FuncDeclaration::overloadModMatch('%s')\n", toChars());
MatchAccumulator m;
* -1 increase nesting by 1 (`target` is nested within 'fd')
* LevelError error
*/
-int getLevelAndCheck(FuncDeclaration fd, const ref Loc loc, Scope* sc, FuncDeclaration target,
+int getLevelAndCheck(FuncDeclaration fd, Loc loc, Scope* sc, FuncDeclaration target,
Declaration decl)
{
int level = fd.getLevel(target, sc.intypeof);
* then mark it as a delegate.
* Returns true if error occurs.
*/
-bool checkNestedFuncReference(FuncDeclaration fd, Scope* sc, const ref Loc loc)
+bool checkNestedFuncReference(FuncDeclaration fd, Scope* sc, Loc loc)
{
//printf("FuncDeclaration::checkNestedFuncReference() %s\n", toPrettyChars());
if (auto fld = fd.isFuncLiteralDeclaration())
ErrorSink errorSink; /// where the error messages go
ErrorSink errorSinkNull; /// where the error messages are ignored
- extern (C++) DArray!ubyte function(FileName, ref const Loc, ref OutBuffer) preprocess;
+ extern (C++) DArray!ubyte function(FileName, Loc, ref OutBuffer) preprocess;
nothrow:
ErrorSink* errorSink; // where the error messages go
ErrorSink* errorSinkNull; // where the error messages disappear
- DArray<unsigned char> (*preprocess)(FileName, const Loc&, OutBuffer&);
+ DArray<unsigned char> (*preprocess)(FileName, Loc, OutBuffer&);
/* Start gagging. Return the current number of gagged errors
*/
#endif
// file location
+struct SourceLoc
+{
+ DString filename;
+ uint32_t line;
+ uint32_t column;
+ uint32_t fileOffset;
+};
+
struct Loc
{
private:
- unsigned _linnum;
- unsigned _charnum;
- unsigned fileIndex;
+
+ unsigned int index;
+
+#if MARS && defined(__linux__) && defined(__i386__)
+ unsigned int dummy;
+#endif
+
public:
static void set(bool showColumns, MessageStyle messageStyle);
+ static Loc singleFilename(const char* const filename);
static bool showColumns;
static MessageStyle messageStyle;
Loc()
{
- _linnum = 0;
- _charnum = 0;
- fileIndex = 0;
- }
-
- Loc(const char *filename, unsigned linnum, unsigned charnum)
- {
- this->linnum(linnum);
- this->charnum(charnum);
- this->filename(filename);
+ index = 0;
}
uint32_t charnum() const;
- uint32_t charnum(uint32_t num);
uint32_t linnum() const;
- uint32_t linnum(uint32_t num);
const char *filename() const;
- void filename(const char *name);
+ SourceLoc toSourceLoc() const;
const char *toChars(
bool showColumns = Loc::showColumns,
MessageStyle messageStyle = Loc::messageStyle) const;
- bool equals(const Loc& loc) const;
+ bool equals(Loc loc) const;
};
enum class LINK : uint8_t
*ptoklist = null;
}
p.token = *toklist;
- p.scanloc = s.loc;
+ p.baseLoc.startLine = s.loc.linnum;
+ p.linnum = s.loc.linnum;
// Parse the gcc asm statement.
const errors = global.errors;
* Identifier (inside Identifier.idPool) with deterministic name based
* on the source location.
*/
- extern (D) static Identifier generateIdWithLoc(string prefix, const ref Loc loc, string parent = "")
+ extern (D) static Identifier generateIdWithLoc(string prefix, Loc loc, string parent = "")
{
// generate `<prefix>_L<line>_C<col>`
+ auto sl = SourceLoc(loc);
OutBuffer idBuf;
idBuf.writestring(prefix);
idBuf.writestring("_L");
- idBuf.print(loc.linnum);
+ idBuf.print(sl.line);
idBuf.writestring("_C");
- idBuf.print(loc.charnum);
+ idBuf.print(sl.column);
/**
* Make sure the identifiers are unique per filename, i.e., per module/mixin
* directly, but that would unnecessary lengthen symbols names. See issue:
* https://issues.dlang.org/show_bug.cgi?id=23722
*/
- static struct Key { Loc loc; string prefix; string parent; }
+ static struct Key { uint fileOffset; string prefix; string parent; }
__gshared uint[Key] counters;
static if (__traits(compiles, counters.update(Key.init, () => 0u, (ref uint a) => 0u)))
{
// 2.082+
- counters.update(Key(loc, prefix, parent),
+ counters.update(Key(loc.fileOffset, prefix, parent),
() => 1u, // insertion
(ref uint counter) // update
{
}
else
{
- const key = Key(loc, prefix, parent);
+ const key = Key(loc.fileOffset, prefix, parent);
if (auto pCounter = key in counters)
{
idBuf.writestring("_");
}
- extern (D) this(const ref Loc loc, InitKind kind) @safe
+ extern (D) this(Loc loc, InitKind kind) @safe
{
this.loc = loc;
this.kind = kind;
{
Type type; // type that this will initialize to
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, InitKind.void_);
}
{
Type type; // type that this will initialize to
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, InitKind.default_);
}
Identifiers field; // of Identifier *'s
Initializers value; // parallel array of Initializer *'s
- extern (D) this(const ref Loc loc)
+ extern (D) this(Loc loc)
{
super(loc, InitKind.struct_);
}
Type type; // type that array will be used to initialize
bool isCarray; // C array semantics
- extern (D) this(const ref Loc loc)
+ extern (D) this(Loc loc)
{
super(loc, InitKind.array);
}
bool expandTuples;
Expression exp;
- extern (D) this(const ref Loc loc, Expression exp) @safe
+ extern (D) this(Loc loc, Expression exp) @safe
{
super(loc, InitKind.exp);
this.exp = exp;
DesigInits initializerList; /// initializer-list
Type type; /// type that array will be used to initialize
- extern (D) this(const ref Loc loc)
+ extern (D) this(Loc loc)
{
super(loc, InitKind.C_);
}
}
}
- extern(D) void property(const char[] linename, const char[] charname, const ref Loc loc)
+ extern(D) void property(const char[] linename, const char[] charname, Loc loc)
{
if (loc.isValid())
{
nothrow:
-version (DMDLIB)
-{
- version = LocOffset;
-}
-
/***********************************************************
* Values to use for various magic identifiers
*/
{
private __gshared OutBuffer stringbuffer;
+ BaseLoc* baseLoc; // Used to generate `scanloc`, which is just an index into this data structure
Loc scanloc; // for error messages
Loc prevloc; // location of token before current
+ int linnum; // current line number
const(char)* p; // current character
ErrorSink errorSink,
const CompileEnv* compileEnv) scope
{
- scanloc = Loc(filename, 1, 1);
// debug printf("Lexer::Lexer(%p)\n", base);
// debug printf("lexer.filename = %s\n", filename);
token = Token.init;
+ this.baseLoc = newBaseLoc(filename, endoffset);
+ this.linnum = 1;
this.base = base;
this.end = base + endoffset;
p = base + begoffset;
tokenizeNewlines = true;
inTokenStringConstant = 0;
lastDocLine = 0;
- scanloc = Loc("#defines", 1, 1);
+
+ baseLoc = newBaseLoc("#defines", slice.length);
+ scanloc = baseLoc.getLoc(0);
}
/**********************************
*/
final void scan(Token* t)
{
- const lastLine = scanloc.linnum;
+ const lastLine = linnum;
Loc startLoc;
t.blockComment = null;
t.lineComment = null;
{
// if /** but not /**/
getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1);
- lastDocLine = scanloc.linnum;
+ lastDocLine = linnum;
}
continue;
case '/': // do // style comments
if (doDocComment && t.ptr[2] == '/')
{
getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1);
- lastDocLine = scanloc.linnum;
+ lastDocLine = linnum;
}
p = end;
t.loc = loc();
if (doDocComment && t.ptr[2] == '/')
{
getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1);
- lastDocLine = scanloc.linnum;
+ lastDocLine = linnum;
}
p++;
endOfLine();
{
// if /++ but not /++/
getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1);
- lastDocLine = scanloc.linnum;
+ lastDocLine = linnum;
}
continue;
}
* Returns:
* the escape sequence as a single character
*/
- private dchar escapeSequence(const ref Loc loc, ref const(char)* sequence, bool Ccompile, out dchar c2)
+ private dchar escapeSequence(Loc loc, ref const(char)* sequence, bool Ccompile, out dchar c2)
{
const(char)* p = sequence; // cache sequence reference on stack
scope(exit) sequence = p;
final Loc loc() @nogc
{
- scanloc.charnum = cast(ushort)(1 + p - line);
- version (LocOffset)
- scanloc.fileOffset = cast(uint)(p - base);
+ scanloc = baseLoc.getLoc(cast(uint) (p - base));
return scanloc;
}
eSink.error(token.loc, format, args);
}
- void error(T...)(const ref Loc loc, const(char)* format, T args)
+ void error(T...)(Loc loc, const(char)* format, T args)
{
eSink.error(loc, format, args);
}
eSink.errorSupplemental(token.loc, format, args);
}
- void deprecation(T...)(const ref Loc loc, const(char)* format, T args)
+ void deprecation(T...)(Loc loc, const(char)* format, T args)
{
eSink.deprecation(loc, format, args);
}
- void warning(T...)(const ref Loc loc, const(char)* format, T args)
+ void warning(T...)(Loc loc, const(char)* format, T args)
{
eSink.warning(loc, format, args);
}
*/
final void poundLine(ref Token tok, bool linemarker)
{
- auto linnum = this.scanloc.linnum;
const(char)* filespec = null;
bool flags;
case TOK.endOfLine:
if (!inTokenStringConstant)
{
- this.scanloc.linnum = linnum;
- if (filespec)
- this.scanloc.filename = filespec;
+ baseLoc.addSubstitution(cast(uint) (p - base), filespec, linnum);
}
return;
case TOK.file:
/**************************
* `p` should be at start of next line
*/
- private void endOfLine() @nogc @safe
+ private void endOfLine() @safe
{
- scanloc.linnum = scanloc.linnum + 1;
+ linnum += 1;
line = p;
+ baseLoc.newLine(cast(uint)(p - base));
}
/****************************
string expectedSupplemental;
bool gotError;
- void verror(const ref Loc loc, const(char)* format, va_list ap)
+ void verror(Loc loc, const(char)* format, va_list ap)
{
gotError = true;
char[100] buffer = void;
assert(expected == actual);
}
- void errorSupplemental(const ref Loc loc, const(char)* format, ...)
+ void errorSupplemental(Loc loc, const(char)* format, ...)
{
gotError = true;
char[128] buffer = void;
import dmd.root.filename;
import dmd.root.string: toDString;
-version (DMDLIB)
-{
- version = LocOffset;
-}
-
/// How code locations are formatted for diagnostic reporting
enum MessageStyle : ubyte
{
*/
struct Loc
{
- private uint _linnum;
- private uint _charnum;
- private uint fileIndex; // index into filenames[], starting from 1 (0 means no filename)
- version (LocOffset)
- uint fileOffset; /// utf8 code unit index relative to start of file, starting from 0
+ private uint index = 0; // offset into lineTable[]
+
+ // FIXME: This arbitrary size increase is needed to prevent segfault in
+ // runnable/test42.d on Ubuntu x86 when DMD was built with DMD 2.105 .. 2.110
+ // https://github.com/dlang/dmd/pull/20777#issuecomment-2614128849
+ version (DigitalMars) version (linux) version (X86)
+ private uint dummy;
- static immutable Loc initial; /// use for default initialization of const ref Loc's
+ static immutable Loc initial; /// use for default initialization of Loc's
extern (C++) __gshared bool showColumns;
extern (C++) __gshared MessageStyle messageStyle;
- __gshared Array!(const(char)*) filenames;
-
nothrow:
/*******************************
this.messageStyle = messageStyle;
}
- extern (C++) this(const(char)* filename, uint linnum, uint charnum) @safe
+ /// Returns: a Loc that simply holds a filename, with no line / column info
+ extern (C++) static Loc singleFilename(const char* filename)
{
- this._linnum = linnum;
- this._charnum = charnum;
- this.filename = filename;
+ Loc result;
+ locFileTable ~= BaseLoc(filename.toDString, locIndex, 0, [0]);
+ result.index = locIndex++;
+ return result;
}
/// utf8 code unit index relative to start of line, starting from 1
extern (C++) uint charnum() const @nogc @safe
{
- return _charnum;
- }
-
- /// ditto
- extern (C++) uint charnum(uint num) @nogc @safe
- {
- return _charnum = num;
+ return SourceLoc(this).column;
}
/// line number, starting from 1
- extern (C++) uint linnum() const @nogc @safe
- {
- return _linnum;
- }
-
- /// ditto
- extern (C++) uint linnum(uint num) @nogc @safe
+ extern (C++) uint linnum() const @nogc @trusted
{
- return _linnum = num;
+ return SourceLoc(this).line;
}
/// Advance this location to the first column of the next line
void nextLine()
{
- if (this._linnum)
- {
- this._linnum++;
- this.charnum = 0;
- }
+ const i = fileTableIndex(this.index);
+ const j = locFileTable[i].getLineIndex(this.index - locFileTable[i].startIndex);
+ if (j + 1 < locFileTable[i].lines.length)
+ index = locFileTable[i].startIndex + locFileTable[i].lines[j + 1];
}
/***
*/
extern (C++) const(char)* filename() const @nogc
{
- return fileIndex ? filenames[fileIndex - 1] : null;
- }
-
- /***
- * Set file name for this location
- * Params:
- * name = file name for location, null for no file name
- */
- extern (C++) void filename(const(char)* name) @trusted
- {
- if (name)
- {
- //printf("setting %s\n", name);
- filenames.push(name);
- fileIndex = cast(uint)filenames.length;
- assert(fileIndex, "internal compiler error: file name index overflow");
- }
- else
- fileIndex = 0;
+ return SourceLoc(this).filename.ptr; // _filename;
}
extern (C++) const(char)* toChars(
return SourceLoc(this).toChars(showColumns, messageStyle);
}
+ /// Returns: byte offset into source file
+ uint fileOffset() const
+ {
+ const i = fileTableIndex(this.index);
+ return this.index - locFileTable[i].startIndex;
+ }
+
+ /// Returns: this location as a SourceLoc
+ extern (C++) SourceLoc toSourceLoc() const @nogc @safe
+ {
+ return SourceLoc(this);
+ }
+
/**
* Checks for equivalence by comparing the filename contents (not the pointer) and character location.
*
* - Uses case-insensitive comparison on Windows
* - Ignores `charnum` if `Columns` is false.
*/
- extern (C++) bool equals(ref const(Loc) loc) const
+ extern (C++) bool equals(Loc loc) const
{
SourceLoc lhs = SourceLoc(this);
SourceLoc rhs = SourceLoc(loc);
*/
extern (D) bool opEquals(ref const(Loc) loc) const @trusted nothrow @nogc
{
- import core.stdc.string : strcmp;
-
- return charnum == loc.charnum &&
- linnum == loc.linnum &&
- (filename == loc.filename ||
- (filename && loc.filename && strcmp(filename, loc.filename) == 0));
+ return this.index == loc.index;
}
/// ditto
extern (D) size_t toHash() const @trusted nothrow
{
- import dmd.root.string : toDString;
-
- auto hash = hashOf(linnum);
- hash = hashOf(charnum, hash);
- hash = hashOf(filename.toDString, hash);
- return hash;
+ return hashOf(this.index);
}
/******************
*/
bool isValid() const pure @safe
{
- return fileIndex != 0;
+ return this.index != 0;
}
}
const(char)[] filename; /// name of source file
uint line; /// line number (starts at 1)
uint column; /// column number (starts at 1)
+ uint fileOffset; /// byte index into file
// aliases for backwards compatibility
alias linnum = line;
alias charnum = column;
- this(const(char)[] filename, uint line, uint column) nothrow
+ this(const(char)[] filename, uint line, uint column, uint fileOffset = 0) nothrow @nogc pure @safe
{
this.filename = filename;
this.line = line;
this.column = column;
+ this.fileOffset = fileOffset;
}
- this(Loc loc) nothrow
+ this(Loc loc) nothrow @nogc @trusted
{
- this.filename = loc.filename.toDString();
- this.line = loc.linnum;
- this.column = loc.charnum;
+ if (loc.index == 0 || locFileTable.length == 0)
+ return;
+
+ const i = fileTableIndex(loc.index);
+ this = locFileTable[i].getSourceLoc(loc.index - locFileTable[i].startIndex);
}
extern (C++) const(char)* toChars(
{
return this.filename == other.filename && this.line == other.line && this.column == other.column;
}
+
+}
+
+/// Given the `index` of a `Loc`, find the index in `locFileTable` of the corresponding `BaseLoc`
+private size_t fileTableIndex(uint index) nothrow @nogc
+{
+ // To speed up linear find, we cache the last hit and compare that first,
+ // since usually we stay in the same file for some time when resolving source locations.
+ // If it's a different file now, either scan forwards / backwards
+ __gshared size_t lastI = 0; // index of last found hit
+
+ size_t i = lastI;
+ if (index >= locFileTable[i].startIndex)
+ {
+ while (i + 1 < locFileTable.length && index >= locFileTable[i+1].startIndex)
+ i++;
+ }
+ else
+ {
+ while (index < locFileTable[i].startIndex)
+ i--;
+ }
+
+ lastI = i;
+ return i;
+}
+
+/**
+ * Create a new source location map for a file
+ * Params:
+ * filename = source file name
+ * size = space to reserve for locations, equal to the file size in bytes
+ * Returns: new BaseLoc
+ */
+BaseLoc* newBaseLoc(const(char)* filename, size_t size) nothrow
+{
+ locFileTable ~= BaseLoc(filename.toDString, locIndex, 1, [0]);
+ // Careful: the endloc of a FuncDeclaration can
+ // point to 1 past the very last byte in the file, so account for that
+ locIndex += size + 1;
+ return &locFileTable[$ - 1];
+}
+
+/**
+Mapping from byte offset into source file to line/column numbers
+
+Consider this 4-line 24 byte source file:
+
+---
+app.d
+1 struct S
+2 {
+3 int y;
+4 }
+---
+
+Loc(0) is reserved for null locations, so the first `BaseLoc` gets `startIndex = 1`
+and reserves 25 possible positions. Loc(1) represents the very start of this source
+file, and every next byte gets the next `Loc`, up to Loc(25) which represents the
+location right past the very last `}` character (hence it's 1 more than the file
+size of 24, classic fence post problem!).
+
+The next source file will get `Loc(26) .. Loc(26 + fileSize + 1)` etc.
+
+Now say we know that `int y` has a `Loc(20)` and we want to know the line and column number.
+
+First we find the corresponding `BaseLoc` in `locFileTable`. Since 20 < 26, the first `BaseLoc`
+contains this location. Since `startIndex = 1`, we subtract that to get a file offset 19.
+
+To get the line number from the file offset, we binary search into the `lines` array,
+which contains file offsets where each line starts:
+
+`locFileTable[0].lines == [0, 9, 11, 22, 24]`
+
+We see 14 would be inserted right after `11` at `lines[2]`, so it's line 3 (+1 for 1-indexing).
+Since line 3 starts at file offset 11, and `14 - 11 = 3`, it's column 4 (again, accounting for 1-indexing)
+
+#line and #file directives are handled with a separate array `substitutions` because they're rare,
+and we don't want to penalize memory usage in their absence.
+*/
+struct BaseLoc
+{
+@safe nothrow:
+
+ const(char)[] filename; /// Source file name
+ uint startIndex; /// Subtract this from Loc.index to get file offset
+ int startLine = 1; /// Line number at index 0
+ uint[] lines; /// For each line, the file offset at which it starts. At index 0 there's always a 0 entry.
+ BaseLoc[] substitutions; /// Substitutions from #line / #file directives
+
+ /// Register that a new line starts at `offset` bytes from the start of the source file
+ void newLine(uint offset)
+ {
+ lines ~= offset;
+ }
+
+ /// Construct a `Loc` entry for the start of the source file + `offset` bytes
+ Loc getLoc(uint offset) @nogc
+ {
+ Loc result;
+ result.index = startIndex + offset;
+ return result;
+ }
+
+ /**
+ * Register a new file/line mapping from #file and #line directives
+ * Params:
+ * offset = byte offset in the source file at which the substitution starts
+ * filename = new filename from this point on (null = unchanged)
+ * line = line number from this point on
+ */
+ void addSubstitution(uint offset, const(char)* filename, uint line) @system
+ {
+ auto fname = filename.toDString;
+ if (substitutions.length == 0)
+ substitutions ~= BaseLoc(this.filename, 0, 0);
+
+ if (fname.length == 0)
+ fname = substitutions[$ - 1].filename;
+ substitutions ~= BaseLoc(fname, offset, cast(int) (line - lines.length + startLine - 2));
+ }
+
+ /// Returns: `loc` modified by substitutions from #file / #line directives
+ SourceLoc substitute(SourceLoc loc) @nogc
+ {
+ if (substitutions.length == 0)
+ return loc;
+
+ const offset = loc.fileOffset;
+ size_t lo = 0;
+ size_t hi = substitutions.length + -1;
+ size_t mid = 0;
+ while (lo <= hi)
+ {
+ mid = lo + (hi - lo) / 2;
+ if (substitutions[mid].startIndex <= offset)
+ {
+ if (mid == substitutions.length - 1 || substitutions[mid + 1].startIndex > offset)
+ {
+ if (substitutions[mid].filename.length > 0)
+ loc.filename = substitutions[mid].filename;
+ loc.linnum += substitutions[mid].startLine;
+ return loc;
+ }
+
+ lo = mid + 1;
+ }
+ else
+ {
+ hi = mid - 1;
+ }
+ }
+ assert(0);
+ }
+
+ /// Resolve an offset into this file to a filename + line + column
+ private SourceLoc getSourceLoc(uint offset) @nogc
+ {
+ const i = getLineIndex(offset);
+ const sl = SourceLoc(filename, cast(int) (i + startLine), cast(int) (1 + offset - lines[i]), offset);
+ return substitute(sl);
+ }
+
+ /// Binary search the index in `this.lines` corresponding to `offset`
+ private size_t getLineIndex(uint offset) @nogc
+ {
+ size_t lo = 0;
+ size_t hi = lines.length + -1;
+ size_t mid = 0;
+ while (lo <= hi)
+ {
+ mid = lo + (hi - lo) / 2;
+ if (lines[mid] <= offset)
+ {
+ if (mid == lines.length - 1 || lines[mid + 1] > offset)
+ return mid;
+
+ lo = mid + 1;
+ }
+ else
+ {
+ hi = mid - 1;
+ }
+ }
+ assert(0);
+ }
}
+
+// Whenever a new source file is parsed, start the `Loc` from this index (0 is reserved for Loc.init)
+private __gshared uint locIndex = 1;
+
+// Global mapping of Loc indices to source file offset/line/column, see `BaseLoc`
+private __gshared BaseLoc[] locFileTable;
static Module* create(const char *arg, Identifier *ident, int doDocComment, int doHdrGen);
static const char *find(const char *filename);
- static Module *load(const Loc &loc, Identifiers *packages, Identifier *ident);
+ static Module *load(Loc loc, Identifiers *packages, Identifier *ident);
const char *kind() const override;
- bool read(const Loc &loc); // read file, returns 'true' if succeed, 'false' otherwise.
+ bool read(Loc loc); // read file, returns 'true' if succeed, 'false' otherwise.
Module *parse(); // syntactic parse
int needModuleInfo();
bool isPackageAccessible(Package *p, Visibility visibility, SearchOptFlags flags = (SearchOptFlags)SearchOpt::all) override;
* Use when we prefer the default initializer to be a literal,
* rather than a global immutable variable.
*/
- Expression defaultInitLiteral(const ref Loc loc)
+ Expression defaultInitLiteral(Loc loc)
{
static if (LOGDEFAULTINIT)
{
return this;
}
- override Expression defaultInitLiteral(const ref Loc loc)
+ override Expression defaultInitLiteral(Loc loc)
{
return ErrorExp.get();
}
return false;
}
- override Expression defaultInitLiteral(const ref Loc loc)
+ override Expression defaultInitLiteral(Loc loc)
{
//printf("TypeVector::defaultInitLiteral()\n");
assert(basetype.ty == Tsarray);
return next.alignment();
}
- override Expression defaultInitLiteral(const ref Loc loc)
+ override Expression defaultInitLiteral(Loc loc)
{
static if (LOGDEFAULTINIT)
{
/// Cached type/symbol after semantic analysis.
RootObject obj;
- final extern (D) this(const ref Loc loc, TraitsExp exp) @safe
+ final extern (D) this(Loc loc, TraitsExp exp) @safe
{
super(Ttraits);
this.loc = loc;
Expressions* exps;
RootObject obj; // cached result of semantic analysis.
- extern (D) this(const ref Loc loc, Expressions* exps) @safe
+ extern (D) this(Loc loc, Expressions* exps) @safe
{
super(Tmixin);
this.loc = loc;
// The symbol representing this identifier, before alias resolution
Dsymbol originalSymbol;
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(Loc loc, Identifier ident)
{
super(Tident, loc);
this.ident = ident;
}
- static TypeIdentifier create(const ref Loc loc, Identifier ident)
+ static TypeIdentifier create(Loc loc, Identifier ident)
{
return new TypeIdentifier(loc, ident);
}
{
TemplateInstance tempinst;
- extern (D) this(const ref Loc loc, TemplateInstance tempinst)
+ extern (D) this(Loc loc, TemplateInstance tempinst)
{
super(Tinstance, loc);
this.tempinst = tempinst;
Expression exp;
int inuse;
- extern (D) this(const ref Loc loc, Expression exp)
+ extern (D) this(Loc loc, Expression exp)
{
super(Ttypeof, loc);
this.exp = exp;
*/
extern (C++) final class TypeReturn : TypeQualified
{
- extern (D) this(const ref Loc loc)
+ extern (D) this(Loc loc)
{
super(Treturn, loc);
}
* Use when we prefer the default initializer to be a literal,
* rather than a global immutable variable.
*/
- override Expression defaultInitLiteral(const ref Loc loc)
+ override Expression defaultInitLiteral(Loc loc)
{
static if (LOGDEFAULTINIT)
{
/// struct S { int a; } s1, *s2;
MOD mod; /// modifiers to apply after type is resolved (only MODFlags.const_ at the moment)
- extern (D) this(const ref Loc loc, TOK tok, Identifier id, structalign_t packalign, Type base, Dsymbols* members) @safe
+ extern (D) this(Loc loc, TOK tok, Identifier id, structalign_t packalign, Type base, Dsymbols* members) @safe
{
//printf("TypeTag ctor %s %p\n", id ? id.toChars() : "null".ptr, this);
super(Ttag);
Expression defaultArg;
UserAttributeDeclaration userAttribDecl; // user defined attributes
- extern (D) this(const ref Loc loc, StorageClass storageClass, Type type, Identifier ident, Expression defaultArg, UserAttributeDeclaration userAttribDecl) @safe
+ extern (D) this(Loc loc, StorageClass storageClass, Type type, Identifier ident, Expression defaultArg, UserAttributeDeclaration userAttribDecl) @safe
{
this.loc = loc;
this.type = type;
this.userAttribDecl = userAttribDecl;
}
- static Parameter create(const ref Loc loc, StorageClass storageClass, Type type, Identifier ident, Expression defaultArg, UserAttributeDeclaration userAttribDecl) @safe
+ static Parameter create(Loc loc, StorageClass storageClass, Type type, Identifier ident, Expression defaultArg, UserAttributeDeclaration userAttribDecl) @safe
{
return new Parameter(loc, storageClass, type, ident, defaultArg, userAttribDecl);
}
namespace dmd
{
- Type *typeSemantic(Type *t, const Loc &loc, Scope *sc);
+ Type *typeSemantic(Type *t, Loc loc, Scope *sc);
Type *merge(Type *type);
}
virtual ClassDeclaration *isClassHandle();
virtual structalign_t alignment();
- virtual Expression *defaultInitLiteral(const Loc &loc);
+ virtual Expression *defaultInitLiteral(Loc loc);
virtual int hasWild() const;
virtual bool hasVoidInitPointers();
virtual bool hasUnsafeBitpatterns();
const char *kind() override;
TypeError *syntaxCopy() override;
- Expression *defaultInitLiteral(const Loc &loc) override;
+ Expression *defaultInitLiteral(Loc loc) override;
void accept(Visitor *v) override { v->visit(this); }
};
bool isScalar() override;
bool isUnsigned() override;
bool isBoolean() override;
- Expression *defaultInitLiteral(const Loc &loc) override;
+ Expression *defaultInitLiteral(Loc loc) override;
TypeBasic *elementType();
void accept(Visitor *v) override { v->visit(this); }
unsigned alignsize() override;
bool isString() override;
structalign_t alignment() override;
- Expression *defaultInitLiteral(const Loc &loc) override;
+ Expression *defaultInitLiteral(Loc loc) override;
bool hasUnsafeBitpatterns() override;
bool hasVoidInitPointers() override;
bool hasInvariant() override;
Expression *defaultArg;
UserAttributeDeclaration *userAttribDecl; // user defined attributes
- static Parameter *create(const Loc &loc, StorageClass storageClass, Type *type, Identifier *ident,
+ static Parameter *create(Loc loc, StorageClass storageClass, Type *type, Identifier *ident,
Expression *defaultArg, UserAttributeDeclaration *userAttribDecl);
Parameter *syntaxCopy();
Type *isLazyArray();
Identifier *ident;
Dsymbol *originalSymbol; // The symbol representing this identifier, before alias resolution
- static TypeIdentifier *create(const Loc &loc, Identifier *ident);
+ static TypeIdentifier *create(Loc loc, Identifier *ident);
const char *kind() override;
TypeIdentifier *syntaxCopy() override;
void accept(Visitor *v) override { v->visit(this); }
unsigned alignsize() override;
TypeStruct *syntaxCopy() override;
structalign_t alignment() override;
- Expression *defaultInitLiteral(const Loc &loc) override;
+ Expression *defaultInitLiteral(Loc loc) override;
bool isAssignable() override;
bool isBoolean() override;
bool needsDestruction() override;
const char *kind() override;
TypeEnum *syntaxCopy() override;
unsigned alignsize() override;
- Type *memType(const Loc &loc);
+ Type *memType(Loc loc);
bool isIntegral() override;
bool isFloating() override;
bool isReal() override;
bool equivalent(Type *src, Type *t);
Covariant covariant(Type *, Type *, StorageClass * = nullptr, bool = false);
bool isBaseOf(Type *tthis, Type *t, int *poffset);
- bool isZeroInit(Type *t, const Loc &loc = Loc());
- Type *trySemantic(Type *type, const Loc &loc, Scope *sc);
+ bool isZeroInit(Type *t, Loc loc = Loc());
+ Type *trySemantic(Type *type, Loc loc, Scope *sc);
Type *pointerTo(Type *type);
Type *referenceTo(Type *type);
Type *merge2(Type *type);
Type *addStorageClass(Type *type, StorageClass stc);
Type *substWildTo(Type *type, unsigned mod);
uinteger_t size(Type *type);
- uinteger_t size(Type *type, const Loc &loc);
+ uinteger_t size(Type *type, Loc loc);
MATCH implicitConvTo(Type* from, Type* to);
MATCH constConv(Type* from, Type* to);
}
return e;
}
-extern (D) void printGCUsage(FuncDeclaration fd, const ref Loc loc, const(char)* warn)
+extern (D) void printGCUsage(FuncDeclaration fd, Loc loc, const(char)* warn)
{
if (!global.params.v.gc)
return;
*/
Expression identExp;
- extern (D) this(const ref Loc loc, Identifier ident, Expression identExp, Dsymbols* members)
+ extern (D) this(Loc loc, Identifier ident, Expression identExp, Dsymbols* members)
{
super(loc, ident);
//printf("Nspace::Nspace(ident = %s)\n", ident.toChars());
}
}
- void dgReadVar(const ref Loc loc, ObNode* ob, VarDeclaration v, bool mutable)
+ void dgReadVar(Loc loc, ObNode* ob, VarDeclaration v, bool mutable)
{
if (log)
printf("dgReadVar() %s %d\n", v.toChars(), mutable);
{
alias visit = typeof(super).visit;
extern (D) void delegate(ObNode*, VarDeclaration, Expression, bool) dgWriteVar;
- extern (D) void delegate(const ref Loc loc, ObNode* ob, VarDeclaration v, bool mutable) dgReadVar;
+ extern (D) void delegate(Loc loc, ObNode* ob, VarDeclaration v, bool mutable) dgReadVar;
ObNode* ob;
ObState* obstate;
extern (D) this(void delegate(ObNode*, VarDeclaration, Expression, bool) dgWriteVar,
- void delegate(const ref Loc loc, ObNode* ob, VarDeclaration v, bool mutable) dgReadVar,
+ void delegate(Loc loc, ObNode* ob, VarDeclaration v, bool mutable) dgReadVar,
ObNode* ob, ref ObState obstate) scope
{
this.dgWriteVar = dgWriteVar;
}
}
- void dgReadVar(const ref Loc loc, ObNode* ob, VarDeclaration v, bool mutable, PtrVarState[] gen)
+ void dgReadVar(Loc loc, ObNode* ob, VarDeclaration v, bool mutable, PtrVarState[] gen)
{
if (log) printf("dgReadVar() %s\n", v.toChars());
const vi = obstate.vars.find(v);
{
alias visit = typeof(super).visit;
extern (D) void delegate(ObNode*, PtrVarState[], VarDeclaration, Expression) dgWriteVar;
- extern (D) void delegate(const ref Loc loc, ObNode* ob, VarDeclaration v, bool mutable, PtrVarState[]) dgReadVar;
+ extern (D) void delegate(Loc loc, ObNode* ob, VarDeclaration v, bool mutable, PtrVarState[]) dgReadVar;
PtrVarState[] cpvs;
ObNode* ob;
ObState* obstate;
- extern (D) this(void delegate(const ref Loc loc, ObNode* ob, VarDeclaration v, bool mutable, PtrVarState[]) dgReadVar,
+ extern (D) this(void delegate(Loc loc, ObNode* ob, VarDeclaration v, bool mutable, PtrVarState[]) dgReadVar,
void delegate(ObNode*, PtrVarState[], VarDeclaration, Expression) dgWriteVar,
PtrVarState[] cpvs, ObNode* ob, ref ObState obstate) scope
{
/***********************************
* Utility to build a function call out of this reference and argument.
*/
-Expression build_overload(const ref Loc loc, Scope* sc, Expression ethis, Expression earg, Dsymbol d)
+Expression build_overload(Loc loc, Scope* sc, Expression ethis, Expression earg, Dsymbol d)
{
assert(d);
Expression e;
}
}
- extern (D) void shift_optimize(BinExp e, UnionExp function(const ref Loc, Type, Expression, Expression) shift)
+ extern (D) void shift_optimize(BinExp e, UnionExp function(Loc, Type, Expression, Expression) shift)
{
if (binOptimize(e, result))
return;
* Input:
* loc = location in source file of mixin
*/
- extern (D) this(const ref Loc loc, AST.Module _module, const(char)[] input, bool doDocComment,
+ extern (D) this(Loc loc, AST.Module _module, const(char)[] input, bool doDocComment,
ErrorSink errorSink, const CompileEnv* compileEnv, const bool doUnittests) scope
{
//printf("Parser::Parser()1 %d\n", doUnittests);
return 0;
}
- AST.Expression templateArgToExp(RootObject o, const ref Loc loc)
+ AST.Expression templateArgToExp(RootObject o, Loc loc)
{
switch (o.dyncast)
{
extern (D) longdouble opAssign(T)(T r)
if (is (T : longdouble))
{
- this.realvalue = r.realvalue;
+ this.realvalue = r.realvalue;
return this;
}
VarDeclaration *varDecl; // variable we are in during semantic2
Dsymbol *parent; // parent to use
LabelStatement *slabel; // enclosing labelled statement
- SwitchStatement *sw; // enclosing switch statement
+ SwitchStatement *switchStatement; // enclosing switch statement
Statement *tryBody; // enclosing _body of TryCatchStatement or TryFinallyStatement
- TryFinallyStatement *tf; // enclosing try finally statement
- ScopeGuardStatement *os; // enclosing scope(xxx) statement
+ TryFinallyStatement *tryFinally; // enclosing try finally statement
+ ScopeGuardStatement *scopeGuard; // enclosing scope(xxx) statement
Statement *sbreak; // enclosing statement that supports "break"
Statement *scontinue; // enclosing statement that supports "continue"
ForeachStatement *fes; // if nested function for ForeachStatement, this is it
// do not set wasRead for it
StructDeclaration *argStruct; // elimiate recursion when looking for rvalue construction
- Dsymbol *search(const Loc &loc, Identifier *ident, Dsymbol *&pscopesym, SearchOptFlags flags = (SearchOptFlags)SearchOpt::all);
+ Dsymbol *search(Loc loc, Identifier *ident, Dsymbol *&pscopesym, SearchOptFlags flags = (SearchOptFlags)SearchOpt::all);
};
sc2.ctorflow.callSuper = CSX.none;
sc2.sbreak = null;
sc2.scontinue = null;
- sc2.sw = null;
+ sc2.switchStatement = null;
sc2.fes = funcdecl.fes;
sc2.linkage = funcdecl.isCsymbol() ? LINK.c : LINK.d;
sc2.stc &= STC.flowThruFunction;
sc2.copyFlagsFrom(sc);
sc2.contract = Contract.none;
}
- sc2.tf = null;
- sc2.os = null;
+ sc2.tryFinally = null;
+ sc2.scopeGuard = null;
sc2.inLoop = false;
sc2.inDefaultArg = false;
sc2.userAttribDecl = null;
return DYNCAST.statement;
}
- final extern (D) this(const ref Loc loc, STMT stmt) @safe
+ final extern (D) this(Loc loc, STMT stmt) @safe
{
this.loc = loc;
this.stmt = stmt;
{
Expression exp;
- final extern (D) this(const ref Loc loc, Expression exp) @safe
+ final extern (D) this(Loc loc, Expression exp) @safe
{
super(loc, STMT.Exp);
this.exp = exp;
}
- final extern (D) this(const ref Loc loc, Expression exp, STMT stmt) @safe
+ final extern (D) this(Loc loc, Expression exp, STMT stmt) @safe
{
super(loc, stmt);
this.exp = exp;
}
- final extern (D) this(const ref Loc loc, Dsymbol declaration) @safe
+ final extern (D) this(Loc loc, Dsymbol declaration) @safe
{
super(loc, STMT.Exp);
this.exp = new DeclarationExp(loc, declaration);
}
- static ExpStatement create(const ref Loc loc, Expression exp) @safe
+ static ExpStatement create(Loc loc, Expression exp) @safe
{
return new ExpStatement(loc, exp);
}
// Wraps an expression that is the destruction of 'var'
VarDeclaration var;
- extern (D) this(const ref Loc loc, Expression exp, VarDeclaration var) @safe
+ extern (D) this(Loc loc, Expression exp, VarDeclaration var) @safe
{
super(loc, exp, STMT.DtorExp);
this.var = var;
{
Expressions* exps;
- extern (D) this(const ref Loc loc, Expression exp)
+ extern (D) this(Loc loc, Expression exp)
{
Expressions* exps = new Expressions();
exps.push(exp);
this(loc, exps);
}
- extern (D) this(const ref Loc loc, Expressions* exps) @safe
+ extern (D) this(Loc loc, Expressions* exps) @safe
{
super(loc, STMT.Mixin);
this.exps = exps;
* loc = Instantiation information
* statements = An array of `Statement`s, that will referenced by this class
*/
- final extern (D) this(const ref Loc loc, Statements* statements) @safe
+ final extern (D) this(Loc loc, Statements* statements) @safe
{
super(loc, STMT.Compound);
this.statements = statements;
}
- final extern (D) this(const ref Loc loc, Statements* statements, STMT stmt) @safe
+ final extern (D) this(Loc loc, Statements* statements, STMT stmt) @safe
{
super(loc, stmt);
this.statements = statements;
* sts = A variadic array of `Statement`s, that will copied in this class
* The entries themselves will not be copied.
*/
- final extern (D) this(const ref Loc loc, Statement[] sts...)
+ final extern (D) this(Loc loc, Statement[] sts...)
{
super(loc, STMT.Compound);
statements = new Statements();
statements.push(s);
}
- static CompoundStatement create(const ref Loc loc, Statement s1, Statement s2)
+ static CompoundStatement create(Loc loc, Statement s1, Statement s2)
{
return new CompoundStatement(loc, s1, s2);
}
*/
extern (C++) final class CompoundDeclarationStatement : CompoundStatement
{
- extern (D) this(const ref Loc loc, Statements* statements) @safe
+ extern (D) this(Loc loc, Statements* statements) @safe
{
super(loc, statements, STMT.CompoundDeclaration);
}
{
Statements* statements;
- extern (D) this(const ref Loc loc, Statements* statements) @safe
+ extern (D) this(Loc loc, Statements* statements) @safe
{
super(loc, STMT.UnrolledLoop);
this.statements = statements;
Statement statement;
Loc endloc; // location of closing curly bracket
- extern (D) this(const ref Loc loc, Statement statement, Loc endloc) @safe
+ extern (D) this(Loc loc, Statement statement, Loc endloc) @safe
{
super(loc, STMT.Scope);
this.statement = statement;
/// The wrapped statement.
Statement statement;
- extern (D) this(const ref Loc loc, ForwardingScopeDsymbol sym, Statement statement) @safe
+ extern (D) this(Loc loc, ForwardingScopeDsymbol sym, Statement statement) @safe
{
super(loc, STMT.Forwarding);
this.sym = sym;
this.statement = statement;
}
- extern (D) this(const ref Loc loc, Statement statement) @safe
+ extern (D) this(Loc loc, Statement statement) @safe
{
auto sym = new ForwardingScopeDsymbol();
sym.symtab = new DsymbolTable();
Statement _body;
Loc endloc; // location of closing curly bracket
- extern (D) this(const ref Loc loc, Expression condition, Statement _body, Loc endloc, Parameter param = null) @safe
+ extern (D) this(Loc loc, Expression condition, Statement _body, Loc endloc, Parameter param = null) @safe
{
super(loc, STMT.While);
this.condition = condition;
Expression condition;
Loc endloc; // location of ';' after while
- extern (D) this(const ref Loc loc, Statement _body, Expression condition, Loc endloc) @safe
+ extern (D) this(Loc loc, Statement _body, Expression condition, Loc endloc) @safe
{
super(loc, STMT.Do);
this._body = _body;
// treat that label as referring to this loop.
Statement relatedLabeled;
- extern (D) this(const ref Loc loc, Statement _init, Expression condition, Expression increment, Statement _body, Loc endloc) @safe
+ extern (D) this(Loc loc, Statement _init, Expression condition, Expression increment, Statement _body, Loc endloc) @safe
{
super(loc, STMT.For);
this._init = _init;
Statements* cases; // put breaks, continues, gotos and returns here
ScopeStatements* gotos; // forward referenced goto's go here
- extern (D) this(const ref Loc loc, TOK op, Parameters* parameters, Expression aggr, Statement _body, Loc endloc) @safe
+ extern (D) this(Loc loc, TOK op, Parameters* parameters, Expression aggr, Statement _body, Loc endloc) @safe
{
super(loc, STMT.Foreach);
this.op = op;
VarDeclaration key;
- extern (D) this(const ref Loc loc, TOK op, Parameter param, Expression lwr, Expression upr, Statement _body, Loc endloc) @safe
+ extern (D) this(Loc loc, TOK op, Parameter param, Expression lwr, Expression upr, Statement _body, Loc endloc) @safe
{
super(loc, STMT.ForeachRange);
this.op = op;
VarDeclaration match; // for MatchExpression results
Loc endloc; // location of closing curly bracket
- extern (D) this(const ref Loc loc, Parameter param, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) @safe
+ extern (D) this(Loc loc, Parameter param, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) @safe
{
super(loc, STMT.If);
this.param = param;
Statement ifbody;
Statement elsebody;
- extern (D) this(const ref Loc loc, Condition condition, Statement ifbody, Statement elsebody) @safe
+ extern (D) this(Loc loc, Condition condition, Statement ifbody, Statement elsebody) @safe
{
super(loc, STMT.Conditional);
this.condition = condition;
{
StaticForeach sfe;
- extern (D) this(const ref Loc loc, StaticForeach sfe) @safe
+ extern (D) this(Loc loc, StaticForeach sfe) @safe
{
super(loc, STMT.StaticForeach);
this.sfe = sfe;
Expressions* args; // array of Expression's
Statement _body;
- extern (D) this(const ref Loc loc, const Identifier ident, Expressions* args, Statement _body) @safe
+ extern (D) this(Loc loc, const Identifier ident, Expressions* args, Statement _body) @safe
{
super(loc, STMT.Pragma);
this.ident = ident;
bool hasVars; /// true if has variable case values
DefaultStatement sdefault; /// default:
Statement tryBody; /// set to TryCatchStatement or TryFinallyStatement if in _body portion
- TryFinallyStatement tf; /// set if in the 'finally' block of a TryFinallyStatement
+ TryFinallyStatement tryFinally; /// set if in the 'finally' block of a TryFinallyStatement
GotoCaseStatements gotoCases; /// array of unresolved GotoCaseStatement's
CaseStatements* cases; /// array of CaseStatement's
VarDeclaration lastVar; /// last observed variable declaration in this statement
- extern (D) this(const ref Loc loc, Parameter param, Expression condition, Statement _body, bool isFinal, Loc endloc)
+ extern (D) this(Loc loc, Parameter param, Expression condition, Statement _body, bool isFinal, Loc endloc)
{
super(loc, STMT.Switch);
this.param = param;
VarDeclaration lastVar;
void* extra; // for use by Statement_toIR()
- extern (D) this(const ref Loc loc, Expression exp, Statement statement) @safe
+ extern (D) this(Loc loc, Expression exp, Statement statement) @safe
{
super(loc, STMT.Case);
this.exp = exp;
Expression last;
Statement statement;
- extern (D) this(const ref Loc loc, Expression first, Expression last, Statement statement) @safe
+ extern (D) this(Loc loc, Expression first, Expression last, Statement statement) @safe
{
super(loc, STMT.CaseRange);
this.first = first;
VarDeclaration lastVar;
- extern (D) this(const ref Loc loc, Statement statement) @safe
+ extern (D) this(Loc loc, Statement statement) @safe
{
super(loc, STMT.Default);
this.statement = statement;
{
SwitchStatement sw;
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, STMT.GotoDefault);
}
CaseStatement cs; // case statement it resolves to
- extern (D) this(const ref Loc loc, Expression exp) @safe
+ extern (D) this(Loc loc, Expression exp) @safe
{
super(loc, STMT.GotoCase);
this.exp = exp;
{
Expression exp;
- extern (D) this(const ref Loc loc) @safe
+ extern (D) this(Loc loc) @safe
{
super(loc, STMT.SwitchError);
}
- final extern (D) this(const ref Loc loc, Expression exp) @safe
+ final extern (D) this(Loc loc, Expression exp) @safe
{
super(loc, STMT.SwitchError);
this.exp = exp;
Expression exp;
size_t caseDim;
- extern (D) this(const ref Loc loc, Expression exp) @safe
+ extern (D) this(Loc loc, Expression exp) @safe
{
super(loc, STMT.Return);
this.exp = exp;
{
Identifier ident;
- extern (D) this(const ref Loc loc, Identifier ident) @safe
+ extern (D) this(Loc loc, Identifier ident) @safe
{
super(loc, STMT.Break);
this.ident = ident;
{
Identifier ident;
- extern (D) this(const ref Loc loc, Identifier ident) @safe
+ extern (D) this(Loc loc, Identifier ident) @safe
{
super(loc, STMT.Continue);
this.ident = ident;
Expression exp;
Statement _body;
- extern (D) this(const ref Loc loc, Expression exp, Statement _body) @safe
+ extern (D) this(Loc loc, Expression exp, Statement _body) @safe
{
super(loc, STMT.Synchronized);
this.exp = exp;
VarDeclaration wthis;
Loc endloc;
- extern (D) this(const ref Loc loc, Expression exp, Statement _body, Loc endloc) @safe
+ extern (D) this(Loc loc, Expression exp, Statement _body, Loc endloc) @safe
{
super(loc, STMT.With);
this.exp = exp;
Statement tryBody; /// set to enclosing TryCatchStatement or TryFinallyStatement if in _body portion
- extern (D) this(const ref Loc loc, Statement _body, Catches* catches) @safe
+ extern (D) this(Loc loc, Statement _body, Catches* catches) @safe
{
super(loc, STMT.TryCatch);
this._body = _body;
// was generated by the compiler, wasn't present in source code
bool internalCatch;
- extern (D) this(const ref Loc loc, Type type, Identifier ident, Statement handler) @safe
+ extern (D) this(Loc loc, Type type, Identifier ident, Statement handler) @safe
{
//printf("Catch(%s, loc = %s)\n", id.toChars(), loc.toChars());
this.loc = loc;
Statement tryBody; /// set to enclosing TryCatchStatement or TryFinallyStatement if in _body portion
bool bodyFallsThru; /// true if _body falls through to finally
- extern (D) this(const ref Loc loc, Statement _body, Statement finalbody) @safe
+ extern (D) this(Loc loc, Statement _body, Statement finalbody) @safe
{
super(loc, STMT.TryFinally);
this._body = _body;
this.bodyFallsThru = true; // assume true until statementSemantic()
}
- static TryFinallyStatement create(const ref Loc loc, Statement _body, Statement finalbody) @safe
+ static TryFinallyStatement create(Loc loc, Statement _body, Statement finalbody) @safe
{
return new TryFinallyStatement(loc, _body, finalbody);
}
TOK tok;
Statement statement;
- extern (D) this(const ref Loc loc, TOK tok, Statement statement) @safe
+ extern (D) this(Loc loc, TOK tok, Statement statement) @safe
{
super(loc, STMT.ScopeGuard);
this.tok = tok;
// was generated by the compiler, wasn't present in source code
bool internalThrow;
- extern (D) this(const ref Loc loc, Expression exp) @safe
+ extern (D) this(Loc loc, Expression exp) @safe
{
super(loc, STMT.Throw);
this.exp = exp;
{
Statement statement;
- extern (D) this(const ref Loc loc, Statement statement) @safe
+ extern (D) this(Loc loc, Statement statement) @safe
{
super(loc, STMT.Debug);
this.statement = statement;
VarDeclaration lastVar;
bool inCtfeBlock; /// set if goto is inside an `if (__ctfe)` block
- extern (D) this(const ref Loc loc, Identifier ident) @safe
+ extern (D) this(Loc loc, Identifier ident) @safe
{
super(loc, STMT.Goto);
this.ident = ident;
bool breaks; // someone did a 'break ident'
bool inCtfeBlock; // inside a block dominated by `if (__ctfe)`
- extern (D) this(const ref Loc loc, Identifier ident, Statement statement) @safe
+ extern (D) this(Loc loc, Identifier ident, Statement statement) @safe
{
super(loc, STMT.Label);
this.ident = ident;
// can be removed if generic error message deduplication is implemented
bool duplicated;
- extern (D) this(Identifier ident, const ref Loc loc = Loc.initial) @safe
+ extern (D) this(Identifier ident, Loc loc = Loc.initial) @safe
{
super(loc, ident);
}
Token* tokens;
bool caseSensitive; // for register names
- extern (D) this(const ref Loc loc, Token* tokens) @safe
+ extern (D) this(Loc loc, Token* tokens) @safe
{
super(loc, STMT.Asm);
this.tokens = tokens;
}
- extern (D) this(const ref Loc loc, Token* tokens, STMT stmt) @safe
+ extern (D) this(Loc loc, Token* tokens, STMT stmt) @safe
{
super(loc, stmt);
this.tokens = tokens;
bool refparam; // true if function parameter is referenced
bool naked; // true if function is to be naked
- extern (D) this(const ref Loc loc, Token* tokens) @safe
+ extern (D) this(Loc loc, Token* tokens) @safe
{
super(loc, tokens, STMT.InlineAsm);
}
Identifiers* labels; // list of goto labels
GotoStatements* gotos; // of the goto labels, the equivalent statements they represent
- extern (D) this(const ref Loc loc, Token* tokens) @safe
+ extern (D) this(Loc loc, Token* tokens) @safe
{
super(loc, tokens, STMT.GccAsm);
}
{
StorageClass stc; // postfix attributes like nothrow/pure/@trusted
- extern (D) this(const ref Loc loc, Statements* statements, StorageClass stc) @safe
+ extern (D) this(Loc loc, Statements* statements, StorageClass stc) @safe
{
super(loc, statements, STMT.CompoundAsm);
this.stc = stc;
{
Dsymbols* imports; // Array of Import's
- extern (D) this(const ref Loc loc, Dsymbols* imports) @safe
+ extern (D) this(Loc loc, Dsymbols* imports) @safe
{
super(loc, STMT.Import);
this.imports = imports;
public:
Expression *exp;
- static ExpStatement *create(const Loc &loc, Expression *exp);
+ static ExpStatement *create(Loc loc, Expression *exp);
ExpStatement *syntaxCopy() override;
void accept(Visitor *v) override { v->visit(this); }
public:
Statements *statements;
- static CompoundStatement *create(const Loc &loc, Statement *s1, Statement *s2);
+ static CompoundStatement *create(Loc loc, Statement *s1, Statement *s2);
CompoundStatement *syntaxCopy() override;
ReturnStatement *endsWithReturnStatement() override final;
Statement *last() override final;
Statement *tryBody; // set to enclosing TryCatchStatement or TryFinallyStatement if in _body portion
d_bool bodyFallsThru; // true if _body falls through to finally
- static TryFinallyStatement *create(const Loc &loc, Statement *body, Statement *finalbody);
+ static TryFinallyStatement *create(Loc loc, Statement *body, Statement *finalbody);
TryFinallyStatement *syntaxCopy() override;
bool hasBreak() const override;
bool hasContinue() const override;
//printf("SwitchStatement::semantic(%p)\n", ss);
ss.tryBody = sc.tryBody;
- ss.tf = sc.tf;
+ ss.tryFinally = sc.tryFinally;
if (ss.cases)
{
result = ss; // already run
sc = sc.push();
sc.sbreak = ss;
- sc.sw = ss;
+ sc.switchStatement = ss;
ss.cases = new CaseStatements();
const inLoopSave = sc.inLoop;
for (Scope* scx = sc; scx; scx = scx.enclosing)
{
- if (!scx.sw)
+ if (!scx.switchStatement)
continue;
- foreach (cs; *scx.sw.cases)
+ foreach (cs; *scx.switchStatement.cases)
{
if (cs.exp.equals(gcs.exp))
{
needswitcherror = true;
}
- ss.hasDefault = sc.sw.sdefault ||
+ ss.hasDefault = sc.switchStatement.sdefault ||
!(!ss.isFinal || needswitcherror || global.params.useAssert == CHECKENABLE.on || sc.func.isSafe || sc.func.isSaferD);
if (!ss.hasDefault)
{
s = new ExpStatement(ss.loc, new HaltExp(ss.loc));
a.reserve(2);
- sc.sw.sdefault = new DefaultStatement(ss.loc, s);
+ sc.switchStatement.sdefault = new DefaultStatement(ss.loc, s);
a.push(ss._body);
if (ss._body.blockExit(sc.func, null) & BE.fallthru)
a.push(new BreakStatement(Loc.initial, null));
- a.push(sc.sw.sdefault);
+ a.push(sc.switchStatement.sdefault);
cs = new CompoundStatement(ss.loc, a);
ss._body = cs;
}
void visitCase(CaseStatement cs)
{
- SwitchStatement sw = sc.sw;
+ SwitchStatement sw = sc.switchStatement;
bool errors = false;
//printf("CaseStatement::semantic() %s\n", toChars());
*/
for (Scope* scx = sc; scx; scx = scx.enclosing)
{
- if (scx.enclosing && scx.enclosing.sw == sw)
+ if (scx.enclosing && scx.enclosing.switchStatement == sw)
continue;
- assert(scx.sw == sw);
+ assert(scx.switchStatement == sw);
Dsymbol pscopesym;
if (!scx.search(cs.exp.loc, v.ident, pscopesym))
i++;
}
- if (sc.sw.tf != sc.tf)
+ if (sc.switchStatement.tryFinally != sc.tryFinally)
{
error(cs.loc, "`switch` and `case` are in different `finally` blocks");
errors = true;
}
- if (sc.sw.tryBody != sc.tryBody)
+ if (sc.switchStatement.tryBody != sc.tryBody)
{
error(cs.loc, "case cannot be in different `try` block level from `switch`");
errors = true;
void visitCaseRange(CaseRangeStatement crs)
{
- SwitchStatement sw = sc.sw;
+ SwitchStatement sw = sc.switchStatement;
if (sw is null)
{
error(crs.loc, "case range not in `switch` statement");
{
//printf("DefaultStatement::semantic()\n");
bool errors = false;
- if (sc.sw)
+ if (sc.switchStatement)
{
- if (sc.sw.sdefault)
+ if (sc.switchStatement.sdefault)
{
error(ds.loc, "`switch` statement already has a default");
errors = true;
}
- sc.sw.sdefault = ds;
+ sc.switchStatement.sdefault = ds;
- if (sc.sw.tf != sc.tf)
+ if (sc.switchStatement.tryFinally != sc.tryFinally)
{
error(ds.loc, "`switch` and `default` are in different `finally` blocks");
errors = true;
}
- if (sc.sw.tryBody != sc.tryBody)
+ if (sc.switchStatement.tryBody != sc.tryBody)
{
error(ds.loc, "default cannot be in different `try` block level from `switch`");
errors = true;
}
- if (sc.sw.isFinal)
+ if (sc.switchStatement.isFinal)
{
error(ds.loc, "`default` statement not allowed in `final switch` statement");
errors = true;
/* https://dlang.org/spec/statement.html#goto-statement
*/
- gds.sw = sc.sw;
+ gds.sw = sc.switchStatement;
if (!gds.sw)
{
error(gds.loc, "`goto default` not in `switch` statement");
/* https://dlang.org/spec/statement.html#goto-statement
*/
- if (!sc.sw)
+ if (!sc.switchStatement)
{
error(gcs.loc, "`goto case` not in `switch` statement");
return setError();
if (gcs.exp)
{
gcs.exp = gcs.exp.expressionSemantic(sc);
- gcs.exp = gcs.exp.implicitCastTo(sc, sc.sw.condition.type);
+ gcs.exp = gcs.exp.implicitCastTo(sc, sc.switchStatement.condition.type);
gcs.exp = gcs.exp.optimize(WANTvalue);
if (gcs.exp.op == EXP.error)
return setError();
}
- sc.sw.gotoCases.push(gcs);
+ sc.switchStatement.gotoCases.push(gcs);
result = gcs;
}
error(rs.loc, "`return` statements cannot be in contracts");
errors = true;
}
- if (sc.os)
+ if (sc.scopeGuard)
{
// @@@DEPRECATED_2.112@@@
// Deprecated in 2.100, transform into an error in 2.112
- if (sc.os.tok == TOK.onScopeFailure)
+ if (sc.scopeGuard.tok == TOK.onScopeFailure)
{
deprecation(rs.loc, "`return` statements cannot be in `scope(failure)` bodies.");
deprecationSupplemental(rs.loc, "Use try-catch blocks for this purpose");
}
else
{
- error(rs.loc, "`return` statements cannot be in `%s` bodies", Token.toChars(sc.os.tok));
+ error(rs.loc, "`return` statements cannot be in `%s` bodies", Token.toChars(sc.scopeGuard.tok));
errors = true;
}
}
- if (sc.tf)
+ if (sc.tryFinally)
{
error(rs.loc, "`return` statements cannot be in `finally` bodies");
errors = true;
Statement s = ls.statement;
if (!s || !s.hasBreak())
error(bs.loc, "label `%s` has no `break`", bs.ident.toChars());
- else if (ls.tf != sc.tf)
+ else if (ls.tf != sc.tryFinally)
error(bs.loc, "cannot break out of `finally` block");
else
{
}
else if (!sc.sbreak)
{
- if (sc.os && sc.os.tok != TOK.onScopeFailure)
+ if (sc.scopeGuard && sc.scopeGuard.tok != TOK.onScopeFailure)
{
- error(bs.loc, "`break` is not allowed inside `%s` bodies", Token.toChars(sc.os.tok));
+ error(bs.loc, "`break` is not allowed inside `%s` bodies", Token.toChars(sc.scopeGuard.tok));
}
else if (sc.fes)
{
Statement s = ls.statement;
if (!s || !s.hasContinue())
error(cs.loc, "label `%s` has no `continue`", cs.ident.toChars());
- else if (ls.tf != sc.tf)
+ else if (ls.tf != sc.tryFinally)
error(cs.loc, "cannot continue out of `finally` block");
else
{
}
else if (!sc.scontinue)
{
- if (sc.os && sc.os.tok != TOK.onScopeFailure)
+ if (sc.scopeGuard && sc.scopeGuard.tok != TOK.onScopeFailure)
{
- error(cs.loc, "`continue` is not allowed inside `%s` bodies", Token.toChars(sc.os.tok));
+ error(cs.loc, "`continue` is not allowed inside `%s` bodies", Token.toChars(sc.scopeGuard.tok));
}
else if (sc.fes)
{
tfs._body = tfs._body.semanticScope(sc, null, null, tfs);
sc = sc.push();
- sc.tf = tfs;
+ sc.tryFinally = tfs;
sc.sbreak = null;
sc.scontinue = null; // no break or continue out of finally block
tfs.finalbody = tfs.finalbody.semanticNoScope(sc);
// scope(success) and scope(failure) are rewritten to try-catch(-finally) statement,
// so the generated catch block cannot be placed in finally block.
// See also Catch::semantic.
- if (sc.os && sc.os.tok != TOK.onScopeFailure)
+ if (sc.scopeGuard && sc.scopeGuard.tok != TOK.onScopeFailure)
{
// If enclosing is scope(success) or scope(exit), this will be placed in finally block.
- error(oss.loc, "cannot put `%s` statement inside `%s`", Token.toChars(oss.tok), Token.toChars(sc.os.tok));
+ error(oss.loc, "cannot put `%s` statement inside `%s`", Token.toChars(oss.tok), Token.toChars(sc.scopeGuard.tok));
return setError();
}
- if (sc.tf)
+ if (sc.tryFinally)
{
error(oss.loc, "cannot put `%s` statement inside `finally` block", Token.toChars(oss.tok));
return setError();
}
sc = sc.push();
- sc.tf = null;
- sc.os = oss;
+ sc.tryFinally = null;
+ sc.scopeGuard = oss;
if (oss.tok != TOK.onScopeFailure)
{
// Jump out from scope(failure) block is allowed.
gs.ident = fixupLabelName(sc, gs.ident);
gs.label = fd.searchLabel(gs.ident, gs.loc);
gs.tryBody = sc.tryBody;
- gs.tf = sc.tf;
- gs.os = sc.os;
+ gs.tf = sc.tryFinally;
+ gs.os = sc.scopeGuard;
gs.lastVar = sc.lastVar;
gs.inCtfeBlock = sc.ctfeBlock;
ls.ident = fixupLabelName(sc, ls.ident);
ls.tryBody = sc.tryBody;
- ls.tf = sc.tf;
- ls.os = sc.os;
+ ls.tf = sc.tryFinally;
+ ls.os = sc.scopeGuard;
ls.lastVar = sc.lastVar;
ls.inCtfeBlock = sc.ctfeBlock;
*
* Returns: true if the `throw` is valid, or false if an error was found
*/
-public bool throwSemantic(const ref Loc loc, ref Expression exp, Scope* sc)
+public bool throwSemantic(Loc loc, ref Expression exp, Scope* sc)
{
if (!global.params.useExceptions)
{
return ec;
}
-private extern(D) Statement loopReturn(Expression e, Statements* cases, const ref Loc loc)
+private extern(D) Statement loopReturn(Expression e, Statements* cases, Loc loc)
{
if (!cases.length)
{
{
//printf("Catch::semantic(%s)\n", ident.toChars());
- if (sc.os && sc.os.tok != TOK.onScopeFailure)
+ if (sc.scopeGuard && sc.scopeGuard.tok != TOK.onScopeFailure)
{
// If enclosing is scope(success) or scope(exit), this will be placed in finally block.
- error(c.loc, "cannot put `catch` statement inside `%s`", Token.toChars(sc.os.tok));
+ error(c.loc, "cannot put `catch` statement inside `%s`", Token.toChars(sc.scopeGuard.tok));
c.errors = true;
}
- if (sc.tf)
+ if (sc.tryFinally)
{
/* This is because the _d_local_unwind() gets the stack munged
* up on this. The workaround is to place any try-catches into
buf.writeByte(0);
const str = buf.extractSlice()[0 .. len];
const bool doUnittests = global.params.parsingUnittestsRequired();
- auto loc = adjustLocForMixin(str, cs.loc, global.params.mixinOut);
- scope p = new Parser!ASTCodegen(loc, sc._module, str, false, global.errorSink, &global.compileEnv, doUnittests);
+ scope p = new Parser!ASTCodegen(sc._module, str, false, global.errorSink, &global.compileEnv, doUnittests);
+ adjustLocForMixin(str, cs.loc, *p.baseLoc, global.params.mixinOut);
+ p.linnum = p.baseLoc.startLine;
p.nextToken();
auto a = new Statements();
Expression exp;
Expressions* msgs;
- extern (D) this(const ref Loc loc, Expression exp, Expression msg)
+ extern (D) this(Loc loc, Expression exp, Expression msg)
{
super(loc, Id.empty);
this.exp = exp;
(*this.msgs)[0] = msg;
}
- extern (D) this(const ref Loc loc, Expression exp, Expressions* msgs)
+ extern (D) this(Loc loc, Expression exp, Expressions* msgs)
{
super(loc, Id.empty);
this.exp = exp;
* Returns:
* `Type` that represents `va_list`.
*/
- extern (C++) Type va_listType(const ref Loc loc, Scope* sc);
+ extern (C++) Type va_listType(Loc loc, Scope* sc);
/**
* Checks whether the target supports a vector type.
* Returns:
* Expression for the requested targetInfo
*/
- extern (C++) Expression getTargetInfo(const(char)* name, const ref Loc loc);
+ extern (C++) Expression getTargetInfo(const(char)* name, Loc loc);
/**
* Params:
// Type sizes and support.
unsigned alignsize(Type *type);
unsigned fieldalign(Type *type);
- Type *va_listType(const Loc &loc, Scope *sc); // get type of va_list
+ Type *va_listType(Loc loc, Scope *sc); // get type of va_list
int isVectorTypeSupported(int sz, Type *type);
bool isVectorOpSupported(Type *type, EXP op, Type *t2 = nullptr);
// ABI and backend.
TypeTuple *toArgTypes(Type *t);
bool isReturnOnStack(TypeFunction *tf, bool needsThis);
bool preferPassByRef(Type *t);
- Expression *getTargetInfo(const char* name, const Loc& loc);
+ Expression *getTargetInfo(const char* name, Loc loc);
bool isCalleeDestroyingArgs(TypeFunction* tf);
bool libraryObjectMonitors(FuncDeclaration *fd, Statement *fbody);
bool supportsLinkerDirective() const;
virtual bool declareParameter(Scope *sc) = 0;
virtual void print(RootObject *oarg, RootObject *oded) = 0;
virtual RootObject *specialization() = 0;
- virtual RootObject *defaultArg(const Loc &instLoc, Scope *sc) = 0;
+ virtual RootObject *defaultArg(Loc instLoc, Scope *sc) = 0;
virtual bool hasDefaultArg() = 0;
DYNCAST dyncast() const override { return DYNCAST_TEMPLATEPARAMETER; }
bool declareParameter(Scope *sc) override final;
void print(RootObject *oarg, RootObject *oded) override final;
RootObject *specialization() override final;
- RootObject *defaultArg(const Loc &instLoc, Scope *sc) override final;
+ RootObject *defaultArg(Loc instLoc, Scope *sc) override final;
bool hasDefaultArg() override final;
void accept(Visitor *v) override { v->visit(this); }
};
bool declareParameter(Scope *sc) override;
void print(RootObject *oarg, RootObject *oded) override;
RootObject *specialization() override;
- RootObject *defaultArg(const Loc &instLoc, Scope *sc) override;
+ RootObject *defaultArg(Loc instLoc, Scope *sc) override;
bool hasDefaultArg() override;
void accept(Visitor *v) override { v->visit(this); }
};
bool declareParameter(Scope *sc) override;
void print(RootObject *oarg, RootObject *oded) override;
RootObject *specialization() override;
- RootObject *defaultArg(const Loc &instLoc, Scope *sc) override;
+ RootObject *defaultArg(Loc instLoc, Scope *sc) override;
bool hasDefaultArg() override;
void accept(Visitor *v) override { v->visit(this); }
};
bool declareParameter(Scope *sc) override;
void print(RootObject *oarg, RootObject *oded) override;
RootObject *specialization() override;
- RootObject *defaultArg(const Loc &instLoc, Scope *sc) override;
+ RootObject *defaultArg(Loc instLoc, Scope *sc) override;
bool hasDefaultArg() override;
void accept(Visitor *v) override { v->visit(this); }
};
* ps = set if s[oindex] is a Dsymbol, otherwise null
* oindex = index into s
*/
-private void resolveTupleIndex(const ref Loc loc, Scope* sc, Dsymbol s, out Expression pe, out Type pt, out Dsymbol ps, RootObject oindex)
+private void resolveTupleIndex(Loc loc, Scope* sc, Dsymbol s, out Expression pe, out Type pt, out Dsymbol ps, RootObject oindex)
{
auto tup = s.isTupleDeclaration();
* ps = set if symbol otherwise null
* typeid = set if in TypeidExpression https://dlang.org/spec/expression.html#TypeidExpression
*/
-private void resolveHelper(TypeQualified mt, const ref Loc loc, Scope* sc, Dsymbol s, Dsymbol scopesym,
+private void resolveHelper(TypeQualified mt, Loc loc, Scope* sc, Dsymbol s, Dsymbol scopesym,
out Expression pe, out Type pt, out Dsymbol ps, bool intypeid = false)
{
version (none)
* Returns:
* symbol found, NULL if not
*/
-private Dsymbol searchX(Dsymbol dsym, const ref Loc loc, Scope* sc, RootObject id, SearchOptFlags flags)
+private Dsymbol searchX(Dsymbol dsym, Loc loc, Scope* sc, RootObject id, SearchOptFlags flags)
{
//printf("Dsymbol::searchX(this=%p,%s, ident='%s')\n", this, toChars(), ident.toChars());
Dsymbol s = dsym.toAlias();
* loc = The source location.
* sc = scope of the type
*/
-extern (D) bool checkComplexTransition(Type type, const ref Loc loc, Scope* sc)
+extern (D) bool checkComplexTransition(Type type, Loc loc, Scope* sc)
{
if (sc.isDeprecated())
return false;
return size(t, Loc.initial);
}
-uinteger_t size(Type t, const ref Loc loc)
+uinteger_t size(Type t, Loc loc)
{
uinteger_t visitType(Type t)
* `Type` with completed semantic analysis, `Terror` if errors
* were encountered
*/
-Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
+Type typeSemantic(Type type, Loc loc, Scope* sc)
{
static Type error()
{
}
}
-Type trySemantic(Type type, const ref Loc loc, Scope* sc)
+Type trySemantic(Type type, Loc loc, Scope* sc)
{
//printf("+trySemantic(%s) %d\n", toChars(), global.errors);
* Returns:
* expression representing the property, or null if not a property and (flag & 1)
*/
-Expression getProperty(Type t, Scope* scope_, const ref Loc loc, Identifier ident, int flag,
+Expression getProperty(Type t, Scope* scope_, Loc loc, Identifier ident, int flag,
Expression src = null)
{
Expression visitType(Type mt)
* ps = is set if t is a symbol
* intypeid = true if in type id
*/
-void resolve(Type mt, const ref Loc loc, Scope* sc, out Expression pe, out Type pt, out Dsymbol ps, bool intypeid = false)
+void resolve(Type mt, Loc loc, Scope* sc, out Expression pe, out Type pt, out Dsymbol ps, bool intypeid = false)
{
void returnExp(Expression e)
{
}
// if initializer is 0
-bool isZeroInit(Type t, const ref Loc loc)
+bool isZeroInit(Type t, Loc loc)
{
bool visitType(Type _)
{
* Returns:
* The initialization expression for the type.
*/
-Expression defaultInit(Type mt, const ref Loc loc, const bool isCfile = false)
+Expression defaultInit(Type mt, Loc loc, const bool isCfile = false)
{
Expression visitBasic(TypeBasic mt)
{
* Complex!float, Complex!double, Complex!real or null for error
*/
-Type getComplexLibraryType(const ref Loc loc, Scope* sc, TY ty)
+Type getComplexLibraryType(Loc loc, Scope* sc, TY ty)
{
// singleton
__gshared Type complex_float;
* Returns:
* number of elements, uint.max on overflow
*/
-uint numberOfElems(Type t, const ref Loc loc)
+uint numberOfElems(Type t, Loc loc)
{
//printf("Type::numberOfElems()\n");
uinteger_t n = 1;
return cast(uint)n;
}
-bool checkRetType(TypeFunction tf, const ref Loc loc)
+bool checkRetType(TypeFunction tf, Loc loc)
{
Type tb = tf.next.toBasetype();
if (tb.ty == Tfunction)
* Returns:
* corresponding value of .max/.min
*/
-Expression getMaxMinValue(EnumDeclaration ed, const ref Loc loc, Identifier id)
+Expression getMaxMinValue(EnumDeclaration ed, Loc loc, Identifier id)
{
//printf("EnumDeclaration::getMaxValue()\n");
- static Expression pvalToResult(Expression e, const ref Loc loc)
+ static Expression pvalToResult(Expression e, Loc loc)
{
if (e.op != EXP.error)
{
* Return:
* null if error, else RootObject AST as parsed
*/
-RootObject compileTypeMixin(TypeMixin tm, ref const Loc loc, Scope* sc)
+RootObject compileTypeMixin(TypeMixin tm, Loc loc, Scope* sc)
{
OutBuffer buf;
if (expressionsToString(buf, sc, tm.exps, tm.loc, null, true))
buf.writeByte(0);
const str = buf.extractSlice()[0 .. len];
const bool doUnittests = global.params.parsingUnittestsRequired();
- auto locm = adjustLocForMixin(str, loc, global.params.mixinOut);
- scope p = new Parser!ASTCodegen(locm, sc._module, str, false, global.errorSink, &global.compileEnv, doUnittests);
+ scope p = new Parser!ASTCodegen(sc._module, str, false, global.errorSink, &global.compileEnv, doUnittests);
+ adjustLocForMixin(str, loc, *p.baseLoc, global.params.mixinOut);
+ p.linnum = p.baseLoc.startLine;
p.nextToken();
//printf("p.loc.linnum = %d\n", p.loc.linnum);
* Returns:
* true if `TypeInfo` was generated and needs compiling to object file
*/
-bool genTypeInfo(Expression e, const ref Loc loc, Type torig, Scope* sc)
+bool genTypeInfo(Expression e, Loc loc, Type torig, Scope* sc)
{
// printf("genTypeInfo() %s\n", torig.toChars());
* Returns:
* The type of the `TypeInfo` object associated with `t`
*/
-extern (C++) Type getTypeInfoType(const ref Loc loc, Type t, Scope* sc);
+extern (C++) Type getTypeInfoType(Loc loc, Type t, Scope* sc);
private TypeInfoDeclaration getTypeInfoDeclaration(Type t)
{
namespace dmd
{
- bool genTypeInfo(Expression *e, const Loc &loc, Type *torig, Scope *sc);
+ bool genTypeInfo(Expression *e, Loc loc, Type *torig, Scope *sc);
bool isSpeculativeType(Type *t);
bool builtinTypeInfo(Type *t);
}
-Type *getTypeInfoType(const Loc &loc, Type *t, Scope *sc);
+Type *getTypeInfoType(Loc loc, Type *t, Scope *sc);
void visit (Module *m) final override
{
Loc loc = (m->md != NULL) ? m->md->loc
- : Loc (m->srcfile.toChars (), 1, 0);
+ : Loc::singleFilename (m->srcfile.toChars ());
this->result_ = build_decl (make_location_t (loc), NAMESPACE_DECL,
get_identifier (m->toPrettyChars ()),
FuncDeclaration *fd = FuncDeclaration::genCfunc (NULL, Type::tvoid,
Identifier::idPool (name));
fd->isGenerated (true);
- fd->loc = Loc (mod->srcfile.toChars (), 1, 0);
+ fd->loc = Loc::singleFilename (mod->srcfile.toChars ());
fd->parent = mod;
fd->visibility = visibility;
fd->semanticRun = PASS::semantic3done;
-d29e3eca45edaeef63b31f78c9846fc6e2870c49
+ffbad272b649b7ae3e88cfdc85688bfef3168994
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
* so the GC can't finalize them.
*/
static if (typeInfoSize)
- attr |= BlkAttr.STRUCTFINAL | BlkAttr.FINALIZE;
+ attr |= BlkAttr.FINALIZE;
static if (!hasIndirections!T)
attr |= BlkAttr.NO_SCAN;
*length = cast(ubyte)newlength;
}
}
- else if (info.size < PAGESIZE)
+ else if (info.size <= PAGESIZE / 2)
{
if (newlength + MEDPAD + typeInfoSize > info.size)
// new size does not fit inside block
*/
void __setBlockFinalizerInfo(ref BlkInfo info, const TypeInfo ti) pure nothrow
{
- if ((info.attr & BlkAttr.APPENDABLE) && info.size >= PAGESIZE)
+ if ((info.attr & BlkAttr.APPENDABLE) && info.size > PAGESIZE / 2)
{
// if the structfinal bit is not set, we don't have a finalizer. But we
// should still zero out the finalizer slot.
/**
Get the finalizer info from the block (typeinfo).
- Must be called on a block with STRUCTFINAL set.
+ If called on a block, without STRUCTFINAL set, returns null.
*/
const(TypeInfo) __getBlockFinalizerInfo(ref BlkInfo info) pure nothrow
{
- bool isLargeArray = (info.attr & BlkAttr.APPENDABLE) && info.size >= PAGESIZE;
+ return __getBlockFinalizerInfo(info.base, info.size, info.attr);
+}
+
+/// ditto
+const(TypeInfo) __getBlockFinalizerInfo(void* base, size_t size, uint attr) pure nothrow
+{
+ if (!(attr & BlkAttr.STRUCTFINAL))
+ return null;
+
+ bool isLargeArray = (attr & BlkAttr.APPENDABLE) && size > PAGESIZE / 2;
auto typeInfo = isLargeArray ?
- info.base + size_t.sizeof :
- info.base + info.size - size_t.sizeof;
+ base + size_t.sizeof :
+ base + size - size_t.sizeof;
+ assert(*cast(size_t*)typeInfo != 0);
return *cast(TypeInfo*)typeInfo;
}
if (info.size <= 256)
return *cast(ubyte *)(info.base + info.size - typeInfoSize - SMALLPAD);
- if (info.size < PAGESIZE)
+ if (info.size <= PAGESIZE / 2)
return *cast(ushort *)(info.base + info.size - typeInfoSize - MEDPAD);
return *cast(size_t *)(info.base);
if (info.size <= 256)
return atomicLoad(*cast(shared(ubyte)*)(info.base + info.size - typeInfoSize - SMALLPAD));
- if (info.size < PAGESIZE)
+ if (info.size <= PAGESIZE / 2)
return atomicLoad(*cast(shared(ushort)*)(info.base + info.size - typeInfoSize - MEDPAD));
return atomicLoad(*cast(shared(size_t)*)(info.base));
in(info.attr & BlkAttr.APPENDABLE)
{
// Capacity is a calculation based solely on the block info.
- if (info.size >= PAGESIZE)
+ if (info.size > PAGESIZE / 2)
return info.size - LARGEPAD;
auto typeInfoSize = (info.attr & BlkAttr.STRUCTFINAL) ? size_t.sizeof : 0;
*
* Params:
* info = array metadata
+ * base = pointer to base of memory block
+ * size = size of memory block.
* Returns:
* pointer to the start of the array
*/
void *__arrayStart()(return scope BlkInfo info) nothrow pure
{
- return info.base + ((info.size & BIGLENGTHMASK) ? LARGEPREFIX : 0);
+ return __arrayStart(info.base, info.size);
+}
+/// Ditto
+void *__arrayStart()(return scope void* base, size_t size) nothrow pure
+{
+ return base + ((size & BIGLENGTHMASK) ? LARGEPREFIX : 0);
+}
+
+/**
+ * Trim a block's extents to the known valid data that is not metadata. This
+ * takes into account the finalizer and array metadata.
+ */
+void __trimExtents(ref scope void* base, ref size_t blockSize, uint attr) nothrow pure @nogc
+{
+ if (attr & BlkAttr.APPENDABLE)
+ {
+ if (blockSize > PAGESIZE / 2)
+ {
+ // large block, it's always LARGEPREFIX bytes at the front.
+ blockSize = *(cast(size_t*)base);
+ base += LARGEPREFIX;
+ return;
+ }
+
+ void *pend = base + blockSize;
+ if (attr & BlkAttr.STRUCTFINAL)
+ // skip the finalizer
+ pend -= (void*).sizeof;
+
+ // get the actual length
+ if (blockSize <= 256)
+ blockSize = *(cast(ubyte*)pend - 1);
+ else // medium array block
+ blockSize = *(cast(ushort*)pend - 1);
+ }
+ else if (attr & BlkAttr.STRUCTFINAL)
+ {
+ // not appendable, but has a finalizer in the block. This is always
+ // stored at the end.
+ blockSize -= (void*).sizeof;
+ }
}
{
// to allow compilation of this module without access to the rt package,
// make these functions available from rt.lifetime
- void rt_finalizeFromGC(void* p, size_t size, uint attr) nothrow;
- int rt_hasFinalizerInSegment(void* p, size_t size, uint attr, const scope void[] segment) nothrow;
+ void rt_finalizeFromGC(void* p, size_t size, uint attr, const(TypeInfo) typeInfo) nothrow;
+ int rt_hasFinalizerInSegment(void* p, size_t size, const(TypeInfo) typeInfo, const scope void[] segment) nothrow;
// Declared as an extern instead of importing core.exception
// to avoid inlining - see https://issues.dlang.org/show_bug.cgi?id=13725.
if (pool.finals.nbits && pool.finals.clear(biti))
{
+ import core.internal.gc.blockmeta;
size_t size = npages * PAGESIZE - SENTINEL_EXTRA;
+ size = sentinel_size(q, size);
uint attr = pool.getBits(biti);
- rt_finalizeFromGC(q, sentinel_size(q, size), attr);
+ auto ti = __getBlockFinalizerInfo(q, size, attr);
+ __trimExtents(q, size, attr);
+ rt_finalizeFromGC(q, size, attr, ti);
}
pool.clrBits(biti, ~BlkAttr.NONE ^ BlkAttr.FINALIZE);
{
immutable biti = base + i;
- if (!pool.mark.test(biti))
- {
- void* q = sentinel_add(p);
- sentinel_Invariant(q);
+ if (pool.mark.test(biti))
+ continue;
- if (pool.finals.nbits && pool.finals.test(biti))
- rt_finalizeFromGC(q, sentinel_size(q, size), pool.getBits(biti));
+ void* q = sentinel_add(p);
+ sentinel_Invariant(q);
- assert(core.bitop.bt(toFree.ptr, i));
+ if (pool.finals.nbits && pool.finals.test(biti))
+ {
+ import core.internal.gc.blockmeta;
+ size_t ssize = sentinel_size(q, size);
+ uint attr = pool.getBits(biti);
+ auto ti = __getBlockFinalizerInfo(q, ssize, attr);
+ __trimExtents(q, ssize, attr);
+ rt_finalizeFromGC(q, ssize, attr, ti);
+ }
- debug(COLLECT_PRINTF) printf("\tcollecting %p\n", p);
- leakDetector.log_free(q, sentinel_size(q, size));
+ assert(core.bitop.bt(toFree.ptr, i));
- invalidate(p[0 .. size], 0xF3, false);
- }
+ debug(COLLECT_PRINTF) printf("\tcollecting %p\n", p);
+ leakDetector.log_free(q, sentinel_size(q, size));
+
+ invalidate(p[0 .. size], 0xF3, false);
}
}
size_t size = sentinel_size(p, getSize(pn));
uint attr = getBits(biti);
- if (!rt_hasFinalizerInSegment(p, size, attr, segment))
+ import core.internal.gc.blockmeta;
+ auto ti = __getBlockFinalizerInfo(p, size, attr);
+ if (!rt_hasFinalizerInSegment(p, size, ti, segment))
continue;
- rt_finalizeFromGC(p, size, attr);
+ __trimExtents(p, size, attr);
+ rt_finalizeFromGC(p, size, attr, ti);
clrBits(biti, ~BlkAttr.NONE);
auto q = sentinel_add(p);
uint attr = getBits(biti);
- const ssize = sentinel_size(q, size);
- if (!rt_hasFinalizerInSegment(q, ssize, attr, segment))
+ auto ssize = sentinel_size(q, size);
+ import core.internal.gc.blockmeta;
+ auto ti = __getBlockFinalizerInfo(q, ssize, attr);
+ if (!rt_hasFinalizerInSegment(q, ssize, ti, segment))
continue;
- rt_finalizeFromGC(q, ssize, attr);
+ __trimExtents(q, ssize, attr);
+ rt_finalizeFromGC(q, ssize, attr, ti);
freeBits = true;
toFree.set(i);
else static if (__traits(isAssociativeArray, T) || is(T == class) || is(T == interface))
enum hasIndirections = true;
else static if (is(T == E[N], E, size_t N))
- enum hasIndirections = T.sizeof && (is(E == void) || hasIndirections!(BaseElemOf!E));
+ enum hasIndirections = T.sizeof && (is(immutable E == immutable void) || hasIndirections!(BaseElemOf!E));
else static if (isFunctionPointer!T)
enum hasIndirections = false;
else
A!int dummy;
}
+// https://github.com/dlang/dmd/issues/20812
+@safe unittest
+{
+ static assert(!hasIndirections!void);
+ static assert(!hasIndirections!(const void));
+ static assert(!hasIndirections!(inout void));
+ static assert(!hasIndirections!(immutable void));
+ static assert(!hasIndirections!(shared void));
+
+ static assert( hasIndirections!(void*));
+ static assert( hasIndirections!(const void*));
+ static assert( hasIndirections!(inout void*));
+ static assert( hasIndirections!(immutable void*));
+ static assert( hasIndirections!(shared void*));
+
+ static assert( hasIndirections!(void[]));
+ static assert( hasIndirections!(const void[]));
+ static assert( hasIndirections!(inout void[]));
+ static assert( hasIndirections!(immutable void[]));
+ static assert( hasIndirections!(shared void[]));
+
+ static assert( hasIndirections!(void[42]));
+ static assert( hasIndirections!(const void[42]));
+ static assert( hasIndirections!(inout void[42]));
+ static assert( hasIndirections!(immutable void[42]));
+ static assert( hasIndirections!(shared void[42]));
+
+ static assert(!hasIndirections!(void[0]));
+ static assert(!hasIndirections!(const void[0]));
+ static assert(!hasIndirections!(inout void[0]));
+ static assert(!hasIndirections!(immutable void[0]));
+ static assert(!hasIndirections!(shared void[0]));
+}
+
template hasUnsharedIndirections(T)
{
static if (is(T == immutable))
import core.memory : GC;
auto flags = !hasIndirections!T ? GC.BlkAttr.NO_SCAN : GC.BlkAttr.NONE;
- immutable tiSize = TypeInfoSize!T;
immutable itemSize = T.sizeof;
- immutable totalSize = itemSize + tiSize;
- if (tiSize)
- flags |= GC.BlkAttr.STRUCTFINAL | GC.BlkAttr.FINALIZE;
+ if (TypeInfoSize!T)
+ flags |= GC.BlkAttr.FINALIZE;
- auto blkInfo = GC.qalloc(totalSize, flags, null);
- auto p = blkInfo.base;
-
- if (tiSize)
- {
- // The GC might not have cleared the padding area in the block.
- *cast(TypeInfo*) (p + (itemSize & ~(size_t.sizeof - 1))) = null;
- *cast(TypeInfo*) (p + blkInfo.size - tiSize) = cast() typeid(T);
- }
+ auto p = GC.malloc(itemSize, flags, typeid(T));
emplaceInitializer(*(cast(T*) p));
{
version (D_TypeInfo)
{
+ static if (is(T == struct))
+ {
+ // prime the TypeInfo name, we don't want that affecting the allocated bytes
+ // Issue https://github.com/dlang/dmd/issues/20832
+ static string typeName(TypeInfo_Struct ti) nothrow @trusted => ti.name;
+ auto tnPure = cast(string function(TypeInfo_Struct ti) nothrow pure @trusted)&typeName;
+ cast(void)tnPure(typeid(T));
+ }
+
import core.internal.array.utils : TraceHook, gcStatsPure, accumulatePure;
mixin(TraceHook!(T.stringof, "_d_newitemT"));
obj.initDataStorage();
- Thread.setThis(obj);
- Thread.add(obj);
+ Thread.registerThis(obj);
+
scope (exit)
{
Thread.remove(obj);
obj.initDataStorage();
atomicStore!(MemoryOrder.raw)(obj.m_isRunning, true);
- Thread.setThis(obj); // allocates lazy TLS (see Issue 11981)
- Thread.add(obj); // can only receive signals from here on
+
+ Thread.registerThis(obj); // can only receive signals from here on
+
scope (exit)
{
Thread.remove(obj);
// to ensure that.
slock.unlock_nothrow();
}
+
+ //
+ // Add a thread to the global thread list, and also register This thread
+ // for use in `getThis`. This does both operations while protected by the
+ // static lock. This helps alternative GCs that use `thread_preSuspend` to
+ // determine whether druntime will provide scanning details during
+ // `thread_scanAll`. Without holding the lock for both operations, it's
+ // possible a `thread_preSuspend` would return true, but the scanning
+ // details would not be handled.
+ //
+ static void registerThis(ThreadBase t, bool rmAboutToStart = true) nothrow @nogc
+ {
+ slock.lock_nothrow();
+ scope(exit) slock.unlock_nothrow();
+
+ setThis(t);
+ add(t, rmAboutToStart);
+ }
+
}
immutable size_t[pointerBitmap.length] RTInfoImpl = pointerBitmap[];
}
-template NoPointersBitmapPayload(size_t N)
-{
- enum size_t[N] NoPointersBitmapPayload = 0;
-}
-
template RTInfo(T)
{
enum pointerBitmap = __traits(getPointerBitmap, T);
- static if (pointerBitmap[1 .. $] == NoPointersBitmapPayload!(pointerBitmap.length - 1))
+ static if (pointerBitmap[1 .. $] == size_t[pointerBitmap.length - 1].init)
enum RTInfo = rtinfoNoPointers;
else
enum RTInfo = RTInfoImpl!(pointerBitmap).ptr;
debug (PRINTF) import core.stdc.stdio : printf;
debug (VALGRIND) import etc.valgrind.valgrind;
-alias BlkInfo = GC.BlkInfo;
alias BlkAttr = GC.BlkAttr;
// for now, all GC array functions are not exposed via core.memory.
if (typeid(ti) is typeid(TypeInfo_Struct)) {
auto sti = cast(TypeInfo_Struct)cast(void*)ti;
if (sti.xdtor)
- attrs |= BlkAttr.STRUCTFINAL | BlkAttr.FINALIZE;
+ attrs |= BlkAttr.FINALIZE;
}
return attrs;
}
/**
*
*/
-extern (C) int rt_hasFinalizerInSegment(void* p, size_t size, uint attr, scope const(void)[] segment) nothrow
+extern (C) int rt_hasFinalizerInSegment(void* p, size_t size, TypeInfo typeInfo, scope const(void)[] segment) nothrow
{
if (!p)
return false;
- if (attr & BlkAttr.STRUCTFINAL)
+ if (typeInfo !is null)
{
- import core.internal.gc.blockmeta;
- auto info = BlkInfo(
- base: p,
- size: size,
- attr: attr
- );
+ assert(typeid(typeInfo) is typeid(TypeInfo_Struct));
- auto ti = cast(TypeInfo_Struct)cast(void*)__getBlockFinalizerInfo(info);
+ auto ti = cast(TypeInfo_Struct)cast(void*)typeInfo;
return cast(size_t)(cast(void*)ti.xdtor - segment.ptr) < segment.length;
}
rt_finalize2(p, det, true);
}
-extern (C) void rt_finalizeFromGC(void* p, size_t size, uint attr) nothrow
+extern (C) void rt_finalizeFromGC(void* p, size_t size, uint attr, TypeInfo typeInfo) nothrow
{
// to verify: reset memory necessary?
- if (!(attr & BlkAttr.STRUCTFINAL)) {
+ if (typeInfo is null) {
rt_finalize2(p, false, false); // class
return;
}
- // get the struct typeinfo from the block, and the used size.
- import core.internal.gc.blockmeta;
- auto info = BlkInfo(
- base: p,
- size: size,
- attr: attr
- );
+ assert(typeid(typeInfo) is typeid(TypeInfo_Struct));
- auto si = cast(TypeInfo_Struct)cast(void*)__getBlockFinalizerInfo(info);
+ auto si = cast(TypeInfo_Struct)cast(void*)typeInfo;
- if (attr & BlkAttr.APPENDABLE)
+ try
{
- auto usedsize = __arrayAllocLength(info);
- auto arrptr = __arrayStart(info);
- try
+ if (attr & BlkAttr.APPENDABLE)
{
- finalize_array(arrptr, usedsize, si);
- }
- catch (Exception e)
- {
- onFinalizeError(si, e);
+ finalize_array(p, size, si);
}
+ else
+ finalize_struct(p, si); // struct
+ }
+ catch (Exception e)
+ {
+ onFinalizeError(si, e);
}
- else
- finalize_struct(p, si); // struct
}
dtorCount = 0;
const(S1)[] carr1 = new const(S1)[5];
- BlkInfo blkinf1 = GC.query(carr1.ptr);
+ auto blkinf1 = GC.query(carr1.ptr);
GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
assert(dtorCount == 5);
GC.free(blkinf1.base);
assert(dtorCount == 4); // destructors run explicitely?
dtorCount = 0;
- BlkInfo blkinf = GC.query(arr2.ptr);
+ auto blkinf = GC.query(arr2.ptr);
GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
assert(dtorCount == 6);
GC.free(blkinf.base);