Type SubscriptOperation::type() const { Type lt = leftType(); if (Subscriptable* s = lt->tryType<Subscriptable>()) return s->subscriptsTo(rightType()); return Type(); }
void writeMatch(refMatch match) { refBuffer buffer = makeBuffer(stdout, 0); writeFormat(buffer, "[Match"); writeBlank(buffer); writingObject(buffer, leftLayer(match)); writeBlank(buffer); writingObject(buffer, leftType(match)); writeBlank(buffer); writingObject(buffer, rightLayer(match)); writeBlank(buffer); writingObject(buffer, rightType(match)); writeChar(buffer, ']'); writeBuffer(buffer); free(buffer); }
Types SubscriptOperation::allowedTypes(int _index) const { if (_index == FirstOperand) { return SubscriptableRegistrar::get()->m_acceptable.values(); } else if (_index == SecondOperand) { Type lt = leftType(); if (Subscriptable* s = lt->tryType<Subscriptable>()) { Types ts = s->subscriptTypes(); ts.replace(Type(), Type(Unsigned|Int)); return ts; } return Types(); } return Super::allowedTypes(_index); }