| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> |
| 3 * Copyright (C) 2006, 2009 Apple Inc. | 3 * Copyright (C) 2006, 2009 Apple Inc. |
| 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 if (m_min == Inf) | 284 if (m_min == Inf) |
| 285 return value <= m_max; | 285 return value <= m_max; |
| 286 | 286 |
| 287 if (m_max == Inf) | 287 if (m_max == Inf) |
| 288 return value >= m_min; | 288 return value >= m_min; |
| 289 | 289 |
| 290 return value >= m_min && value <= m_max; | 290 return value >= m_min && value <= m_max; |
| 291 } | 291 } |
| 292 | 292 |
| 293 void Function::setArguments(const Vector<Expression*>& args) | 293 void Function::setArguments(Vector<OwnPtr<Expression> >& args) |
| 294 { | 294 { |
| 295 ASSERT(!subExprCount()); | 295 ASSERT(!subExprCount()); |
| 296 | 296 |
| 297 // Some functions use context node as implicit argument, so when explicit ar
guments are added, they may no longer be context node sensitive. | 297 // Some functions use context node as implicit argument, so when explicit ar
guments are added, they may no longer be context node sensitive. |
| 298 if (m_name != "lang" && !args.isEmpty()) | 298 if (m_name != "lang" && !args.isEmpty()) |
| 299 setIsContextNodeSensitive(false); | 299 setIsContextNodeSensitive(false); |
| 300 | 300 |
| 301 Vector<Expression*>::const_iterator end = args.end(); | 301 Vector<OwnPtr<Expression> >::iterator end = args.end(); |
| 302 for (Vector<Expression*>::const_iterator it = args.begin(); it != end; it++) | 302 for (Vector<OwnPtr<Expression> >::iterator it = args.begin(); it != end; it+
+) |
| 303 addSubExpression(*it); | 303 addSubExpression(it->release()); |
| 304 } | 304 } |
| 305 | 305 |
| 306 Value FunLast::evaluate() const | 306 Value FunLast::evaluate() const |
| 307 { | 307 { |
| 308 return Expression::evaluationContext().size; | 308 return Expression::evaluationContext().size; |
| 309 } | 309 } |
| 310 | 310 |
| 311 Value FunPosition::evaluate() const | 311 Value FunPosition::evaluate() const |
| 312 { | 312 { |
| 313 return Expression::evaluationContext().position; | 313 return Expression::evaluationContext().position; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 { "sum", { &createFunSum, 1 } }, | 705 { "sum", { &createFunSum, 1 } }, |
| 706 { "translate", { &createFunTranslate, 3 } }, | 706 { "translate", { &createFunTranslate, 3 } }, |
| 707 { "true", { &createFunTrue, 0 } }, | 707 { "true", { &createFunTrue, 0 } }, |
| 708 }; | 708 }; |
| 709 | 709 |
| 710 functionMap = new HashMap<String, FunctionRec>; | 710 functionMap = new HashMap<String, FunctionRec>; |
| 711 for (size_t i = 0; i < WTF_ARRAY_LENGTH(functions); ++i) | 711 for (size_t i = 0; i < WTF_ARRAY_LENGTH(functions); ++i) |
| 712 functionMap->set(functions[i].name, functions[i].function); | 712 functionMap->set(functions[i].name, functions[i].function); |
| 713 } | 713 } |
| 714 | 714 |
| 715 Function* createFunction(const String& name, const Vector<Expression*>& args) | 715 |
| 716 Function* createFunction(const String& name) |
| 717 { |
| 718 Vector<OwnPtr<Expression> > args; |
| 719 return createFunction(name, args); |
| 720 } |
| 721 |
| 722 Function* createFunction(const String& name, Vector<OwnPtr<Expression> >& args) |
| 716 { | 723 { |
| 717 if (!functionMap) | 724 if (!functionMap) |
| 718 createFunctionMap(); | 725 createFunctionMap(); |
| 719 | 726 |
| 720 HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(n
ame); | 727 HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(n
ame); |
| 721 FunctionRec* functionRec = 0; | 728 FunctionRec* functionRec = 0; |
| 722 | 729 |
| 723 if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIte
r->value)->args.contains(args.size())) | 730 if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIte
r->value)->args.contains(args.size())) |
| 724 return 0; | 731 return 0; |
| 725 | 732 |
| 726 Function* function = functionRec->factoryFn(); | 733 Function* function = functionRec->factoryFn(); |
| 727 function->setArguments(args); | 734 function->setArguments(args); |
| 728 function->setName(name); | 735 function->setName(name); |
| 729 return function; | 736 return function; |
| 730 } | 737 } |
| 731 | 738 |
| 732 } | 739 } |
| 733 } | 740 } |
| OLD | NEW |