definition module CommonObjectToDisk;

import
	State,
	StdEnv;
	
//1.3	
from SymbolTable import LibraryList;
//3.1
/*2.0
from SymbolTable import ::LibraryList;
0.2*/

:: *WriteOutputRecord = {
		file_or_memory	:: !Int
	,	offset			:: !Int
	,	string			:: !{#Char}
	,	file_n			:: !Int
	,	module_n		:: !Int
	,	state			:: !*State
	};

class Target2 a
where
{
	WriteOutput :: !WriteOutputRecord !*a -> (!*State,*a)
};

//write_code_to_pe_files :: !Int !Bool !Int !Int !(!Int,!Int) !State !Bool !*a !*Files -> (!*a,!(!Int,!Int),!State,!*Files) | Target2 a;
write_code_to_pe_files :: !Int !Bool !Int !Int !(!Int,!Int) !State !Bool !*a !*Files -> ((!*a,!(!Int,!Int),!State),!*Files) | Target2 a;
//write_code_to_pe_filesD :: !Int !Bool !Int !Int (!Int,!Int) !State (!Int,!*{#Char},!*File) !*Files -> ((!Int,!*{#Char},!*File),!State,!*Files);
import PlatformLinkOptions;

:: *WriteState = {
		do_relocations	:: !Bool
	,	buffers			:: !*{*{#Char}}
	,	buffers_i		:: !*{#Int}
	,	text_offset		:: !Int
	,	text_buffer		:: !*{#Char}
	};
		
WriteCode :: !*File !*PlatformLinkOptions !*State !*Files -> (!*File,!*PlatformLinkOptions,!*State,!*Files,!*WriteState);
