Open dianaliu opened 12 years ago
Grimm mentioned in class today that he loves the operator + DUN DUN DUN
We get the below error because the + operator needs to be overloaded? (or specialized?)
--- Finish translation. See xtc/output/
FloatArray.cc: In function ‘int32_t main()’:
FloatArray.cc:85: error: no match for ‘operator+’ in ‘__rt::literal(const char*)() + f. __rt::Ptr<T>::operator-> [with T = __rt::Array<float>]()->__rt::Array<float>::length’
--- ERR: CPP compile time error
Generated CC code:
using namespace java::lang;
int32_t main() {
__rt::Ptr<__rt::Array<float > > f = new __rt::Array<float >(2);
for (int32_t i = 0; i < f->length; i++) {
// __rt::checkNotNull(i);
// __rt::checkStore(f,i);
(*f)[i] = i;
}
// __rt::checkNotNull(f);
std::cout
<< __rt::literal("array f has ") + f->length << __rt::literal(" element(s)")
<< std::endl;
}
There are only 7 cases where it fails. We need this to compile!!!
Test.cc:1349: error: no match for ‘operator+’ in ‘__rt::literal(const char*)() + __rt::literal(const char*)()’
Test.cc:1364: error: no match for ‘operator+’ in ‘__rt::literal(const char*)() + __rt::literal(const char*)()’
Test.cc:1379: error: no match for ‘operator+’ in ‘__rt::literal(const char*)() + 1’
Test.cc:1394: error: no match for ‘operator+’ in ‘__rt::literal(const char*)() + '1'’
Test.cc:1409: error: no match for ‘operator+’ in ‘'H' + __rt::literal(const char*)()’
Test.cc:1428: error: no match for ‘operator+’ in ‘c + __rt::literal(const char*)()’
Test.cc:1443: error: no match for ‘operator+’ in ‘'H' + __rt::literal(const char*)()’
// String s3 = s1 + " and " + s2; std::ostringstream temp; temp << s1 << " and " << s2; String s3 = new java::lang::__String(temp.str()
String s = "hi" + "bye"
Translator translates this to rt::StringLiteral("hi") + rt::StringLiteral("bye") or something like that. the + doesn't work.