Skip to content

Commit

Permalink
[Refactoring] Fix incorrect wording 'arg' 'argument' for Parameter ob…
Browse files Browse the repository at this point in the history
…jects

An exception is the around of TypeTuple. It stores types and expressions
merely using Parameter. So the wording 'arg' is not incorrect at least.
  • Loading branch information
9rnsr committed Nov 29, 2014
1 parent 4c98263 commit e3f0b58
Show file tree
Hide file tree
Showing 18 changed files with 457 additions and 468 deletions.
4 changes: 2 additions & 2 deletions src/clone.c
Expand Up @@ -115,8 +115,8 @@ FuncDeclaration *hasIdentityOpAssign(AggregateDeclaration *ad, Scope *sc)
Parameters *fparams = f->getParameters(&varargs);
if (fparams->dim >= 1)
{
Parameter *arg0 = Parameter::getNth(fparams, 0);
if (arg0->type->toDsymbol(NULL) != ad)
Parameter *fparam0 = Parameter::getNth(fparams, 0);
if (fparam0->type->toDsymbol(NULL) != ad)
f = NULL;
}
}
Expand Down
24 changes: 13 additions & 11 deletions src/cppmangle.c
Expand Up @@ -492,21 +492,23 @@ class CppMangleVisitor : public Visitor
}
}

static int argsCppMangleDg(void *ctx, size_t n, Parameter *arg)
static int paramsCppMangleDg(void *ctx, size_t n, Parameter *fparam)
{
CppMangleVisitor *mangler = (CppMangleVisitor *)ctx;

Type *t = arg->type->merge2();
if (arg->storageClass & (STCout | STCref))
Type *t = fparam->type->merge2();
if (fparam->storageClass & (STCout | STCref))
t = t->referenceTo();
else if (arg->storageClass & STClazy)
{ // Mangle as delegate
else if (fparam->storageClass & STClazy)
{
// Mangle as delegate
Type *td = new TypeFunction(NULL, t, 0, LINKd);
td = new TypeDelegate(td);
t = t->merge();
}
if (t->ty == Tsarray)
{ // Mangle static arrays as pointers
{
// Mangle static arrays as pointers
t->error(Loc(), "ICE: Unable to pass static array to extern(C++) function.");
t->error(Loc(), "Use pointer instead.");
assert(0);
Expand All @@ -525,15 +527,15 @@ class CppMangleVisitor : public Visitor
return 0;
}

void argsCppMangle(Parameters *arguments, int varargs)
void argsCppMangle(Parameters *parameters, int varargs)
{
if (arguments)
Parameter::foreach(arguments, &argsCppMangleDg, (void*)this);
if (parameters)
Parameter::foreach(parameters, &paramsCppMangleDg, (void*)this);

if (varargs)
buf.writestring("z");
else if (!arguments || !arguments->dim)
buf.writeByte('v'); // encode ( ) arguments
else if (!parameters || !parameters->dim)
buf.writeByte('v'); // encode ( ) parameters
}

public:
Expand Down
4 changes: 2 additions & 2 deletions src/declaration.h
Expand Up @@ -856,7 +856,7 @@ class UnitTestDeclaration : public FuncDeclaration
class NewDeclaration : public FuncDeclaration
{
public:
Parameters *arguments;
Parameters *parameters;
int varargs;

NewDeclaration(Loc loc, Loc endloc, StorageClass stc, Parameters *arguments, int varargs);
Expand All @@ -875,7 +875,7 @@ class NewDeclaration : public FuncDeclaration
class DeleteDeclaration : public FuncDeclaration
{
public:
Parameters *arguments;
Parameters *parameters;

DeleteDeclaration(Loc loc, Loc endloc, StorageClass stc, Parameters *arguments);
Dsymbol *syntaxCopy(Dsymbol *);
Expand Down
22 changes: 11 additions & 11 deletions src/doc.c
Expand Up @@ -1603,7 +1603,7 @@ void ParamSection::write(DocComment *dc, Scope *sc, Dsymbol *s, OutBuffer *buf)
size_t textlen = 0;

size_t o, paramcount = 0;
Parameter *arg = NULL;
Parameter *fparam = NULL;

buf->writestring("$(DDOC_PARAMS ");
while (p < pend)
Expand Down Expand Up @@ -1661,15 +1661,15 @@ void ParamSection::write(DocComment *dc, Scope *sc, Dsymbol *s, OutBuffer *buf)
buf->writestring("$(DDOC_PARAM_ROW ");
buf->writestring("$(DDOC_PARAM_ID ");
o = buf->offset;
arg = isFunctionParameter(s, namestart, namelen);
fparam = isFunctionParameter(s, namestart, namelen);
bool isCVariadic = isCVariadicParameter(s, namestart, namelen);
if (isCVariadic)
{
buf->writestring("...");
}
else if (arg && arg->type && arg->ident)
else if (fparam && fparam->type && fparam->ident)
{
::toCBuffer(arg->type, buf, arg->ident, &hgs);
::toCBuffer(fparam->type, buf, fparam->ident, &hgs);
}
else
{
Expand All @@ -1678,7 +1678,7 @@ void ParamSection::write(DocComment *dc, Scope *sc, Dsymbol *s, OutBuffer *buf)
// 10236: Don't count template parameters for params check
--paramcount;
}
else if (!arg)
else if (!fparam)
{
warning(s->loc, "Ddoc: function declaration has no parameter '%.*s'", namelen, namestart);
}
Expand Down Expand Up @@ -2142,10 +2142,10 @@ Parameter *isFunctionParameter(Dsymbol *s, const utf8_t *p, size_t len)
{
for (size_t k = 0; k < tf->parameters->dim; k++)
{
Parameter *arg = (*tf->parameters)[k];
if (arg->ident && cmp(arg->ident->toChars(), p, len) == 0)
Parameter *fparam = (*tf->parameters)[k];
if (fparam->ident && cmp(fparam->ident->toChars(), p, len) == 0)
{
return arg;
return fparam;
}
}
}
Expand All @@ -2162,10 +2162,10 @@ TemplateParameter *isTemplateParameter(Dsymbol *s, const utf8_t *p, size_t len)
{
for (size_t k = 0; k < td->origParameters->dim; k++)
{
TemplateParameter *arg = (*td->origParameters)[k];
if (arg->ident && cmp(arg->ident->toChars(), p, len) == 0)
TemplateParameter *tp = (*td->origParameters)[k];
if (tp->ident && cmp(tp->ident->toChars(), p, len) == 0)
{
return arg;
return tp;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/dsymbol.c
Expand Up @@ -1251,12 +1251,12 @@ FuncDeclaration *ScopeDsymbol::findGetMembers()
if (!tfgetmembers)
{
Scope sc;
Parameters *arguments = new Parameters;
Parameters *arg = new Parameter(STCin, Type::tchar->constOf()->arrayOf(), NULL, NULL);
arguments->push(arg);
Parameters *parameters = new Parameters;
Parameters *p = new Parameter(STCin, Type::tchar->constOf()->arrayOf(), NULL, NULL);
parameters->push(p);

Type *tret = NULL;
tfgetmembers = new TypeFunction(arguments, tret, 0, LINKd);
tfgetmembers = new TypeFunction(parameters, tret, 0, LINKd);
tfgetmembers = (TypeFunction *)tfgetmembers->semantic(Loc(), &sc);
}
if (fdx)
Expand Down

0 comments on commit e3f0b58

Please sign in to comment.