comparison dmd/CallExp.d @ 84:be2ab491772e

Expressions -> Vector!Expression
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Mon, 30 Aug 2010 16:12:19 +0100
parents 43073c7c7769
children 39648eb578f6
comparison
equal deleted inserted replaced
83:ee670dd808a8 84:be2ab491772e
91 91
92 this(Loc loc, Expression e, Expression earg1) 92 this(Loc loc, Expression e, Expression earg1)
93 { 93 {
94 super(loc, TOK.TOKcall, CallExp.sizeof, e); 94 super(loc, TOK.TOKcall, CallExp.sizeof, e);
95 95
96 Expressions arguments = new Expressions(); 96 auto arguments = new Expressions();
97 if (earg1) 97 if (earg1)
98 { 98 {
99 arguments.setDim(1); 99 arguments.setDim(1);
100 arguments.data[0] = cast(void*)earg1; 100 arguments[0] = earg1;
101 } 101 }
102 this.arguments = arguments; 102 this.arguments = arguments;
103 } 103 }
104 104
105 this(Loc loc, Expression e, Expression earg1, Expression earg2) 105 this(Loc loc, Expression e, Expression earg1, Expression earg2)
106 { 106 {
107 super(loc, TOK.TOKcall, CallExp.sizeof, e); 107 super(loc, TOK.TOKcall, CallExp.sizeof, e);
108 108
109 Expressions arguments = new Expressions(); 109 auto arguments = new Expressions();
110 arguments.setDim(2); 110 arguments.setDim(2);
111 arguments.data[0] = cast(void*)earg1; 111 arguments.data[0] = earg1;
112 arguments.data[1] = cast(void*)earg2; 112 arguments.data[1] = earg2;
113 113
114 this.arguments = arguments; 114 this.arguments = arguments;
115 } 115 }
116 116
117 override Expression syntaxCopy() 117 override Expression syntaxCopy()
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)
188 { 188 {
189 if (!arguments) 189 if (!arguments)
190 arguments = new Expressions(); 190 arguments = new Expressions();
191 arguments.shift(cast(void*)dotid.e1); 191 arguments.shift(dotid.e1);
192 version (DMDV2) { 192 version (DMDV2) {
193 e1 = new DotIdExp(dotid.loc, new IdentifierExp(dotid.loc, Id.empty), dotid.ident); 193 e1 = new DotIdExp(dotid.loc, new IdentifierExp(dotid.loc, Id.empty), dotid.ident);
194 } else { 194 } else {
195 e1 = new IdentifierExp(dotid.loc, dotid.ident); 195 e1 = new IdentifierExp(dotid.loc, dotid.ident);
196 } 196 }
782 Expression e = this; 782 Expression e = this;
783 783
784 // Optimize parameters 784 // Optimize parameters
785 if (arguments) 785 if (arguments)
786 { 786 {
787 for (size_t i = 0; i < arguments.dim; i++) 787 foreach (ref Expression ee; arguments)
788 { 788 {
789 Expression ee = cast(Expression)arguments.data[i];
790
791 ee = ee.optimize(WANT.WANTvalue); 789 ee = ee.optimize(WANT.WANTvalue);
792 arguments.data[i] = cast(void*)ee;
793 } 790 }
794 } 791 }
795 792
796 e1 = e1.optimize(result); 793 e1 = e1.optimize(result);
797 if (e1.op == TOK.TOKvar) 794 if (e1.op == TOK.TOKvar)
860 { 857 {
861 scope Expressions args = new Expressions(); 858 scope Expressions args = new Expressions();
862 args.setDim(arguments.dim); 859 args.setDim(arguments.dim);
863 for (size_t i = 0; i < args.dim; i++) 860 for (size_t i = 0; i < args.dim; i++)
864 { 861 {
865 Expression earg = cast(Expression)arguments.data[i]; 862 auto earg = arguments[i];
866 earg = earg.interpret(istate); 863 earg = earg.interpret(istate);
867 if (earg == EXP_CANT_INTERPRET) 864 if (earg == EXP_CANT_INTERPRET)
868 return earg; 865 return earg;
869 args.data[i] = cast(void*)earg; 866 args[i] = earg;
870 } 867 }
871 e = eval_builtin(b, args); 868 e = eval_builtin(b, args);
872 if (!e) 869 if (!e)
873 e = EXP_CANT_INTERPRET; 870 e = EXP_CANT_INTERPRET;
874 } 871 }