00001 #include "text.h" 00002 #include "image.h" 00003 #include "runtime.h" 00004 #include "point.h" 00005 00006 Value * Runtime::mul(Value * a, Value * b) 00007 { 00008 if (!a || !b) return NULL; 00009 if (typeid(*a)==typeid(TextValue) && typeid(*b)==typeid(TextValue)) 00010 { 00011 TextValue * A = (TextValue*)a; 00012 TextValue * B = (TextValue*)b; 00013 return new TextValue(A->number()/B->number()); 00014 } 00015 if (typeid(*a)==typeid(PointValue) && typeid(*b)==typeid(TextValue)) 00016 { 00017 PointValue * A = (PointValue*)a; 00018 TextValue * B = (TextValue*)b; 00019 double C = B->number(); 00020 PointValue * R = new PointValue(); 00021 R->x=A->x*C; 00022 R->y=A->y*C; 00023 return R; 00024 } 00025 assert(0); 00026 } 00027 00028 Value * Runtime::mul(vector<Value*> values) 00029 { 00030 Value * accumulated = values[0]; 00031 for(unsigned int i = 1 ; i < values.size() ; i++) 00032 accumulated=mul(accumulated,values[i]); 00033 return accumulated; 00034 }