Ejemplo n.º 1
0
/*******************************BuiltinPtr********************************/
string TarsAnalyzer::tostrBuiltin(const BuiltinPtr &pPtr)
{
    string s;

    switch(pPtr->kind())
    {
    case Builtin::KindBool:
        s = " bool ";
        break;
    case Builtin::KindByte:
        s = " char ";
        break;
    case Builtin::KindShort:
    //为了兼容java无unsigned, 编结码时把tars问件中 unsigned char 对应到short
    //c++中需要还原回来
        s = (pPtr->isUnsigned()?"uchar":" short ");
        break;
    case Builtin::KindInt:
        s = (pPtr->isUnsigned()?"ushort":" int ");
        break;
    case Builtin::KindLong:
        s =  (pPtr->isUnsigned()?"uint":" int64 ");
        break;
    case Builtin::KindFloat:
        s = " float ";
        break;
    case Builtin::KindDouble:
        s = " double ";
        break;
    case Builtin::KindString:
        if(pPtr->isArray())
            s = "char[]"; //char a [8];
        else
            s = " string ";//string a;
        break;
    case Builtin::KindVector:
        s = " vector ";
        break;
    case Builtin::KindMap:
        s = " map ";
        break;
    default:
        cout << getTab() << " _cur:" << _cur << " _last_pos:" << _last_pos << endl;
        exit(-1);
        break;
    }

    return s;
}
Ejemplo n.º 2
0
/*******************************获取定长数组坐标********************************/
int Jce2Php::getSuffix(const TypeIdPtr &pPtr) const
{
    BuiltinPtr bPtr = BuiltinPtr::dynamicCast(pPtr->getTypePtr());
    if(bPtr && bPtr->kind() == Builtin::KindString && bPtr->isArray())
    {
        return bPtr->getSize();
    }

    VectorPtr vPtr = VectorPtr::dynamicCast(pPtr->getTypePtr());
    if(vPtr && vPtr->isArray())
    {
        return vPtr->getSize();
    }

    return -1;
}