00001 #include "text.h" 00002 #include "image.h" 00003 #include "runtime.h" 00004 #include "point.h" 00005 00006 Value * Runtime::div(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::div(vector<Value*> values) 00029 { 00030 if (values.size()!=2) return NULL; 00031 return div(values[0],values[1]); 00032 }