FreeBSD/sys/contrib/dev/acpica/compiler/aslpredef.c
/*******************************************************************************
 *
 * FUNCTION:    ApCheckObjectType
 *
 * PARAMETERS:  PredefinedName  - Name of the predefined object we are checking
 *              Op              - Current parse node
 *              ExpectedBtypes  - Bitmap of expected return type(s)
 *              PackageIndex    - Index of object within parent package (if
 *                                applicable - ACPI_NOT_PACKAGE_ELEMENT
 *                                otherwise)
 *
 * RETURN:      None
 *
 * DESCRIPTION: Check if the object type is one of the types that is expected
 *              by the predefined name. Only a limited number of object types
 *              can be returned by the predefined names.
 *
 ******************************************************************************/


None

Check if the object type is one of the types that is expected
by the predefined name. Only a limited number of object types
can be returned by the predefined names.
None Check if the object type is one of the types that is expected by the predefined name . Only a limited number of object types can be returned by the predefined names .
ACPI_STATUS
ApCheckObjectType (
    const char              *PredefinedName,
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  ExpectedBtypes,
    UINT32                  PackageIndex)
{
    UINT32                  ReturnBtype;
    char                    *TypeName;
    if (!Op)
    {
        return (AE_TYPE);
    }
    switch (Op->Asl.ParseOpcode)
    {
    case PARSEOP_ZERO:
    case PARSEOP_ONE:
    case PARSEOP_ONES:
    case PARSEOP_INTEGER:
        ReturnBtype = ACPI_RTYPE_INTEGER;
        TypeName = "Integer";
        break;
    case PARSEOP_STRING_LITERAL:
        ReturnBtype = ACPI_RTYPE_STRING;
        TypeName = "String";
        break;
    case PARSEOP_BUFFER:
        ReturnBtype = ACPI_RTYPE_BUFFER;
        TypeName = "Buffer";
        break;
    case PARSEOP_PACKAGE:
    case PARSEOP_VAR_PACKAGE:
        ReturnBtype = ACPI_RTYPE_PACKAGE;
        TypeName = "Package";
        break;
    case PARSEOP_NAMESEG:
    case PARSEOP_NAMESTRING:
        if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
        {
            return (AE_OK);
        }
        ReturnBtype = ACPI_RTYPE_REFERENCE;
        TypeName = "Reference";
        break;
    default:
        TypeName = UtGetOpName (Op->Asl.ParseOpcode);
        goto TypeErrorExit;
    }
    if (ReturnBtype & ExpectedBtypes)
    {
        return (AE_OK);
    }
TypeErrorExit:
    AcpiUtGetExpectedReturnTypes (StringBuffer, ExpectedBtypes);
    if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
    {
        sprintf (MsgBuffer, "%4.4s: found %s, %s required",
            PredefinedName, TypeName, StringBuffer);
    }
    else
    {
        sprintf (MsgBuffer, "%4.4s: found %s at index %u, %s required",
            PredefinedName, TypeName, PackageIndex, StringBuffer);
    }
    AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer);
    return (AE_TYPE);
}
ACPI_STATUS ApCheckObjectType ( const char * PredefinedName , ACPI_PARSE_OBJECT * Op , UINT32 ExpectedBtypes , UINT32 PackageIndex ) { UINT32 ReturnBtype ; char * TypeName ; if ( ! Op ) { return ( AE_TYPE ) ; } switch ( Op -> Asl . ParseOpcode ) { case PARSEOP_ZERO : case PARSEOP_ONE : case PARSEOP_ONES : case PARSEOP_INTEGER : ReturnBtype = ACPI_RTYPE_INTEGER ; TypeName = " " ; break ; case PARSEOP_STRING_LITERAL : ReturnBtype = ACPI_RTYPE_STRING ; TypeName = " " ; break ; case PARSEOP_BUFFER : ReturnBtype = ACPI_RTYPE_BUFFER ; TypeName = " " ; break ; case PARSEOP_PACKAGE : case PARSEOP_VAR_PACKAGE : ReturnBtype = ACPI_RTYPE_PACKAGE ; TypeName = " " ; break ; case PARSEOP_NAMESEG : case PARSEOP_NAMESTRING : if ( PackageIndex != ACPI_NOT_PACKAGE_ELEMENT ) { return ( AE_OK ) ; } ReturnBtype = ACPI_RTYPE_REFERENCE ; TypeName = " " ; break ; default : TypeName = UtGetOpName ( Op -> Asl . ParseOpcode ) ; goto TypeErrorExit ; } if ( ReturnBtype & ExpectedBtypes ) { return ( AE_OK ) ; } TypeErrorExit : AcpiUtGetExpectedReturnTypes ( StringBuffer , ExpectedBtypes ) ; if ( PackageIndex == ACPI_NOT_PACKAGE_ELEMENT ) { sprintf ( MsgBuffer , " " , PredefinedName , TypeName , StringBuffer ) ; } else { sprintf ( MsgBuffer , " " , PredefinedName , TypeName , PackageIndex , StringBuffer ) ; } AslError ( ASL_ERROR , ASL_MSG_RESERVED_OPERAND_TYPE , Op , MsgBuffer ) ; return ( AE_TYPE ) ; }
FUNCTION:    ApCheckObjectType
 PARAMETERS:  PredefinedName  - Name of the predefined object we are checking
              Op              - Current parse node
              ExpectedBtypes  - Bitmap of expected return type(s)
              PackageIndex    - Index of object within parent package (if
                                applicable - ACPI_NOT_PACKAGE_ELEMENT
                                otherwise)
FUNCTION : ApCheckObjectType PARAMETERS : PredefinedName - Name of the predefined object we are checking Op - Current parse node ExpectedBtypes - Bitmap of expected return type ( s ) PackageIndex - Index of object within parent package ( if applicable - ACPI_NOT_PACKAGE_ELEMENT otherwise )
/* Map the parse opcode to a bitmapped return type (RTYPE) */ /*
         * Ignore any named references within a package object.
         *
         * For Package objects, references are allowed instead of any of the
         * standard data types (Integer/String/Buffer/Package). These
         * references are resolved at runtime. NAMESEG and NAMESTRING are
         * impossible to typecheck at compile time because the type of
         * any named object can be changed at runtime (for example,
         * CopyObject will change the type of the target object).
         */ /* Not one of the supported object types */ /* Exit if the object is one of the expected types */ /* Format the expected types and emit an error message */