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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/dmd/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,11 @@ extern (C++) final class IntegerExp : Expression
return new IntegerExp(loc, value, type);
}

static IntegerExp createi(Loc loc, int value, Type type)
{
return new IntegerExp(loc, value, type);
}

override bool equals(RootObject o)
{
if (this == o)
Expand Down
1 change: 1 addition & 0 deletions src/dmd/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class IntegerExp : public Expression
dinteger_t value;

static IntegerExp *create(Loc loc, dinteger_t value, Type *type);
static IntegerExp *createi(Loc loc, int value, Type *type);
bool equals(RootObject *o);
dinteger_t toInteger();
real_t toReal();
Expand Down
2 changes: 1 addition & 1 deletion src/dmd/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ extern (C++) class FuncDeclaration : Declaration
*/
static FuncDeclaration genCfunc(Parameters* fparams, Type treturn, const(char)* name, StorageClass stc = 0)
{
return genCfunc(fparams, treturn, Identifier.idPool(name, strlen(name)), stc);
return genCfunc(fparams, treturn, Identifier.idPool(name, cast(uint)strlen(name)), stc);
}

static FuncDeclaration genCfunc(Parameters* fparams, Type treturn, Identifier id, StorageClass stc = 0)
Expand Down
4 changes: 2 additions & 2 deletions src/dmd/identifier.d
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ nothrow:
*/
extern (D) static Identifier idPool(const(char)[] s)
{
return idPool(s.ptr, s.length);
return idPool(s.ptr, cast(uint)s.length);
}

static Identifier idPool(const(char)* s, size_t len)
static Identifier idPool(const(char)* s, uint len)
{
StringValue* sv = stringtable.update(s, len);
Identifier id = cast(Identifier)sv.ptrvalue;
Expand Down
3 changes: 2 additions & 1 deletion src/dmd/identifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif /* __DMC__ */

#include "root.h"
#include "rmem.h"
#include "stringtable.h"

class Identifier : public RootObject
Expand All @@ -38,7 +39,7 @@ class Identifier : public RootObject
static StringTable stringtable;
static Identifier *generateId(const char *prefix);
static Identifier *generateId(const char *prefix, size_t i);
static Identifier *idPool(const char *s, size_t len);
static Identifier *idPool(const char *s, unsigned len);

static inline Identifier *idPool(const char *s)
{
Expand Down
2 changes: 1 addition & 1 deletion src/dmd/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class Lexer : ErrorHandler
}
break;
}
Identifier id = Identifier.idPool(cast(char*)t.ptr, p - t.ptr);
Identifier id = Identifier.idPool(cast(char*)t.ptr, cast(uint)(p - t.ptr));
t.ident = id;
t.value = cast(TOK)id.getValue();
anyToken = 1;
Expand Down
6 changes: 3 additions & 3 deletions src/dmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ private int tryMain(size_t argc, const(char)** argv)
/* At this point, name is the D source file name stripped of
* its path and extension.
*/
auto id = Identifier.idPool(name, strlen(name));
auto id = Identifier.idPool(name, cast(uint)strlen(name));
auto m = new Module(files[i], id, global.params.doDocComments, global.params.doHdrGeneration);
modules.push(m);
if (firstmodule)
Expand Down Expand Up @@ -2479,7 +2479,7 @@ private void parseModulePattern(const(char)* modulePattern, MatcherNode* dst, us
if (*modulePattern == '.')
{
assert(modulePattern > idStart, "empty module pattern");
*dst = MatcherNode(Identifier.idPool(idStart, modulePattern - idStart));
*dst = MatcherNode(Identifier.idPool(idStart, cast(uint)(modulePattern - idStart)));
modulePattern++;
idStart = modulePattern;
break;
Expand All @@ -2491,7 +2491,7 @@ private void parseModulePattern(const(char)* modulePattern, MatcherNode* dst, us
if (*modulePattern == '\0')
{
assert(modulePattern > idStart, "empty module pattern");
*lastNode = MatcherNode(Identifier.idPool(idStart, modulePattern - idStart));
*lastNode = MatcherNode(Identifier.idPool(idStart, cast(uint)(modulePattern - idStart)));
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dmd/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -5629,7 +5629,7 @@ extern (C++) abstract class TypeQualified : Type
/* Look for what user might have intended
*/
const p = mutableOf().unSharedOf().toChars();
auto id = Identifier.idPool(p, strlen(p));
auto id = Identifier.idPool(p, cast(uint)strlen(p));
if (const n = importHint(p))
error(loc, "`%s` is not defined, perhaps `import %s;` ?", p, n);
else if (auto s2 = sc.search_correct(id))
Expand Down
2 changes: 1 addition & 1 deletion src/tests/cxxfrontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void test_visitors()
Loc loc;
Identifier *ident = Identifier::idPool("test");

IntegerExp *ie = IntegerExp::create(loc, 42, Type::tint32);
IntegerExp *ie = IntegerExp::createi(loc, 42, Type::tint32);
ie->accept(&tv);
assert(tv.expr == true);

Expand Down