mirror of
https://github.com/openRuyi-Project/gcc.git
synced 2026-09-06 22:11:37 +00:00
D front-end changes: - Import latest changes from dmd v2.107.0-beta.1. - Keywords like `__FILE__' are now always evaluated at the callsite. D runtime changes: - Import latest changes from druntime v2.107.0-beta.1. - Added `nameSig' field to TypeInfo_Class in object.d. Phobos changes: - Import latest changes from phobos v2.107.0-beta.1. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd bce5c1f7b5. * d-attribs.cc (build_attributes): Update for new front-end interface. * d-lang.cc (d_parse_file): Likewise. * decl.cc (DeclVisitor::visit (VarDeclaration *)): Likewise. * expr.cc (build_lambda_tree): New function. (ExprVisitor::visit (FuncExp *)): Use build_lambda_tree. (ExprVisitor::visit (SymOffExp *)): Likewise. (ExprVisitor::visit (VarExp *)): Likewise. * typeinfo.cc (create_tinfo_types): Add two ulong fields to internal TypeInfo representation. (TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Emit stub data for TypeInfo_Class.nameSig. (TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Update for new front-end interface. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime bce5c1f7b5. * src/MERGE: Merge upstream phobos e4d0dd513.
64 lines
1.3 KiB
D
64 lines
1.3 KiB
D
/**
|
|
* Common code for writing containers.
|
|
*
|
|
* Copyright: Copyright Martin Nowak 2013.
|
|
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
|
* Authors: Martin Nowak
|
|
*/
|
|
module core.internal.container.common;
|
|
|
|
import core.stdc.stdlib : malloc, realloc;
|
|
public import core.stdc.stdlib : free;
|
|
import core.internal.traits : dtorIsNothrow;
|
|
nothrow:
|
|
|
|
void* xrealloc(void* ptr, size_t sz) nothrow @nogc
|
|
{
|
|
import core.exception;
|
|
|
|
if (!sz) { .free(ptr); return null; }
|
|
if (auto nptr = .realloc(ptr, sz)) return nptr;
|
|
.free(ptr); onOutOfMemoryError();
|
|
assert(0);
|
|
}
|
|
|
|
void* xmalloc(size_t sz) nothrow @nogc
|
|
{
|
|
import core.exception;
|
|
if (auto nptr = .malloc(sz))
|
|
return nptr;
|
|
onOutOfMemoryError();
|
|
assert(0);
|
|
}
|
|
|
|
void destroy(T)(ref T t) if (is(T == struct) && dtorIsNothrow!T)
|
|
{
|
|
scope (failure) assert(0); // nothrow hack
|
|
object.destroy(t);
|
|
}
|
|
|
|
void destroy(T)(ref T t) if (!is(T == struct))
|
|
{
|
|
t = T.init;
|
|
}
|
|
|
|
void initialize(T)(ref T t) if (is(T == struct))
|
|
{
|
|
import core.internal.lifetime : emplaceInitializer;
|
|
emplaceInitializer(t);
|
|
}
|
|
|
|
void initialize(T)(ref T t) if (!is(T == struct))
|
|
{
|
|
t = T.init;
|
|
}
|
|
|
|
version (CoreUnittest) struct RC()
|
|
{
|
|
nothrow:
|
|
this(size_t* cnt) { ++*(_cnt = cnt); }
|
|
~this() { if (_cnt) --*_cnt; }
|
|
this(this) { if (_cnt) ++*_cnt; }
|
|
size_t* _cnt;
|
|
}
|