TempleOSTS_131005.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:45:52 +02:00
1 parent 1343005a29
commit 2d2a65d572
547 files changed
+33608 -12549

No files matched your search

+170 -182
View File
@@ -1,43 +1,31 @@
U0 StreamPutS(U8 *buf)
//Inss text into the stream of
U0 StreamPrint(U8 *fmt,...)
//Inserts text into the stream of
//characters being compiled. Called
//from withing #exe{} block.
{
U8 *buf=SPrintJoin(NULL,fmt,argc,argv);
CLex *lx=Fs->last_lex;
CStreamBlk *tempe=lx->last_stream_blk;
if (tempe!=&lx->next_stream_blk)
tempe->body=StrAdd(tempe->body,buf);
else
PrintFErr("No exe{} blk\n");
}
U0 StreamPrintF(U8 *src,...)
//Inss text into the stream of
//characters being compiled. Called
//from withing #exe{} block.
{
U8 *buf=SPrintFJoin(NULL,src,argc,argv);
StreamPutS(buf);
PrintErr("No exe{} blk\n");
Free(buf);
}
U8 *CmpStatement(CLex *lx,I64 *type)
U8 *LexStatement2Bin(CLex *lx,I64 *type)
{
I64 size,i,j,k,*result=INVALID_PTR;
CIntermediateCode *tempi;
if (type) *type=IT_I64;
Btr(&lx->flags,Lf_OPT_TRACE_PRESENT);
if (lx->a_depth==2)
CBPush(lx);
CBOutPtrsInit(lx);
CBICAdd(lx,IC_START,0,0); //So we can scan back an instruction
tempi=lx->cbh.cb_last_out_ptr;
LCCPush(lx);
LCCInit(lx);
if (!PrsStatement(lx,NULL)) {
if (tempi!=lx->cbh.cb_last_out_ptr) {
CBICAdd(lx,IC_RETURN_VAL2,0,NULL);
CBICAdd(lx,IC_RET,0,0);
CBICAdd(lx,IC_END,0,0);
if (result=CBCompile(lx,NULL,&size,NULL,type)) {
if (lx->lcc.lcc_root.next!=&lx->lcc.lcc_root) {
LCCAdd(lx,IC_RETURN_VAL2,0,NULL);
LCCAdd(lx,IC_RET,0,0);
if (result=LCCCompile(lx,NULL,&size,NULL,type)) {
if (lx->flags&LF_AOT_COMPILE) {
j=lx->a->ip;
k=(size+7)>>3;
@@ -47,12 +35,11 @@ U8 *CmpStatement(CLex *lx,I64 *type)
result=j;
}
}
} else
LinkedLstDel(lx->cbh.cb_out_first);
} else
LinkedLstDel(lx->cbh.cb_out_first);
} //TODO: else del misc?
} else //TODO: too dangerous to del Misc?
QueDel(&lx->lcc.lcc_root.next);
if (lx->a_depth==2)
CBPop(lx);
LCCPop(lx);
return result;
}
@@ -62,6 +49,7 @@ CExe *CmpJoin(CLex *lx,CHashFun *locals,Bool first_lex,Bool asm_blk=FALSE,
{
CAsmCtrl *a,*old_a=lx->a;
I64 i,j,l;
U8 *ex;
CAsmCodeBlk *tempc;
CExeImportExport *tempe;
Bool okay=TRUE;
@@ -75,7 +63,7 @@ CExe *CmpJoin(CLex *lx,CHashFun *locals,Bool first_lex,Bool asm_blk=FALSE,
lx->a=a=CAlloc(sizeof(CAsmCtrl));
lx->a_depth++;
a->code=CAlloc(sizeof(CAsmCodeBlk));
a->cb=CAlloc(sizeof(CAsmCodeBlk));
a->max_align=1;
a->module_org=INVALID_PTR;
@@ -92,17 +80,17 @@ CExe *CmpJoin(CLex *lx,CHashFun *locals,Bool first_lex,Bool asm_blk=FALSE,
lx->htc.glbl_hash_table->next=Fs->hash_table;
lx->htc.hash_table_lst =asm_hash_alias;
lx->htc.local_var_lst=locals; //Holy C local vars
lx->htc.local_var_lst=locals; //HolyC local vars
try {
if (first_lex)
Lex(lx);
if (lx->flags&LF_AOT_COMPILE) {
while (lx->token!=TK_EOF) {
i=CmpStatement(lx,NULL);
if (i!=INVALID_PTR) {
ex=LexStatement2Bin(lx,NULL);
if (ex!=INVALID_PTR) {
tempe=CAlloc(sizeof(CExeImportExport));
tempe->type=EIE_MAIN;
tempe->ip=i;
tempe->ip=ex;
QueIns(tempe,result->last_ie);
}
if (asm_blk)
@@ -112,8 +100,7 @@ CExe *CmpJoin(CLex *lx,CHashFun *locals,Bool first_lex,Bool asm_blk=FALSE,
PrsStatement(lx,NULL);
AsmGlblsResolve(lx,result);
} catch {
if (Fs->except_argc>0 && Fs->except_argv[0]==EXCEPT_COMPILER &&
!asm_blk) {
if (Fs->except_argc>0 && Fs->except_argv[0]==EXCEPT_COMPILER && !asm_blk) {
if (Fs->except_argc>1 && Fs->except_argv[1]) {
"Compiler exception #%d\n",Fs->except_argv[1];
LexPutPos(lx);
@@ -127,40 +114,40 @@ CExe *CmpJoin(CLex *lx,CHashFun *locals,Bool first_lex,Bool asm_blk=FALSE,
lx->error_cnt=1;
lx->exe_struct=result->parent_exe;
Free(result);
LinkedLstDel(a->code);
LinkedLstDel(a->cb);
result=NULL;
} else {
if (map_name && !cmp_do_not_write_to_dsk)
HashRep(lx->htc.glbl_hash_table,HTG_ALL,map_name,"-r-p",mapfile_drv);
Who("-r",lx->htc.glbl_hash_table,map_name,mapfile_drv);
HashTableDel(lx->htc.local_hash_table);
HashTableDel(lx->htc.glbl_hash_table);
if (!a->num_code_U8s)
result->code=NULL;
if (!a->num_ex_U8s)
result->ex=NULL;
else {
if (lx->flags&LF_AOT_COMPILE)
result->code=MAlloc(a->num_code_U8s);
result->ex=MAlloc(a->num_ex_U8s);
else {
if (a->module_org==INVALID_PTR)
result->code=MAlloc(a->num_code_U8s,Fs->code_heap);
result->ex=MAlloc(a->num_ex_U8s,Fs->code_heap);
else
result->code=a->module_org;
result->ex=a->module_org;
}
result->code_U8s=a->num_code_U8s;
tempc=a->code;
result->ex_U8s=a->num_ex_U8s;
tempc=a->cb;
j=0;
l=a->num_code_U8s;
l=a->num_ex_U8s;
while (tempc) {
i=l;
if (i>ASM_CODE_BLK_SIZE)
i=ASM_CODE_BLK_SIZE;
MemCpy(result->code+j,tempc->body,i);
MemCpy(result->ex+j,tempc->body,i);
j+=i;
l-=i;
tempc=tempc->next;
}
}
LinkedLstDel(a->code);
LinkedLstDel(a->cb);
result->abss=a->abss;
result->heap_glbls=a->heap_glbls;
result->max_align =a->max_align;
@@ -195,103 +182,96 @@ CExe *CmpBuf(U8 *buf,U8 *map_name=NULL,
return result;
}
U0 CmpFixUpJITAsm(CLex *lx,CExe *ex,I64 ip2)
U0 CmpFixUpJITAsm(CLex *lx,CExe *tempx,I64 ip2)
{
I64 i,*str=NULL;
U8 *ptr;
CExeAbsAddr *tempa,*tempa1;
CExeImportExport *tempe,*tempe1;
CHashExport *tempess;
CHashFun *tempf;
CHashGlblVar *tempg;
CHashExport *tempex;
tempa=ex->abss;
tempa=tempx->abss;
while (tempa) {
tempa1=tempa->next;
ptr=tempx->ex+tempa->ip;
nobound_switch (tempa->type) {
case EAA_ADD_U8:
*(ex->code(U8 *)+tempa->ip)(U8 *)+=ip2;
*ptr(U8 *)+=ip2;
break;
case EAA_SUB_U8:
*(ex->code(U8 *)+tempa->ip)(U8 *)-=ip2;
*ptr(U8 *)-=ip2;
break;
case EAA_ADD_U16:
*(ex->code(U8 *)+tempa->ip)(U16 *)+=ip2;
*ptr(U16 *)+=ip2;
break;
case EAA_SUB_U16:
*(ex->code(U8 *)+tempa->ip)(U16 *)-=ip2;
*ptr(U16 *)-=ip2;
break;
case EAA_ADD_U32:
*(ex->code(U8 *)+tempa->ip)(U32 *)+=ip2;
*ptr(U32 *)+=ip2;
break;
case EAA_SUB_U32:
*(ex->code(U8 *)+tempa->ip)(U32 *)-=ip2;
*ptr(U32 *)-=ip2;
break;
case EAA_ADD_U64:
*(ex->code(U8 *)+tempa->ip)(I64 *)+=ip2;
*ptr(I64 *)+=ip2;
break;
case EAA_SUB_U64:
*(ex->code(U8 *)+tempa->ip)(I64 *)-=ip2;
*ptr(I64 *)-=ip2;
break;
}
Free(tempa);
tempa=tempa1;
}
tempe=ex->next_ie;
while (tempe!=&ex->next_ie) {
tempe=tempx->next_ie;
while (tempe!=&tempx->next_ie) {
tempe1=tempe->next;
if (tempe->str) {
Free(str);
str=tempe->str;
}
if (tempe->type<=EIE_LIT_EXPORT) {
tempess=CAlloc(sizeof(CHashExport));
tempess->str=str;
str=NULL;
tempess->type=HTT_EXPORT_SYS_SYM|HTF_LIT;
if (tempe->type==EIE_LIT_EXPORT)
tempess->val=tempe->ip;
else
tempess->val=tempe->ip+ip2;
tempess->src_link=tempe->src_link;
tempe->src_link=NULL;
if (IsReplaceSyms)
HashReplace(tempess,Fs->hash_table);
else
HashAdd(tempess,Fs->hash_table);
SysSymImportsResolve(tempess->str);
} else if (tempe->type<EIE_MAIN) {
if (tempe->str && !(tempess=HashFind(str,Fs->hash_table,HTG_ALL-HTT_IMPORT_SYS_SYM)))
"%S%s\n","ST_UNRESOLVED_REFERENCE",str;
else {
ptr=tempe->ip+ip2;
if (tempess->type & HTT_FUN) {
tempf=tempess;
if (tempe->type & 1)
i=tempf->executable_addr;
switch (tempe->type) {
case EIE_REL_EXPORT:
case EIE_IMM_EXPORT:
tempex=CAlloc(sizeof(CHashExport));
tempex->str=str;
str=NULL;
tempex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
if (tempe->type==EIE_IMM_EXPORT)
tempex->val=tempe->ip;
else
tempex->val=tempe->ip+ip2;
tempex->src_link=tempe->src_link;
tempe->src_link=NULL;
if (IsReplaceSyms)
HashReplace(tempex,Fs->hash_table);
else
HashAdd(tempex,Fs->hash_table);
SysSymImportsResolve(tempex->str);
break;
case EIE_REL_U8...EIE_IMM_U64:
if (tempe->str && !(tempex=HashFind(str,Fs->hash_table,HTG_ALL-HTT_IMPORT_SYS_SYM)))
"%S%s\n","ST_UNRESOLVED_REFERENCE",str;
else {
ptr=tempe->ip+ip2;
if (tempex->type & HTT_FUN)
i=tempex(CHashFun *)->executable_addr;
else if (tempex->type & HTT_GLBL_VAR)
i=tempex(CHashGlblVar *)->data_addr;
else
i=tempf->executable_addr-ex->code;
} else if (tempess->type & HTT_GLBL_VAR) {
tempg=tempess;
if (tempe->type & 1)
i=tempg->data_addr;
else
i=tempg->data_addr-ex->code;
} else {
if (tempe->type & 1)
i=tempess->val;
else
i=tempess->val(U8 *)-ex->code;
i=tempex->val;
nobound_switch (tempe->type) {
case EIE_REL_U8: *ptr(U8 *) =i-ptr-1; break;
case EIE_IMM_U8: *ptr(U8 *) =i; break;
case EIE_REL_U16: *ptr(U16 *)=i-ptr-2; break;
case EIE_IMM_U16: *ptr(U16 *)=i; break;
case EIE_REL_U32: *ptr(U32 *)=i-ptr-4; break;
case EIE_IMM_U32: *ptr(U32 *)=i; break;
case EIE_REL_U64: *ptr(I64 *)=i-ptr-8; break;
case EIE_IMM_U64: *ptr(I64 *)=i; break;
}
}
if (tempe->type<=EIE_LIT_U8)
*ptr(U8 *)+=i;
else if (tempe->type<=EIE_LIT_U16)
*ptr(U16 *)+=i;
else if (tempe->type<=EIE_LIT_U32)
*ptr(U32 *)+=i;
else if (tempe->type<=EIE_LIT_U64)
*ptr(I64 *)+=i;
}
break;
}
Free(tempe->src_link);
Free(tempe);
@@ -299,45 +279,46 @@ U0 CmpFixUpJITAsm(CLex *lx,CExe *ex,I64 ip2)
}
Free(str);
if (!lx->a_depth && Bt(&lx->opts,OPTf_COMPILE_TRACE))
Un(ex->code,ex->code_U8s,64);
Free(ex);
Un(tempx->ex,tempx->ex_U8s,64);
Free(tempx);
}
U0 CmpFixUpAOTAsm(CLex *lx,CExe *ex,I64 ip2)
U0 CmpFixUpAOTAsm(CLex *lx,CExe *tempx,I64 ip2)
{
CAsmCtrl *a=lx->a;
U8 *ptr;
CExeAbsAddr *tempa,*tempa1;
CExeImportExport *tempe,*tempe1;
tempa=ex->abss;
tempa=tempx->abss;
while (tempa) {
tempa1=tempa->next;
tempa->next=a->abss;
ptr=tempx->ex+tempa->ip;
nobound_switch (tempa->type) {
case EAA_ADD_U8:
*(ex->code(U8 *)+tempa->ip)(U8 *)+=ip2;
*ptr(U8 *)+=ip2;
break;
case EAA_SUB_U8:
*(ex->code(U8 *)+tempa->ip)(U8 *)-=ip2;
*ptr(U8 *)-=ip2;
break;
case EAA_ADD_U16:
*(ex->code(U8 *)+tempa->ip)(U16 *)+=ip2;
*ptr(U16 *)+=ip2;
break;
case EAA_SUB_U16:
*(ex->code(U8 *)+tempa->ip)(U16 *)-=ip2;
*ptr(U16 *)-=ip2;
break;
case EAA_ADD_U32:
*(ex->code(U8 *)+tempa->ip)(U32 *)+=ip2;
*ptr(U32 *)+=ip2;
break;
case EAA_SUB_U32:
*(ex->code(U8 *)+tempa->ip)(U32 *)-=ip2;
*ptr(U32 *)-=ip2;
break;
case EAA_ADD_U64:
*(ex->code(U8 *)+tempa->ip)(I64 *)+=ip2;
*ptr(I64 *)+=ip2;
break;
case EAA_SUB_U64:
*(ex->code(U8 *)+tempa->ip)(I64 *)-=ip2;
*ptr(I64 *)-=ip2;
break;
}
a->abss=tempa;
@@ -345,36 +326,49 @@ U0 CmpFixUpAOTAsm(CLex *lx,CExe *ex,I64 ip2)
tempa=tempa1;
}
tempe=ex->next_ie;
while (tempe!=&ex->next_ie) {
tempe=tempx->next_ie;
while (tempe!=&tempx->next_ie) {
tempe1=tempe->next;
QueRem(tempe);
if (tempe->type<=EIE_LIT_EXPORT)
tempe->ip+=ip2;
else if (tempe->type<EIE_MAIN) {
ptr=ex->code(U8 *)+tempe->ip;
if (tempe->type<=EIE_LIT_U8)
*ptr(U8 *)-=ip2;
else if (tempe->type<=EIE_LIT_U16)
ptr=tempx->ex+tempe->ip;
switch (tempe->type) {
case EIE_REL_EXPORT:
case EIE_IMM_EXPORT:
tempe->ip+=ip2;
break;
case EIE_REL_U8:
case EIE_IMM_U8:
*ptr(U8 *) -=ip2;
tempe->ip+=ip2;
break;
case EIE_REL_U16:
case EIE_IMM_U16:
*ptr(U16 *)-=ip2;
else if (tempe->type<=EIE_LIT_U32)
tempe->ip+=ip2;
break;
case EIE_REL_U32:
case EIE_IMM_U32:
*ptr(U32 *)-=ip2;
else if (tempe->type<=EIE_LIT_U64)
tempe->ip+=ip2;
break;
case EIE_REL_U64:
case EIE_IMM_U64:
*ptr(I64 *)-=ip2;
tempe->ip+=ip2;
tempe->ip+=ip2;
break;
}
QueIns(tempe,ex->parent_exe->last_ie);
QueIns(tempe,tempx->parent_exe->last_ie);
tempe=tempe1;
}
Free(ex);
Free(tempx);
}
I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv=0)
{ //Compile file, returns err_cnt
U8 *ptr,*fbuf=NULL,*fbuf2=NULL,*fbuf3=NULL,
*patch_table=MAlloc(0x20000);
CExe *ex;
I64 i,cnt,size=0,error_cnt=0,warning_cnt=0,code_U8s=0;
CExe *tempx;
I64 i,cnt,size=0,error_cnt=0,warning_cnt=0,ex_U8s=0;
CBinFile *bfh;
CExeImportExport *tempe,*tempe1;
CExeAbsAddr *tempa,*tempa1;
@@ -382,26 +376,26 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv=0)
CExeHeapGlbl *temphg,*temphg1;
fbuf=DftExt(filename,"PRJ.Z");
fbuf2=MSPrintF("#include \"%s\"",fbuf);
fbuf2=MPrint("#include \"%s\"",fbuf);
if (map_name)
fbuf3=DftExt(map_name,"MAP.Z");
ex=CmpBuf(fbuf2,fbuf3,&error_cnt,&warning_cnt,mapfile_drv);
tempx=CmpBuf(fbuf2,fbuf3,&error_cnt,&warning_cnt,mapfile_drv);
if (ex) {
code_U8s=ex->code_U8s;
if (tempx) {
ex_U8s=tempx->ex_U8s;
ptr=patch_table;
//See $LK,"CBinFilePatchTableWithoutOrg","MN:CBinFilePatchTableWithoutOrg"$
*ptr++=EIE_MODULE_ALIGNMENT; //See $LK,"Load","MN:Load"$() and $LK,"BinRep","MN:BinRep"$()
*ptr(U32 *)++=ex->max_align;
*ptr(U32 *)++=tempx->max_align;
*ptr++=0;
if (ex->module_org!=INVALID_PTR) {
if (tempx->module_org!=INVALID_PTR) {
//See $LK,"CBinFilePatchTableWithOrg","MN:CBinFilePatchTableWithOrg"$
*ptr++=EIE_MODULE_ORG;
*ptr(U32 *)++=ex->module_org;
*ptr(U32 *)++=tempx->module_org;
*ptr++=0;
}
cnt=0;
tempa=ex->abss;
tempa=tempx->abss;
while (tempa) {
if (!(tempa->type&1))
cnt++;
@@ -411,7 +405,7 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv=0)
*ptr++=EIE_ABS_ADDR;
*ptr(U32 *)++=cnt;
*ptr++=0;
tempa=ex->abss;
tempa=tempx->abss;
while (tempa) {
tempa1=tempa->next;
if (!(tempa->type&1))
@@ -420,7 +414,7 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv=0)
tempa=tempa1;
}
}
temphg=ex->heap_glbls;
temphg=tempx->heap_glbls;
while (temphg) {
temphg1=temphg->next;
cnt=0;
@@ -453,10 +447,10 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv=0)
}
//Do exports first
tempe=ex->next_ie;
while (tempe!=&ex->next_ie) {
tempe=tempx->next_ie;
while (tempe!=&tempx->next_ie) {
tempe1=tempe->next;
if (tempe->type<=EIE_LIT_EXPORT) {
if (tempe->type<=EIE_IMM_EXPORT) {
QueRem(tempe);
*ptr++=tempe->type;
*ptr(U32 *)++=tempe->ip;
@@ -474,8 +468,8 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv=0)
}
//Do imports second
tempe=ex->next_ie;
while (tempe!=&ex->next_ie) {
tempe=tempx->next_ie;
while (tempe!=&tempx->next_ie) {
tempe1=tempe->next;
QueRem(tempe);
*ptr++=tempe->type;
@@ -496,17 +490,17 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv=0)
MemSet(ptr,0,16);
i=ptr-patch_table;
//$LK,"TEMPLEOS_XSUM","FF:::/TempleOS/Kernel/KStart.CPP,TEMPLEOS_XSUM"$ needs 16 ALIGN
size=(sizeof(CBinFile)+code_U8s+i+15)&-16;
size=(sizeof(CBinFile)+ex_U8s+i+15)&-16;
bfh=MAlloc(size);
bfh->jmp=0xEB+256*(sizeof(CBinFile)-2);
#assert sizeof(CBinFile)-2<=MAX_I8
bfh->type=0;
bfh->loader_patch_table_offset=sizeof(CBinFile)+code_U8s;
bfh->loader_patch_table_offset=sizeof(CBinFile)+ex_U8s;
bfh->file_size=size;
bfh->xsum=TEMPLEOS_XSUM;
MemCpy(bfh(U8 *)+sizeof(CBinFile),ex->code,code_U8s);
MemCpy(bfh(U8 *)+sizeof(CBinFile)+code_U8s,patch_table,
size-code_U8s-sizeof(CBinFile));
MemCpy(bfh(U8 *)+sizeof(CBinFile),tempx->ex,ex_U8s);
MemCpy(bfh(U8 *)+sizeof(CBinFile)+ex_U8s,patch_table,
size-ex_U8s-sizeof(CBinFile));
bfh->xsum=ArcXSum(bfh,size);
Free(fbuf2);
if (out_name)
@@ -516,14 +510,14 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv=0)
if (!cmp_do_not_write_to_dsk)
FileWrite(fbuf2,bfh,size);
Free(bfh);
Free(ex->code);
Free(ex);
ExpressionBinDel(tempx->ex);
Free(tempx);
}
Free(patch_table);
Free(fbuf);
Free(fbuf2);
Free(fbuf3);
PrintF(Define("ST_ERRORS_WARNINGS"),error_cnt,warning_cnt,code_U8s,size);
Print(Define("ST_ERRORS_WARNINGS"),error_cnt,warning_cnt,ex_U8s,size);
return error_cnt;
}
@@ -565,10 +559,10 @@ I64 ExePutS(U8 *buf,U8 *filename=NULL,Bool just_load=FALSE,CLexHashTableContext
return result;
}
I64 ExePrintF(U8 *fmt,...)
I64 ExePrint(U8 *fmt,...)
{
I64 result;
U8 *buf=SPrintFJoin(NULL,fmt,argc,argv);
U8 *buf=SPrintJoin(NULL,fmt,argc,argv);
result=ExePutS(buf);
Free(buf);
return result;
@@ -578,7 +572,7 @@ I64 ExeFile(U8 *name,Bool just_load=FALSE)
{
I64 result;
U8 *name2=DftExt(name,"CPP.Z"),
*st=MSPrintF("#include \"%s\";",name2);
*st=MPrint("#include \"%s\";",name2);
result=ExePutS(st,name,just_load);
Free(st);
Free(name2);
@@ -617,10 +611,10 @@ I64 ExePutS2(U8 *buf,U8 *filename=NULL,Bool just_load=FALSE)
return result;
}
I64 ExePrintF2(U8 *fmt,...)
I64 ExePrint2(U8 *fmt,...)
{ //with REPLACE_SYMS
I64 result;
U8 *buf=SPrintFJoin(NULL,fmt,argc,argv);
U8 *buf=SPrintJoin(NULL,fmt,argc,argv);
result=ExePutS2(buf);
Free(buf);
return result;
@@ -630,7 +624,7 @@ I64 ExeFile2(U8 *name,Bool just_load=FALSE)
{ //with REPLACE_SYMS
I64 result;
U8 *name2=DftExt(name,"CPP.Z"),
*st=MSPrintF("#include \"%s\";",name2);
*st=MPrint("#include \"%s\";",name2);
result=ExePutS2(st,name,just_load);
Free(st);
Free(name2);
@@ -656,49 +650,41 @@ I64 ExePutS3(U8 *buf,U8 *filename=NULL,Bool just_load=FALSE)
return result;
}
I64 ExePrintF3(U8 *fmt,...)
I64 ExePrint3(U8 *fmt,...)
{ //throws exceptions
I64 result;
U8 *buf=SPrintFJoin(NULL,fmt,argc,argv);
U8 *buf=SPrintJoin(NULL,fmt,argc,argv);
result=ExePutS3(buf);
Free(buf);
return result;
}
I64 ExeFile3(U8 *name,Bool just_load=FALSE)
{ //throws exceptions
I64 result;
U8 *name2=DftExt(name,"CPP.Z"),
*st=MSPrintF("#include \"%s\";",name2);
*st=MPrint("#include \"%s\";",name2);
result=ExePutS3(st,name,just_load);
Free(st);
Free(name2);
return result;
}
I64 StreamExePutS(U8 *buf)
I64 StreamExePrint(U8 *fmt,...)
{//Suppose you want a value from the stream to be used in an #exe block...
CLexHashTableContext *htc;
U8 *buf=SPrintJoin(NULL,fmt,argc,argv);
I64 result=0;
CLexHashTableContext *htc;
CLex *lx=Fs->last_lex;
if (lx==&Fs->next_lex) {
PutErr;
"Not Compiling\n";
} else {
if (!(lx->flags&LF_EXE_BLK))
LexExcept(lx,"ST_STREAM_EXE_PUTS_NOT_ALLOWED");
LexExcept(lx,"ST_STREAM_EXE_PRINT_NOT_ALLOWED");
if (htc=lx->htc.next)
result=ExePutS(buf,,,htc);
}
return result;
}
I64 StreamExePrintF(U8 *fmt,...)
{
I64 result;
U8 *buf=SPrintFJoin(NULL,fmt,argc,argv);
result=StreamExePutS(buf);
Free(buf);
return result;
}
@@ -716,10 +702,12 @@ U0 CmpInit()
cmp_do_not_write_to_dsk=FALSE;
CmpLoadDefines;
CmpFillTables;
MemSet(&opt_nop,0,sizeof(CIntermediateCode));
opt_nop.ic_class=sys_internal_types[IT_I64];
MemSet(&opt_nop,0,sizeof(CIntermediateCode));
QueInit(&opt_nop);
opt_nop.ic_class=sys_internal_types[IT_I64];
opt_nop.ic_opcode=IC_NOP1;
AsmHashLoad(is_first_compiler);
UnasmHashLoad;
}