renamed Interp.Compile to Interp.CompileText
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ee152519a8
commit
b80bea5f73
36
pas/hcl.pas
36
pas/hcl.pas
@ -45,7 +45,7 @@ type
|
|||||||
{$define HCL_CCI_BUF_LEN := 2048}
|
{$define HCL_CCI_BUF_LEN := 2048}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{$packrecords c}
|
//{$packrecords c}
|
||||||
CciArgPtr = ^CciArg;
|
CciArgPtr = ^CciArg;
|
||||||
CciArg = record (* this record must follow the public part of hcl_io_cciarg_t in hcl.h *)
|
CciArg = record (* this record must follow the public part of hcl_io_cciarg_t in hcl.h *)
|
||||||
name: pwidechar;
|
name: pwidechar;
|
||||||
@ -55,7 +55,7 @@ type
|
|||||||
xlen: System.SizeUint;
|
xlen: System.SizeUint;
|
||||||
includer: CciArgPtr;
|
includer: CciArgPtr;
|
||||||
end;
|
end;
|
||||||
{$packrecords normal}
|
//{$packrecords normal}
|
||||||
|
|
||||||
Interp = class
|
Interp = class
|
||||||
protected
|
protected
|
||||||
@ -68,10 +68,10 @@ type
|
|||||||
procedure Ignite(heapsize: System.SizeUint);
|
procedure Ignite(heapsize: System.SizeUint);
|
||||||
procedure AddBuiltinPrims();
|
procedure AddBuiltinPrims();
|
||||||
procedure CompileFile(filename: pansichar);
|
procedure CompileFile(filename: pansichar);
|
||||||
procedure Compile(text: pansichar);
|
procedure CompileText(text: pansichar);
|
||||||
procedure Compile(text: pansichar; len: System.SizeUint);
|
procedure CompileText(text: pansichar; len: System.SizeUint);
|
||||||
procedure Compile(text: pwidechar);
|
procedure CompileText(text: pwidechar);
|
||||||
procedure Compile(text: pwidechar; len: System.SizeUint);
|
procedure CompileText(text: pwidechar; len: System.SizeUint);
|
||||||
procedure Execute();
|
procedure Execute();
|
||||||
|
|
||||||
protected
|
protected
|
||||||
@ -255,7 +255,7 @@ begin
|
|||||||
case cmd of
|
case cmd of
|
||||||
IO_OPEN: begin
|
IO_OPEN: begin
|
||||||
self := handle_to_self(handle);
|
self := handle_to_self(handle);
|
||||||
if arg^.includer <> nil then
|
if (arg^.includer <> nil) and (SysUtils.CompareStr(self.basedir, '') <> 0) then
|
||||||
name := SysUtils.ConcatPaths([self.basedir, UTF8Encode(arg^.name)])
|
name := SysUtils.ConcatPaths([self.basedir, UTF8Encode(arg^.name)])
|
||||||
else
|
else
|
||||||
name := System.UTF8Encode(arg^.name);
|
name := System.UTF8Encode(arg^.name);
|
||||||
@ -275,15 +275,10 @@ begin
|
|||||||
SysUtils.FileClose(f);
|
SysUtils.FileClose(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
IO_READ: begin
|
|
||||||
hcl_seterrnum(handle, 999); (* TODO: change error code to ENOIMPL *)
|
|
||||||
exit(-1);
|
|
||||||
end;
|
|
||||||
|
|
||||||
IO_READ_BYTES: begin
|
IO_READ_BYTES: begin
|
||||||
f := System.THandle(arg^.handle);
|
f := System.THandle(arg^.handle);
|
||||||
len := SysUtils.FileRead(f, arg^.buf, System.SizeOf(arg^.buf));
|
len := SysUtils.FileRead(f, arg^.buf, System.SizeOf(arg^.buf)); (* use SizeOf a widechar buffer as it needs to fill it with bytes *)
|
||||||
//len := SysUtils.FileRead(f, arg^.buf, 1);
|
|
||||||
if len <= -1 then begin
|
if len <= -1 then begin
|
||||||
hcl_seterrbmsg(handle, hcl_syserrstrb(handle, 0, err, nil, 0), pansichar(SysUtils.SysErrorMessage(err)));
|
hcl_seterrbmsg(handle, hcl_syserrstrb(handle, 0, err, nil, 0), pansichar(SysUtils.SysErrorMessage(err)));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@ -296,6 +291,7 @@ begin
|
|||||||
;
|
;
|
||||||
|
|
||||||
(* the following operations are prohibited on the code input stream:
|
(* the following operations are prohibited on the code input stream:
|
||||||
|
IO_READ:
|
||||||
IO_WRITE:
|
IO_WRITE:
|
||||||
IO_WRITE_BYTES:
|
IO_WRITE_BYTES:
|
||||||
*)
|
*)
|
||||||
@ -321,7 +317,7 @@ label
|
|||||||
oops;
|
oops;
|
||||||
begin
|
begin
|
||||||
f := SysUtils.FileOpen(filename, SysUtils.fmOpenRead);
|
f := SysUtils.FileOpen(filename, SysUtils.fmOpenRead);
|
||||||
if f <= -1 then begin
|
if f = System.THandle(-1) then begin
|
||||||
errmsg := 'failed to open file - ' + filename;
|
errmsg := 'failed to open file - ' + filename;
|
||||||
goto oops;
|
goto oops;
|
||||||
end;
|
end;
|
||||||
@ -374,12 +370,12 @@ oops:
|
|||||||
raise Exception.Create(errmsg);
|
raise Exception.Create(errmsg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Interp.Compile(text: pansichar);
|
procedure Interp.CompileText(text: pansichar);
|
||||||
begin
|
begin
|
||||||
self.Compile(text, SysUtils.Strlen(text));
|
self.CompileText(text, SysUtils.Strlen(text));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Interp.Compile(text: pansichar; len: System.SizeUint);
|
procedure Interp.CompileText(text: pansichar; len: System.SizeUint);
|
||||||
var
|
var
|
||||||
errnum: integer;
|
errnum: integer;
|
||||||
errmsg: string;
|
errmsg: string;
|
||||||
@ -413,12 +409,12 @@ begin
|
|||||||
hcl_detachccio(self.handle);
|
hcl_detachccio(self.handle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Interp.Compile(text: pwidechar);
|
procedure Interp.CompileText(text: pwidechar);
|
||||||
begin
|
begin
|
||||||
self.Compile(text, SysUtils.Strlen(text));
|
self.CompileText(text, SysUtils.Strlen(text));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Interp.Compile(text: pwidechar; len: System.SizeUint);
|
procedure Interp.CompileText(text: pwidechar; len: System.SizeUint);
|
||||||
var
|
var
|
||||||
errnum: integer;
|
errnum: integer;
|
||||||
errmsg: string;
|
errmsg: string;
|
||||||
|
@ -22,10 +22,10 @@ begin
|
|||||||
//x.AttachUDIO();
|
//x.AttachUDIO();
|
||||||
|
|
||||||
(*
|
(*
|
||||||
x.Compile(pwidechar('(printf "hello 동키콩\n")'));
|
x.CompileText(pwidechar('(printf "hello 동키콩\n")'));
|
||||||
x.Compile('(printf "hello 동키콩월드\n") ');
|
x.CompileText('(printf "hello 동키콩월드\n") ');
|
||||||
x.Compile('(동가리오 := 20)');
|
x.CompileText('(동가리오 := 20)');
|
||||||
x.Compile('(printf "%d %d\n" 동가리오 (+ 동가리오 동가리오))');
|
x.CompileText('(printf "%d %d\n" 동가리오 (+ 동가리오 동가리오))');
|
||||||
|
|
||||||
x.Compile(pwidechar('(printf "%d %d\n" 동가리오 (동가리오 * 동가리오))'#10'printf "hello, world\n";;;'#10));
|
x.Compile(pwidechar('(printf "%d %d\n" 동가리오 (동가리오 * 동가리오))'#10'printf "hello, world\n";;;'#10));
|
||||||
*)
|
*)
|
||||||
|
Loading…
Reference in New Issue
Block a user