relation_set.cc
//converts the AstConstant to a Variable based on the defined type
//s.t. it fails if the AstConstant type and specified type do not match
converts the AstConstant to a Variable based on the defined type
s.t. it fails if the AstConstant type and specified type do not match
converts the AstConstant to a Variable based on the defined type s . t . it fails if the AstConstant type and specified type do not match
Variable RelationSet::toVariableByType(AstConstant &constant, VariableSetType type)  {
    Variable var;
    var.isEnum = false;
    if(constant.type == AstValueType::Integer)  {
        int64_t value = boost::get<int64_t>(constant.value);
        if(type == VariableSetType::INT64) {
            var.type = VariableSetType::INT64;
            var.value.asInt64 = value;
        }
        else if(type == VariableSetType::INT32) {
            var.type = VariableSetType::INT32;
            var.value.asInt32 = value;
        }
        else if(type == VariableSetType::INT16) {
            var.type = VariableSetType::INT16;
            var.value.asInt16 = value;
        }
        else if(type == VariableSetType::INT8) {
            var.type = VariableSetType::INT8;
            var.value.asInt8 = value;
        }
        else if(type == VariableSetType::UINT32) {
            var.type = VariableSetType::UINT32;
            var.value.asUInt32 = value;
        }
        else if(type == VariableSetType::UINT16) {
            var.type = VariableSetType::UINT16;
            var.value.asUInt16 = value;
        }
        else if(type == VariableSetType::UINT8) {
            var.type = VariableSetType::UINT8;
            var.value.asUInt8 = value;
        }
        else {
            throw "Defined type is not implemented in toVariableByType()!";
        }
    }
    else if(constant.type == AstValueType::Float && type == VariableSetType::DOUBLE)  {
        var.type = VariableSetType::DOUBLE;
        var.value.asDouble = boost::get<double>(constant.value);
    }
    else if(constant.type == AstValueType::Boolean && type == VariableSetType::BOOLEAN)  {
        var.type = VariableSetType::BOOLEAN;
        var.value.asBoolean = boost::get<bool>(constant.value);
    }
    else if(constant.type == AstValueType::String && type == VariableSetType::STRING)  {
        var.type = VariableSetType::STRING;
        var.value.asString = new string(boost::get<string>(constant.value));
    }
    else if(constant.type == AstValueType::EnumValue && type == VariableSetType::ENUM_VALUE)  {
        var.type = VariableSetType::ENUM_VALUE;
        var.value.asInt32 = boost::get<int64_t>(constant.value);
        var.bitsForEnumValuePosition = constant.bitsForEnumValuePosition;
    }
    else
        throw "Unsupported AstValueType and VariableSetType combination in RelationSet::toVariableByType()";
    return var;
}
Variable RelationSet :: toVariableByType ( AstConstant & constant , VariableSetType type ) { Variable var ; var . isEnum = false ; if ( constant . type == AstValueType :: Integer ) { int64_t value = boost :: get < int64_t > ( constant . value ) ; if ( type == VariableSetType :: INT64 ) { var . type = VariableSetType :: INT64 ; var . value . asInt64 = value ; } else if ( type == VariableSetType :: INT32 ) { var . type = VariableSetType :: INT32 ; var . value . asInt32 = value ; } else if ( type == VariableSetType :: INT16 ) { var . type = VariableSetType :: INT16 ; var . value . asInt16 = value ; } else if ( type == VariableSetType :: INT8 ) { var . type = VariableSetType :: INT8 ; var . value . asInt8 = value ; } else if ( type == VariableSetType :: UINT32 ) { var . type = VariableSetType :: UINT32 ; var . value . asUInt32 = value ; } else if ( type == VariableSetType :: UINT16 ) { var . type = VariableSetType :: UINT16 ; var . value . asUInt16 = value ; } else if ( type == VariableSetType :: UINT8 ) { var . type = VariableSetType :: UINT8 ; var . value . asUInt8 = value ; } else { throw " " ; } } else if ( constant . type == AstValueType :: Float && type == VariableSetType :: DOUBLE ) { var . type = VariableSetType :: DOUBLE ; var . value . asDouble = boost :: get < double > ( constant . value ) ; } else if ( constant . type == AstValueType :: Boolean && type == VariableSetType :: BOOLEAN ) { var . type = VariableSetType :: BOOLEAN ; var . value . asBoolean = boost :: get < bool > ( constant . value ) ; } else if ( constant . type == AstValueType :: String && type == VariableSetType :: STRING ) { var . type = VariableSetType :: STRING ; var . value . asString = new string ( boost :: get < string > ( constant . value ) ) ; } else if ( constant . type == AstValueType :: EnumValue && type == VariableSetType :: ENUM_VALUE ) { var . type = VariableSetType :: ENUM_VALUE ; var . value . asInt32 = boost :: get < int64_t > ( constant . value ) ; var . bitsForEnumValuePosition = constant . bitsForEnumValuePosition ; } else throw " " ; return var ; }
converts the AstConstant to a Variable based on the defined type
s.t.
converts the AstConstant to a Variable based on the defined type s . t .
//get the value as the maximal type possible