Commit 2ea18da7 authored by Marius Bozga's avatar Marius Bozga
Browse files

improve type checking in presence of renamed types

parent 01542e56
......@@ -269,21 +269,21 @@ void IfCallExpression::PreCompile() {
switch (m_eOperator) {
case INSERT:
if (t0->IsString() &&
if (t0->GetBase()->IsString() &&
t1->Match(integer) &&
t2->Match(((IfStringType*) t0)->GetElement()))
t2->Match(((IfStringType*) t0->GetBase())->GetElement()))
m_pType = t0;
break;
case REMOVE:
if (t0->IsString() &&
if (t0->GetBase()->IsString() &&
t1->Match(integer))
m_pType = t0;
break;
case INDEX:
if ((t0->IsString() &&
t1->Match(((IfStringType*) t0)->GetElement())) ||
(t0->IsArray() &&
t1->Match(((IfArrayType*) t1)->GetElement())))
if ((t0->GetBase()->IsString() &&
t1->Match(((IfStringType*) t0->GetBase())->GetElement())) ||
(t0->GetBase()->IsArray() &&
t1->Match(((IfArrayType*) t1->GetBase())->GetElement())))
m_pType = integer;
break;
case OBS_QLENGTH:
......@@ -469,8 +469,8 @@ void IfFieldExpression::PreCompile() {
if (m_pBase->GetType() == NULL)
return;
if (m_pBase->GetType()->IsRecord() || m_pBase->GetType()->IsUnion()) {
IfRecordType* record = (IfRecordType*) m_pBase->GetType();
if (m_pBase->GetType()->GetBase()->IsRecord() || m_pBase->GetType()->GetBase()->IsUnion()) {
IfRecordType* record = (IfRecordType*) m_pBase->GetType()->GetBase();
m_pField = record->GetFields()->Find(m_pFieldName);
m_eKind = RECORD;
}
......@@ -1026,18 +1026,18 @@ void IfIndexExpression::PreCompile() {
if (m_pBase->GetType() && m_pIndex->GetType()) {
IfType* integer = TYPES[IfBasicType::INTEGER];
if (m_pBase->GetType()->IsArray() &&
if (m_pBase->GetType()->GetBase()->IsArray() &&
m_pIndex->GetType()->Match(integer))
m_pType = ((IfArrayType*) m_pBase->GetType())->GetElement();
m_pType = ((IfArrayType*) m_pBase->GetType()->GetBase())->GetElement();
if (m_pBase->GetType()->IsString() &&
if (m_pBase->GetType()->GetBase()->IsString() &&
m_pIndex->GetType()->Match(integer))
m_pType = ((IfStringType*) m_pBase->GetType())->GetElement();
m_pType = ((IfStringType*) m_pBase->GetType()->GetBase())->GetElement();
if (m_pBase->GetType()->IsTree() &&
m_pIndex->GetType()->IsString() &&
((IfStringType*) m_pIndex->GetType())->GetElement()->Match(integer))
m_pType = ((IfTreeType*) m_pBase->GetType())->GetElement();
if (m_pBase->GetType()->GetBase()->IsTree() &&
m_pIndex->GetType()->GetBase()->IsString() &&
((IfStringType*) m_pIndex->GetType()->GetBase())->GetElement()->Match(integer))
m_pType = ((IfTreeType*) m_pBase->GetType()->GetBase())->GetElement();
}
if (m_pIndex->IsTimed()) {
......@@ -1116,7 +1116,7 @@ void IfUnaryExpression::PreCompile() {
m_pType = (m_eOperator == ACTIVE) ? boolean : integer;
break;
case LENGTH:
if (tr->IsArray() || tr->IsString())
if (tr->GetBase()->IsArray() || tr->GetBase()->IsString())
m_pType = integer;
break;
case PLUS: case MINUS:
......@@ -1390,7 +1390,7 @@ void IfTernaryExpression::PreCompile() {
m_pType = m_pLeft->GetType();
break;
case SUBSTRING:
if (m_pTop->GetType()->IsString() &&
if (m_pTop->GetType()->GetBase()->IsString() &&
m_pLeft->GetType()->Match(integer) &&
m_pRight->GetType()->Match(integer))
m_pType = m_pTop->GetType();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment