| 170 | | class Reference: |
| | 172 | class Unresolved: |
| | 173 | def __mul__(self, other): |
| | 174 | return Operation((lambda a,b: int(a) * int(b)), |
| | 175 | [self, makeValue(other)]) |
| | 176 | |
| | 177 | class Value(Unresolved): |
| | 178 | def __init__(self, value): |
| | 179 | self.value = value |
| | 180 | def getValue(self, args): |
| | 181 | return self.value |
| | 182 | |
| | 183 | def makeValue(a): |
| | 184 | if isinstance(a, Unresolved): |
| | 185 | return a |
| | 186 | return Value(a) |
| | 187 | |
| | 188 | class Reference(Unresolved): |
| | 204 | class Template(Unresolved): |
| | 205 | def __init__(self, name, args): |
| | 206 | self.name = makeValue(name) |
| | 207 | self.args = map(lambda x: makeValue(x), args) |
| | 208 | def getValue(self, args): |
| | 209 | params = ', '.join(map(lambda x:str(x.getValue(args)), self.args)) |
| | 210 | return self.name.getValue(args) + '<' + params + ' > ' |
| | 211 | |
| | 212 | class Operation(Unresolved): |
| | 213 | def __init__(self, func, args): |
| | 214 | self.func = func |
| | 215 | self.args = args |
| | 216 | pass |
| | 217 | def getValue(self, args): |
| | 218 | return apply(self.func, map(lambda x:str(x.getValue(args)), self.args)) |
| | 219 | |