Changeset 121

Show
Ignore:
Timestamp:
08/21/05 12:54:43 (3 years ago)
Author:
pragma
Message:

added LIDATA support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ddl/RecordCursor.d

    r119 r121  
    5252    } 
    5353     
     54    public void setPosition(uint value){ 
     55        position = value; 
     56    } 
     57     
    5458    public bit hasMore(){ 
    5559        return position < data.length; 
     
    5963        ubyte result = data[position]; 
    6064        position++; 
     65        return result; 
     66    } 
     67     
     68    public ubyte[] getBytes(uint size){ 
     69        ubyte[] result = data[position..position+size]; 
     70        position += size; 
    6171        return result; 
    6272    } 
  • trunk/ddl/ddl.d

    r119 r121  
    11/* 
    22    Copyright (c) 2005 Eric Anderton 
    3     Original (non-DSP version) - Copyright (c) 2004 Kris Bell, Scott Sanders 
    43         
    54    Permission is hereby granted, free of charge, to any person 
     
    3433 
    3534interface DynamicModule{ 
    36     char[][] getRequiredModuleNames(); 
     35    char[][] getDependencies(); 
     36    void resolveDependency(char[] name,void* address); 
    3737    ExportSymbol[] getExports(); 
    38     void resolveImports(DynamicLibraryLoader loader); 
     38    ExportSymbol getExport(char[] name); 
    3939} 
    4040 
    4141interface DynamicLibrary{ 
    4242    ExportSymbol[] getExports(); 
     43    ExportSymbol getSymbol(char[] name); 
    4344    DynamicModule[] getModules(); 
    44      
    45     void resolveImports(DynamicLibraryLoader loader); 
    46     void init(); 
    4745} 
    4846 
  • trunk/ddl/omfloader.d

    r120 r121  
    4242private import RecordCursor; 
    4343private import OMFException; 
     44 
    4445 
    4546struct Segment{ 
     
    403404        } 
    404405    } 
    405  
    406     // add raw data to a segment    
    407     protected void parseLogicalEnumeratedData(RecordCursor cursor){     
     406     
     407     
     408    protected void parseLogicalEnumeratedData(RecordCursor cursor){ 
    408409        uint segmentIndex = cursor.getIndex(); 
    409410        uint offsetAddress = cursor.getVWord(); 
    410411         
    411         //read raw data and overlay segment data with these bytes 
    412412        ubyte[] rawData = cursor.getRemainder();  
    413         this.segments[segmentIndex].data[offsetAddress..rawData.length] = rawData; 
     413        this.segments[segmentIndex].data[offsetAddress..offsetAddress+rawData.length] = rawData; 
    414414 
    415415        this.enumData.segmentIndex = segmentIndex; 
    416416        this.enumData.offset = offsetAddress; 
    417417         
    418         debug writefln("enum data: segmentIndex %d | offset %d | length %d",segmentIndex,offsetAddress,rawData.length); 
    419     } 
     418        debug writefln("enum data: segmentIndex %d | offset %d | length %d",segmentIndex,offsetAddress,rawData.length);      
     419    }    
     420 
     421    // add raw data to a segment     
     422    protected void parseLogicalIteratedData(RecordCursor cursor){    
     423        uint segmentIndex = cursor.getIndex(); 
     424        uint offsetAddress = cursor.getVWord(); 
     425        ubyte[] rawData; 
     426         
     427        debug writefln("LIDATA: %s seg %d offset %d",cursor.getData(),segmentIndex,offsetAddress); 
     428 
     429        // define recursive parser 
     430        ubyte[] parseBlock(){ 
     431            uint repeatCount = cursor.getVWord(); 
     432            uint blockCount = cursor.getWord(); 
     433            ubyte[] result; 
     434             
     435            //debug writefln("parseblock: repeat %d block count %d",repeatCount,blockCount); 
     436             
     437            //build raw data using a repeated block 
     438            if(blockCount == 0){ 
     439                ubyte count = cursor.getByte(); 
     440                                 
     441                ubyte[] data = cursor.getBytes(count); 
     442 
     443                for(uint i=0; i<repeatCount; i++){ 
     444                    result ~= data; 
     445                } 
     446            } 
     447            // recursion 
     448            else{ 
     449                uint startPosition = cursor.getPosition(); 
     450                for(uint i=0; i<blockCount; i++){ 
     451                    cursor.setPosition(startPosition); // reset cursor so recursion works correctly 
     452                    result = parseBlock(); 
     453                } 
     454            } 
     455             
     456            // use the repeat count repeat rawData  
     457            ubyte[] tempData; 
     458            for(uint i=0; i<repeatCount; i++){ 
     459                tempData ~= result; 
     460            } 
     461            // use rawData to store the result of the repeat 
     462            return result; 
     463        } 
     464         
     465        // multiple data blocks 
     466        while(cursor.hasMore()){         
     467            rawData ~= parseBlock(); 
     468        } 
     469         
     470        debug writefln("rawData: %d %s",rawData.length,rawData); 
     471         
     472        this.segments[segmentIndex].data[offsetAddress..offsetAddress+rawData.length] = rawData; 
     473         
     474        this.enumData.segmentIndex = segmentIndex; 
     475        this.enumData.offset = offsetAddress; 
     476         
     477        debug writefln("iterated data: segmentIndex %d | offset %d | length %d",segmentIndex,offsetAddress,rawData.length); 
     478    } 
     479 
    420480     
    421481    protected void parseExternalNames(RecordCursor cursor){ 
     
    532592            case 0x9C: parseFixupData(cursor); break; 
    533593            case 0xA0: parseLogicalEnumeratedData(cursor); break; 
     594            case 0xA2: parseLogicalIteratedData(cursor); break; 
    534595            case 0xBC: parseExternalNames(cursor); break; 
    535596            case 0xC2: parseCommonData(cursor); break; 
     
    613674        resolveInternals(); 
    614675         
    615          
     676        /+ 
    616677        debug{ 
    617678            // read in foobar.x and display its value 
     
    655716            writef("]\n"); 
    656717             
    657             writefln("add: %d",add(42,69)); 
    658              
    659         }        
     718            writefln("add: %d",add(42,69));          
     719        }+/      
    660720    } 
    661721}