FreeBSD/sys/contrib/dev/acpica/compiler/aslpredef.c
/*******************************************************************************
 *
 * FUNCTION:    ApCheckPredefinedReturnValue
 *
 * PARAMETERS:  Op              - A parse node of type "RETURN".
 *              MethodInfo      - Saved info about this method
 *
 * RETURN:      None
 *
 * DESCRIPTION: If method is a predefined name, attempt to validate the return
 *              value. Only "static" types can be validated - a simple return
 *              of an integer/string/buffer/package or a named reference to
 *              a static object. Values such as a Localx or Argx or a control
 *              method invocation are not checked. Issue a warning if there is
 *              a valid return value, but the reserved method defines no
 *              return value.
 *
 ******************************************************************************/
ApCheckPredefinedReturnValue
PARAMETERS:  Op              - A parse node of type "RETURN".
MethodInfo      - Saved info about this method

None

If method is a predefined name, attempt to validate the return
value. Only "static" types can be validated - a simple return
of an integer/string/buffer/package or a named reference to
a static object. Values such as a Localx or Argx or a control
method invocation are not checked. Issue a warning if there is
a valid return value, but the reserved method defines no
return value.
ApCheckPredefinedReturnValue PARAMETERS : Op - A parse node of type " RETURN " . MethodInfo - Saved info about this method None If method is a predefined name attempt to validate the return value . Only " static " types can be validated - a simple return of an integer / string / buffer / package or a named reference to a static object . Values such as a Localx or Argx or a control method invocation are not checked . Issue a warning if there is a valid return value but the reserved method defines no return value .
void
ApCheckPredefinedReturnValue (
    ACPI_PARSE_OBJECT       *Op,
    ASL_METHOD_INFO         *MethodInfo)
{
    UINT32                      Index;
    ACPI_PARSE_OBJECT           *ReturnValueOp;
    const ACPI_PREDEFINED_INFO  *ThisName;
    Gbl_AllExceptionsDisabled = TRUE;
    Index = ApCheckForPredefinedName (MethodInfo->Op,
        MethodInfo->Op->Asl.NameSeg);
    Gbl_AllExceptionsDisabled = FALSE;
    switch (Index)
    {
    case ACPI_EVENT_RESERVED_NAME:      
        ApCheckForUnexpectedReturnValue (Op, MethodInfo);
        return;
    case ACPI_NOT_RESERVED_NAME:        
    case ACPI_PREDEFINED_NAME:          
    case ACPI_COMPILER_RESERVED_NAME:   
        return;
    default: 
        ThisName = &AcpiGbl_PredefinedMethods[Index];
        if (!ThisName->Info.ExpectedBtypes)
        {
            ApCheckForUnexpectedReturnValue (Op, MethodInfo);
            return;
        }
        ReturnValueOp = Op->Asl.Child;
        switch (ReturnValueOp->Asl.ParseOpcode)
        {
        case PARSEOP_ZERO:
        case PARSEOP_ONE:
        case PARSEOP_ONES:
        case PARSEOP_INTEGER:
        case PARSEOP_STRING_LITERAL:
        case PARSEOP_BUFFER:
        case PARSEOP_PACKAGE:
            ApCheckObjectType (ThisName->Info.Name, ReturnValueOp,
                ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
            if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_PACKAGE)
            {
                ApCheckPackage (ReturnValueOp, ThisName);
            }
            break;
        default:
            break;
        }
    }
}
void ApCheckPredefinedReturnValue ( ACPI_PARSE_OBJECT * Op , ASL_METHOD_INFO * MethodInfo ) { UINT32 Index ; ACPI_PARSE_OBJECT * ReturnValueOp ; const ACPI_PREDEFINED_INFO * ThisName ; Gbl_AllExceptionsDisabled = TRUE ; Index = ApCheckForPredefinedName ( MethodInfo -> Op , MethodInfo -> Op -> Asl . NameSeg ) ; Gbl_AllExceptionsDisabled = FALSE ; switch ( Index ) { case ACPI_EVENT_RESERVED_NAME : ApCheckForUnexpectedReturnValue ( Op , MethodInfo ) ; return ; case ACPI_NOT_RESERVED_NAME : case ACPI_PREDEFINED_NAME : case ACPI_COMPILER_RESERVED_NAME : return ; default : ThisName = & AcpiGbl_PredefinedMethods [ Index ] ; if ( ! ThisName -> Info . ExpectedBtypes ) { ApCheckForUnexpectedReturnValue ( Op , MethodInfo ) ; return ; } ReturnValueOp = Op -> Asl . Child ; switch ( ReturnValueOp -> Asl . ParseOpcode ) { case PARSEOP_ZERO : case PARSEOP_ONE : case PARSEOP_ONES : case PARSEOP_INTEGER : case PARSEOP_STRING_LITERAL : case PARSEOP_BUFFER : case PARSEOP_PACKAGE : ApCheckObjectType ( ThisName -> Info . Name , ReturnValueOp , ThisName -> Info . ExpectedBtypes , ACPI_NOT_PACKAGE_ELEMENT ) ; if ( ReturnValueOp -> Asl . ParseOpcode == PARSEOP_PACKAGE ) { ApCheckPackage ( ReturnValueOp , ThisName ) ; } break ; default : break ; } } }
FUNCTION:    ApCheckPredefinedReturnValue
 PARAMETERS:  Op              - A parse node of type "RETURN".
FUNCTION : ApCheckPredefinedReturnValue PARAMETERS : Op - A parse node of type " RETURN " .
/*
     * Check parent method for a match against the predefined name list.
     *
     * Note: Disable compiler errors/warnings because any errors will be
     * caught when analyzing the parent method. Eliminates duplicate errors.
     */ /* _Lxx/_Exx/_Wxx/_Qxx methods */ /* No return value expected, warn if there is one */ /* No underscore or _Txx or _xxx name not matched */ /* Resource Name or reserved scope name */ /* A _Txx that was not emitted by compiler */ /* Just return, nothing to do */ /* A standard predefined ACPI name */ /* No return value expected, warn if there is one */ /* Get the object returned, it is the next argument */ /* Static data return object - check against expected type */ /* For packages, check the individual package elements */ /*
             * All other ops are very difficult or impossible to typecheck at
             * compile time. These include all Localx, Argx, and method
             * invocations. Also, NAMESEG and NAMESTRING because the type of
             * any named object can be changed at runtime (for example,
             * CopyObject will change the type of the target object.)
             */