void Class_Object_Init ( Word * word, Namespace * ns ) { DebugShow_Off ; Stack * nsstack = _Context_->Compiler0->NamespacesStack ; Stack_Init ( nsstack ) ; // !! ?? put this in Compiler ?? !! // init needs to be done by the most super class first successively down to the current class do { Word * initWord ; if ( ( initWord = Word_FindInOneNamespace ( ns, ( byte* ) "init" ) ) ) { _Stack_Push ( nsstack, ( int32 ) initWord ) ; } ns = ns->ContainingNamespace ; } while ( ns ) ; int32 i, * svDsp = Dsp ; //DebugShow_Off ; SetState ( _Debugger_, DEBUG_SHTL_OFF, true ) ; for ( i = Stack_Depth ( nsstack ) ; i > 0 ; i -- ) { _Push ( ( int32 ) * word->W_PtrToValue ) ; Word * initWord = ( Word* ) _Stack_Pop ( nsstack ) ; _Word_Eval ( initWord ) ; } Dsp = svDsp ; // this seems a little too presumptive -- a finer tuned stack adjust maybe be more correct SetState ( _Debugger_, DEBUG_SHTL_OFF, false ) ; //DebugShow_StateRestore ; }
status_t DwarfExpressionEvaluator::Push(target_addr_t value) { try { _Push(value); return B_OK; } catch (const EvaluationException& exception) { return B_BAD_VALUE; } catch (const std::bad_alloc& exception) { return B_NO_MEMORY; } }
status_t DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size, ValueLocation& _location) { _location.Clear(); // the empty expression is a valid one if (size == 0) { ValuePieceLocation piece; piece.SetToUnknown(); piece.SetSize(0); return _location.AddPiece(piece) ? B_OK : B_NO_MEMORY; } fDataReader.SetTo(expression, size, fContext->AddressSize()); // parse the first (and maybe only) expression try { // push the object address, if any target_addr_t objectAddress; if (fContext->GetObjectAddress(objectAddress)) _Push(objectAddress); ValuePieceLocation piece; status_t error = _Evaluate(&piece); if (error != B_OK) return error; // if that's all, it's only a simple expression without composition if (fDataReader.BytesRemaining() == 0) { if (!piece.IsValid()) piece.SetToMemory(_Pop()); piece.SetSize(0); return _location.AddPiece(piece) ? B_OK : B_NO_MEMORY; } // there's more, so it must be a composition operator uint8 opcode = fDataReader.Read<uint8>(0); if (opcode == DW_OP_piece) { piece.SetSize(fDataReader.ReadUnsignedLEB128(0)); } else if (opcode == DW_OP_bit_piece) { uint64 bitSize = fDataReader.ReadUnsignedLEB128(0); piece.SetSize(bitSize, fDataReader.ReadUnsignedLEB128(0)); } else return B_BAD_DATA; // If there's a composition operator, there must be at least two // simple expressions, so this must not be the end. if (fDataReader.BytesRemaining() == 0) return B_BAD_DATA; } catch (const EvaluationException& exception) { WARNING("DwarfExpressionEvaluator::EvaluateLocation(): %s\n", exception.message); return B_BAD_VALUE; } catch (const std::bad_alloc& exception) { return B_NO_MEMORY; } // parse subsequent expressions (at least one) while (fDataReader.BytesRemaining() > 0) { // Restrict the data reader to the remaining bytes to prevent jumping // back. fDataReader.SetTo(fDataReader.Data(), fDataReader.BytesRemaining(), fDataReader.AddressSize()); try { // push the object address, if any target_addr_t objectAddress; if (fContext->GetObjectAddress(objectAddress)) _Push(objectAddress); ValuePieceLocation piece; status_t error = _Evaluate(&piece); if (error != B_OK) return error; if (!piece.IsValid()) piece.SetToMemory(_Pop()); // each expression must be followed by a composition operator if (fDataReader.BytesRemaining() == 0) return B_BAD_DATA; uint8 opcode = fDataReader.Read<uint8>(0); if (opcode == DW_OP_piece) { piece.SetSize(fDataReader.ReadUnsignedLEB128(0)); } else if (opcode == DW_OP_bit_piece) { uint64 bitSize = fDataReader.ReadUnsignedLEB128(0); piece.SetSize(bitSize, fDataReader.ReadUnsignedLEB128(0)); } else return B_BAD_DATA; } catch (const EvaluationException& exception) { WARNING("DwarfExpressionEvaluator::EvaluateLocation(): %s\n", exception.message); return B_BAD_VALUE; } catch (const std::bad_alloc& exception) { return B_NO_MEMORY; } } return B_OK; }