comparison dmd/CallExp.d @ 90:39648eb578f6

more Expressions work
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Mon, 30 Aug 2010 20:27:56 +0100
parents be2ab491772e
children acd69f84627e
comparison
equal deleted inserted replaced
88:23280d154c5b 90:39648eb578f6
106 { 106 {
107 super(loc, TOK.TOKcall, CallExp.sizeof, e); 107 super(loc, TOK.TOKcall, CallExp.sizeof, e);
108 108
109 auto arguments = new Expressions(); 109 auto arguments = new Expressions();
110 arguments.setDim(2); 110 arguments.setDim(2);
111 arguments.data[0] = earg1; 111 arguments[0] = earg1;
112 arguments.data[1] = earg2; 112 arguments[1] = earg2;
113 113
114 this.arguments = arguments; 114 this.arguments = arguments;
115 } 115 }
116 116
117 override Expression syntaxCopy() 117 override Expression syntaxCopy()
172 if (!arguments || arguments.dim != 1) 172 if (!arguments || arguments.dim != 1)
173 { 173 {
174 error("expected key as argument to aa.remove()"); 174 error("expected key as argument to aa.remove()");
175 goto Lagain; 175 goto Lagain;
176 } 176 }
177 Expression key = cast(Expression)arguments.data[0]; 177 auto key = arguments[0];
178 key = key.semantic(sc); 178 key = key.semantic(sc);
179 key = resolveProperties(sc, key); 179 key = resolveProperties(sc, key);
180 key.rvalue(); 180 key.rvalue();
181 181
182 TypeAArray taa = cast(TypeAArray)dotid.e1.type.toBasetype(); 182 auto taa = cast(TypeAArray)dotid.e1.type.toBasetype();
183 key = key.implicitCastTo(sc, taa.index); 183 key = key.implicitCastTo(sc, taa.index);
184 184
185 return new RemoveExp(loc, dotid.e1, key); 185 return new RemoveExp(loc, dotid.e1, key);
186 } 186 }
187 else if (e1ty == TY.Tarray || e1ty == TY.Tsarray || e1ty == TY.Taarray) 187 else if (e1ty == TY.Tarray || e1ty == TY.Tsarray || e1ty == TY.Taarray)
872 else 872 else
873 ///} 873 ///}
874 // Inline .dup 874 // Inline .dup
875 if (fd.ident == Id.adDup && arguments && arguments.dim == 2) 875 if (fd.ident == Id.adDup && arguments && arguments.dim == 2)
876 { 876 {
877 e = cast(Expression)arguments.data[1]; 877 e = arguments[1];
878 e = e.interpret(istate); 878 e = e.interpret(istate);
879 if (e !is EXP_CANT_INTERPRET) 879 if (e !is EXP_CANT_INTERPRET)
880 { 880 {
881 e = expType(type, e); 881 e = expType(type, e);
882 } 882 }
905 if (e1.checkSideEffect(2)) 905 if (e1.checkSideEffect(2))
906 return true; 906 return true;
907 907
908 /* If any of the arguments have side effects, this expression does 908 /* If any of the arguments have side effects, this expression does
909 */ 909 */
910 for (size_t i = 0; i < arguments.dim; i++) 910 foreach (e; arguments)
911 { 911 {
912 Expression e = cast(Expression)arguments.data[i];
913
914 if (e.checkSideEffect(2)) 912 if (e.checkSideEffect(2))
915 return true; 913 return true;
916 } 914 }
917 915
918 /* If calling a function or delegate that is typed as pure, 916 /* If calling a function or delegate that is typed as pure,
988 { 986 {
989 fd = (cast(VarExp)e1).var.isFuncDeclaration(); 987 fd = (cast(VarExp)e1).var.isFuncDeclaration();
990 988
991 if (fd && fd.ident == Id.alloca && !fd.fbody && fd.linkage == LINK.LINKc && arguments && arguments.dim == 1) 989 if (fd && fd.ident == Id.alloca && !fd.fbody && fd.linkage == LINK.LINKc && arguments && arguments.dim == 1)
992 { 990 {
993 Expression arg = cast(Expression)arguments.data[0]; 991 auto arg = arguments[0];
994 arg = arg.optimize(WANT.WANTvalue); 992 arg = arg.optimize(WANT.WANTvalue);
995 if (arg.isConst() && arg.type.isintegral()) 993 if (arg.isConst() && arg.type.isintegral())
996 { 994 {
997 long sz = arg.toInteger(); 995 long sz = arg.toInteger();
998 if (sz > 0 && sz < 0x40000) 996 if (sz > 0 && sz < 0x40000)
1058 if (e1.canThrow()) 1056 if (e1.canThrow())
1059 return true; 1057 return true;
1060 1058
1061 /* If any of the arguments can throw, then this expression can throw 1059 /* If any of the arguments can throw, then this expression can throw
1062 */ 1060 */
1063 for (size_t i = 0; i < arguments.dim; i++) 1061 foreach (e; arguments)
1064 { 1062 {
1065 Expression e = cast(Expression)arguments.data[i];
1066
1067 if (e && e.canThrow()) 1063 if (e && e.canThrow())
1068 return true; 1064 return true;
1069 } 1065 }
1070 1066
1071 if (global.errors && !e1.type) 1067 if (global.errors && !e1.type)