diff options
Diffstat (limited to 'lib/CodeGen/OperatorGen.cc')
| -rw-r--r-- | lib/CodeGen/OperatorGen.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/CodeGen/OperatorGen.cc b/lib/CodeGen/OperatorGen.cc new file mode 100644 index 0000000..83c515b --- /dev/null +++ b/lib/CodeGen/OperatorGen.cc @@ -0,0 +1,20 @@ +#include "cps/CodeGen.h" +#include "cps/Operator.h" + +using namespace cps; + +// Probing candidates must not evaluate operands or diagnose absent overloads: +// both static typing and emission use this same selection. +CodeGen::OperatorResolution CodeGen::resolveOperator( + int Op, const TypeInfo *Left, const TypeInfo *Right) { + OperatorResolution Result; + if (!Left) return Result; + for (const FuncSig *Sig : FuncGen->getOverloads(operatorName(Op))) { + if (Sig->Prototype->getOperator() != Op || Sig->Params.size() != (Right ? 2u : 1u)) continue; + if (!Left->sameType(resolveType(Sig->Params[0].TypeName))) continue; + if (Right && !Right->sameType(resolveType(Sig->Params[1].TypeName))) continue; + if (Result.Signature) Result.Ambiguous = true; + else Result.Signature = Sig; + } + return Result; +} |
