diff options
Diffstat (limited to 'linden/indra/llmath/llcalcparser.cpp')
-rw-r--r-- | linden/indra/llmath/llcalcparser.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/linden/indra/llmath/llcalcparser.cpp b/linden/indra/llmath/llcalcparser.cpp new file mode 100644 index 0000000..1546c09 --- /dev/null +++ b/linden/indra/llmath/llcalcparser.cpp | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * LLCalcParser.cpp | ||
3 | * SecondLife | ||
4 | * | ||
5 | * Created by Aimee Walton on 28/09/2008. | ||
6 | * Copyright 2008 Aimee Walton. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #include "linden_common.h" | ||
11 | |||
12 | #include "llcalcparser.h" | ||
13 | |||
14 | F32 LLCalcParser::lookup(const std::string::iterator& start, const std::string::iterator& end) const | ||
15 | { | ||
16 | LLCalc::calc_map_t::iterator iter; | ||
17 | |||
18 | std::string name(start, end); | ||
19 | |||
20 | if (mConstants) | ||
21 | { | ||
22 | iter = mConstants->find(name); | ||
23 | if (iter != mConstants->end()) | ||
24 | { | ||
25 | return (*iter).second; | ||
26 | } | ||
27 | } | ||
28 | else | ||
29 | { | ||
30 | // This should never happen! | ||
31 | boost::spirit::throw_(end, std::string("Missing constants table")); | ||
32 | } | ||
33 | |||
34 | if (mVariables) | ||
35 | { | ||
36 | iter = mVariables->find(name); | ||
37 | if (iter != mVariables->end()) | ||
38 | { | ||
39 | return (*iter).second; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | boost::spirit::throw_(end, std::string("Unknown symbol " + name)); | ||
44 | return 0.f; | ||
45 | } | ||