added primitive code to compile the 'if' expression

This commit is contained in:
hyunghwan.chung
2017-01-18 17:17:05 +00:00
parent 4a4d40dea1
commit 40ba50fc53
7 changed files with 386 additions and 90 deletions

View File

@ -406,9 +406,16 @@ class UndefinedObject(Apex)
pooldic ErrorCode
{
(* migrate it into Error class *)
#NONE := error(0).
#GENERIC := error(1).
#NOENT := error(2).
#NONE := error(0).
#GENERIC := error(1).
#NOIMPL := error(2).
#SYSERR := error(3).
#INTERN := error(4).
#SYSMEM := error(5).
#OOMEM := error(6).
#INVAL := error(7).
#NOENT := error(8).
(* add more items... *)
}
class Error(Apex)

View File

@ -514,4 +514,4 @@ extend Apex
{
^Association new key: self value: object
}
}
}

View File

@ -39,7 +39,7 @@ dcl obj.
class MyObject(Object)
{
method(#class) main
method(#class) mainxx
{
| d a ffi |
@ -85,6 +85,7 @@ class MyObject(Object)
] on: Exception do: [:ex | ('Exception caught - ' & ex asString) dump ].*)
ffi := FFI new: '/lib64/libc.so.6'.
(*
(ffi isError)
ifTrue: [System logNl: 'cannot open libc.so' ]
ifFalse: [
@ -92,6 +93,51 @@ class MyObject(Object)
(ffi call: #printf signature: 's|iis)i' arguments: #(S'A=>%d B=>%d Hello, world %s\n' 1 2 'fly away')) dump.
(ffi call: #printf signature: 's|iis)i' arguments: #(S'A=>%d B=>%d Hello, world %s\n' 1 2 'jump down')) dump.
ffi close.
]
].
*)
if (ffi isError)
{
System logNl: 'cannot open libc.so'
}
else
{
(ffi call: #getpid signature: ')i' arguments: nil) dump.
(ffi call: #printf signature: 's|iis)i' arguments: #(S'A=>%d B=>%d Hello, world %s\n' 1 2 'fly away')) dump.
(ffi call: #printf signature: 's|iis)i' arguments: #(S'A=>%d B=>%d Hello, world %s\n' 1 2 'jump down')) dump.
ffi close.
}.
(('abcd' == 'abcd') ifTrue: [1] ifFalse: [2]) dump.
}
method(#class) main
{
|a k|
a :=
if ([System logNl: 'xxxx'. 'abcd' == 'bcde'. false] value)
{
System logNl: 'XXXXXXXXX'.
1111
}
elsif ('abcd' ~= 'abcd')
{
System logNl: 'second if'.
}
elsif ([k := 20. System logNl: 'k => ' & (k asString). k + 20. true] value)
{
System logNl: 'THIRID forever.............' & (k asString)
}
elsif (true = true)
{
System logNl: 'forever.............'
}
else
{
System logNl: 'NO MATCH'.
[true] value.
}.
a dump.
System logNl: 'DONE DONE DONE...'.
}
}