Mercurial > projects > ddmd
diff dmd/Expression.d @ 130:60bb0fe4563e
dmdfe 2.037 first main iteration
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Thu, 09 Sep 2010 22:51:44 +0100 |
parents | 1765f3ef917d |
children | af1bebfd96a4 |
line wrap: on
line diff
--- a/dmd/Expression.d Sun Sep 05 15:32:22 2010 +0400 +++ b/dmd/Expression.d Thu Sep 09 22:51:44 2010 +0100 @@ -3,7 +3,7 @@ import dmd.common; import dmd.Loc; import dmd.TOK; -import dmd.Argument; +import dmd.Parameter; import dmd.IdentifierExp; import dmd.Type; import dmd.WANT; @@ -705,12 +705,25 @@ static if (true) { if (sc.func) { + /* Given: + * void f() + * { pure void g() + * { + * void h() + * { + * void i() { } + * } + * } + * } + * g() can call h() but not f() + * i() can call h() and g() but not f() + */ FuncDeclaration outerfunc = sc.func; while (outerfunc.toParent2() && outerfunc.toParent2().isFuncDeclaration()) { outerfunc = outerfunc.toParent2().isFuncDeclaration(); } - if (outerfunc.isPure() && !sc.intypeof && (!f.isNested() && !f.isPure())) + if (outerfunc.isPure() && !sc.intypeof && (!f.isNested() && !f.isPure())) error("pure function '%s' cannot call impure function '%s'\n", sc.func.toChars(), f.toChars()); } @@ -720,6 +733,14 @@ sc.func.toChars(), .toChars()); } } + + void checkSafety(Scope sc, FuncDeclaration f) + { + if (sc.func && sc.func.isSafe() && !sc.intypeof && + !f.isSafe() && !f.isTrusted()) + error("safe function '%s' cannot call system function '%s'\n", + sc.func.toChars(), f.toChars()); + } /***************************** * Check that expression can be tested for true or false. @@ -932,6 +953,15 @@ } } + /**************************************** + * Resolve __LINE__ and __FILE__ to loc. + */ + + Expression resolveLoc(Loc loc, Scope sc) + { + return this; + } + int inlineCost(InlineCostState* ics) { return 1; @@ -987,10 +1017,10 @@ arguments.shift(this); } - Expression buildArrayLoop(Arguments fparams) + Expression buildArrayLoop(Parameters fparams) { Identifier id = Identifier.generateId("c", fparams.dim); - auto param = new Argument(STC.STCundefined, type, id, null); + auto param = new Parameter(STC.STCundefined, type, id, null); fparams.shift(param); Expression e = new IdentifierExp(Loc(0), id); return e;