aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2014-01-06 23:13:21 +0100
committerDrahflow <drahflow@gmx.de>2014-01-06 23:13:21 +0100
commit90d664bc9e77530113c9a65bd02bae4667a2c25c (patch)
tree289e69b262ef72e09816981817e48d24aeec9a31
parentdef28d4cbac907f45ad083f01a34aca5f1c78fe8 (diff)
streq -> eq
-rw-r--r--compiler/elymasAsm.ey2
-rw-r--r--compiler/elymasAsmOps.ey21
-rw-r--r--compiler/elymasGlobal.ey139
-rw-r--r--compiler/elymasLexer.ey4
-rw-r--r--compiler/elymasTokenize.ey2
-rw-r--r--compiler/standardClient.ey6
-rw-r--r--elymas/lib/sys/opt.ey70
-rw-r--r--elymas/lib/sys/so.ey22
-rw-r--r--examples/working-compiler/grammar-pre.test2
-rw-r--r--examples/working-loaded/httpServer.test4
-rw-r--r--examples/working/macro.ey2
-rw-r--r--examples/working/streq_autoloop.ey4
-rw-r--r--interpreter/ElymasGlobal.pm17
-rw-r--r--notes44
14 files changed, 194 insertions, 145 deletions
diff --git a/compiler/elymasAsm.ey b/compiler/elymasAsm.ey
index 1fcdd35..b5099ac 100644
--- a/compiler/elymasAsm.ey
+++ b/compiler/elymasAsm.ey
@@ -7,7 +7,7 @@
# hex decoding
{
"(.)(.)" regex { } { "not a valid hex-string" die } ? *
- { { streq }_ [ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F" ] -01 index }
+ { { eq }_ [ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F" ] -01 index }
-20*10* 16 mul add
} "%" defq
diff --git a/compiler/elymasAsmOps.ey b/compiler/elymasAsmOps.ey
index ed02242..f5de4b9 100644
--- a/compiler/elymasAsmOps.ey
+++ b/compiler/elymasAsmOps.ey
@@ -52,7 +52,7 @@
} /rex deff
{ ==mem ==reg
- mem [ /spl /sp /esp /rsp /bpl /bp /ebp /rbp ] streq any {
+ mem [ /spl /sp /esp /rsp /bpl /bp /ebp /rbp ] eq any {
"modrm00 not possible on rsp / rbp and their partial registers" die
} rep
@@ -62,7 +62,7 @@
} /modrm00 deff
{ ==mem ==reg
- mem [ /spl /sp /esp /rsp ] streq any {
+ mem [ /spl /sp /esp /rsp ] eq any {
# actually encode sib with rsp index register (to get it ignored)
%40
/sib regno %07 band add
@@ -80,7 +80,7 @@
} /modrm01 deff
{ ==mem ==reg
- mem [ /spl /sp /esp /rsp ] streq any {
+ mem [ /spl /sp /esp /rsp ] eq any {
# actually encode sib with rsp index register (to get it ignored)
%80
/sib regno %07 band add
@@ -104,8 +104,8 @@
} /modrm11 deff
{ ==base ==idx ==scale
- idx [ /spl /sp /esp /rsp ] streq any { "sib cannot encode rsp as index" die } rep
- base [ /bpl /bp /ebp /rbp ] streq any { "sib cannot encode rbp as base" die } rep
+ idx [ /spl /sp /esp /rsp ] eq any { "sib cannot encode rsp as index" die } rep
+ base [ /bpl /bp /ebp /rbp ] eq any { "sib cannot encode rbp as base" die } rep
scale _ 0 gt not { "invalid scale chosen for sib" die } rep
8 le not { "invalid scale chosen for sib" die } rep
@@ -1207,6 +1207,17 @@ memoryAddressingVariants keys { ==variant memoryAddressingVariants variant . =*p
i imm8
} /testbImmReg deff
+memoryAddressingVariants keys { ==variant memoryAddressingVariants variant . =*parse
+ { parse ==mem ==i
+ i 256 lt not { "Imm8 too large" die } rep
+
+ mem .base regno %07 gt mem .idx regno %07 gt or { 0 /none mem .idx mem .base rex } rep
+ %F6
+ /zero mem .encode
+ i imm8
+ } /testbImm variant defOp
+} each
+
{ ==dst ==src
dst bit64assert
src bit64assert
diff --git a/compiler/elymasGlobal.ey b/compiler/elymasGlobal.ey
index 2e5e098..01db3b8 100644
--- a/compiler/elymasGlobal.ey
+++ b/compiler/elymasGlobal.ey
@@ -506,10 +506,10 @@
/rbp /rsi :cmovcqRegReg
60 /rsi :shrqImm8Reg # sil = type of concrete argument
- /al /sil :cmpbRegReg
- /typedNonCommon :jnzLbl8 # non-equal types
+ %0E /sil :testbImmReg
+ /typedNonCommon :jnzLbl8 # non-scalar concrete type
%0E /al :testbImmReg
- /typedNonCommon :jnzLbl8 # non-trivial types
+ /typedNonCommon :jnzLbl8 # non-scalar abstract type
8 /rdi :addqImm8Reg
8 /rbx :addqImm8Reg
@@ -2543,24 +2543,83 @@
%01 %00 %00 %00 %00 %00 %00 %80 # unboxed 1
] /t11t1 defv
- [
- %20 %00 %00 %00 %00 %00 %00 %10
- %00 %00 %00 %00 %00 %00 %00 %00
- %01 %00 %00 %00 %00 %00 %00 %00
- %61 %00 %00 %00 %00 %00 %00 %00
- ] /ta defv
-
- [
- %30 %00 %00 %00 %00 %00 %00 %80
- %02 %00 %00 %00 %00 %00 %00 %00
- /taat1 /ta ::linkAbs64
- /taat1 /ta ::linkAbs64
- %01 %00 %00 %00 %00 %00 %00 %00
- %01 %00 %00 %00 %00 %00 %00 %80 # unboxed 1
- ] /taat1 defv
+ # [
+ # %20 %00 %00 %00 %00 %00 %00 %10
+ # %00 %00 %00 %00 %00 %00 %00 %00
+ # %01 %00 %00 %00 %00 %00 %00 %00
+ # %61 %00 %00 %00 %00 %00 %00 %00
+ # ] /ta defv
+
+ # [
+ # %30 %00 %00 %00 %00 %00 %00 %80
+ # %02 %00 %00 %00 %00 %00 %00 %00
+ # /taat1 /ta ::linkAbs64
+ # /taat1 /ta ::linkAbs64
+ # %01 %00 %00 %00 %00 %00 %00 %00
+ # %01 %00 %00 %00 %00 %00 %00 %80 # unboxed 1
+ # ] /taat1 defv
> _ =globalTypes { defv }' ::allocateOffsetStruct
<
+ # equality on ints and strings
+ [[
+ /rbx :popqReg
+
+ /rdx :popqReg
+ /rdi :popqReg
+ 63 /rdx :btqImm8Reg
+ /intCase :jcLbl8
+ 63 /rdi :btqImm8Reg
+ /intCase :jcLbl8
+ %F0 7 /rdx :testbImmMemDisp8
+ /intCase :jzLbl8
+ %F0 7 /rdi :testbImmMemDisp8
+ /intCase :jzLbl8
+
+ 16 /rdx /rsi :movqMemDisp8Reg
+ 16 /rdi /rcx :movqMemDisp8Reg
+
+ /rsi /rcx :cmpqRegReg
+ /nonEqualStr :jneLbl8
+
+ 24 /rdx /rsi :leaqMemDisp8Reg
+ 24 /rdi /rdi :leaqMemDisp8Reg
+
+ :repz :cmpsb
+ /nonEqualStr :jneLbl8
+
+ /rdx /rdx :xorqRegReg
+ /rdx :incqReg
+ /done :jmpLbl8
+
+ @nonEqualStr
+ /rdx /rdx :xorqRegReg
+
+ @done
+ 63 /rdx :btsqImm8Reg
+ /rdx :pushqReg
+
+ /rbx :pushqReg
+ :retn
+
+ @intCase
+
+ /rdi ::unboxInteger
+ /rdx ::unboxInteger
+
+ /rax /rax :xorqRegReg
+ /rdi /rdx :cmpqRegReg
+ /nonEqual :jnzLbl8
+ /rax :incqReg
+ @nonEqual
+
+ 63 /rax :btsqImm8Reg
+ /rax :pushqReg
+
+ /rbx :pushqReg
+ :retn
+ ]] /eyeq defv
+
# arithmetic functions on ints
[ /rcx /rdx :addqRegReg ] makeArith /eyadd defv
[ /rcx /rdx :subqRegReg ] makeArith /eysub defv
@@ -2573,13 +2632,6 @@
1 /rsi :movqImmReg
/rdx /rcx :cmpqRegReg
/rsi /rdx :movqRegReg
- /rdi /rdx :cmovnzqRegReg
- ] makeArith /eyeq defv
- [
- /rdi /rdi :xorqRegReg
- 1 /rsi :movqImmReg
- /rdx /rcx :cmpqRegReg
- /rsi /rdx :movqRegReg
/rdi /rdx :cmovzqRegReg
] makeArith /eyneq defv
[
@@ -2661,41 +2713,6 @@
> _ =globalT11t1Functions { defv }' ::allocateOffsetStruct
<
- [[
- /rbx :popqReg
-
- /rdx :popqReg
- /rdi :popqReg
-
- 16 /rdx /rsi :movqMemDisp8Reg
- 16 /rdi /rcx :movqMemDisp8Reg
-
- /rsi /rcx :cmpqRegReg
- /nonEqual :jneLbl8
-
- 24 /rdx /rsi :leaqMemDisp8Reg
- 24 /rdi /rdi :leaqMemDisp8Reg
-
- :repz :cmpsb
- /nonEqual :jneLbl8
-
- /rdx /rdx :xorqRegReg
- /rdx :incqReg
- /done :jmpLbl8
-
- @nonEqual
- /rdx /rdx :xorqRegReg
-
- @done
- 63 /rdx :btsqImm8Reg
- /rdx :pushqReg
-
- /rbx :pushqReg
- :retn
- ]] /eystreq defv
- > _ =globalTaat1Functions { defv }' ::allocateOffsetStruct
-
- <
# 0 -> integer
# 0 <- the bitwise negated integer
[[
@@ -2832,7 +2849,6 @@
globalMacros keys len add
globalT11t1Functions keys len add
globalT1t1Functions keys len add
- globalTaat1Functions keys len add
/rdi :movqImmReg
/rsi /rsi :xorqRegReg
::internalAllocateScope /rax :movqImmReg
@@ -2846,7 +2862,6 @@
globalMacros keys eydefq { | }' createScopeEntries
globalT11t1Functions keys eydeffd t11t1 { | }' createTypedScopeEntries
globalT1t1Functions keys eydeffd t1t1 { | }' createTypedScopeEntries
- globalTaat1Functions keys eydeffd taat1 { | }' createTypedScopeEntries
] :execute
{ ==name
diff --git a/compiler/elymasLexer.ey b/compiler/elymasLexer.ey
index 65df806..4226f06 100644
--- a/compiler/elymasLexer.ey
+++ b/compiler/elymasLexer.ey
@@ -9,7 +9,7 @@
{ 0 ==result
{ "(.)(.*)" regex } {
- { streq }_ digits -01 index result 10 mul add =result
+ { eq }_ digits -01 index result 10 mul add =result
} loop
result
}
@@ -55,7 +55,7 @@
{ /input defv
"" {
4096 input .read cat
- _ "" streq not
+ _ "" eq not
} {
{ _ "([^\\n]*)\\n(.*)" regex } { -102 -- TOKINT TOKSTR TOKID elymas .tokenize {
_ .handle
diff --git a/compiler/elymasTokenize.ey b/compiler/elymasTokenize.ey
index ef938d0..1483b16 100644
--- a/compiler/elymasTokenize.ey
+++ b/compiler/elymasTokenize.ey
@@ -4,7 +4,7 @@
{ ==TOKID ==TOKSTR ==TOKINT
" " cat
{ < /handle deff /value defv > } /token deff
- [ -01 { _ "" streq not } {
+ [ -01 { _ "" eq not } {
0 ==matched { =*f matched { -- } { { 1 =matched f } rxparse } ? * } /parse deffst
{ "^ +(.*)" regex } { } parse
diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey
index 2288159..1fb102f 100644
--- a/compiler/standardClient.ey
+++ b/compiler/standardClient.ey
@@ -443,7 +443,7 @@
{ =*f "" ==buffer
{
buffer 4096 read cat =buffer
- buffer "" streq not
+ buffer "" eq not
} {
buffer "\n" str .split ==lines
0 lines len 1 sub range {
@@ -572,8 +572,8 @@
{ 2 laterType * 1 neg neq }
{ laterType 1 }
- # General integers co-iterate iff their binary and results in non-zero
- { 0 earlierType * 0 laterType * band 0 neq }
+ # General integers co-iterate iff equal
+ { 0 earlierType * 0 laterType * eq }
{ earlierType 1 }
{ 1 }
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey
index a59886f..e0fc06e 100644
--- a/elymas/lib/sys/opt.ey
+++ b/elymas/lib/sys/opt.ey
@@ -155,9 +155,9 @@
{ ==e
[
- 0 e * STATICTYPED streq { 4 e * sys .typed .type 0 eq }' andif
- 0 e * PUSH streq { 1 e * sys .typed .type 0 eq }' andif
- 0 e * STRINGSTAR streq
+ 0 e * STATICTYPED eq { 4 e * sys .typed .type 0 eq }' andif
+ 0 e * PUSH eq { 1 e * sys .typed .type 0 eq }' andif
+ 0 e * STRINGSTAR eq
] any
} /holdsInt deffd
@@ -167,11 +167,11 @@
{ _ ==logic
logic { ==entry 0 entry * ==action
[
- { action CALL streq { 1 entry * "<" | ::rawCodeAddress eq }' andif }' {
+ { action CALL eq { 1 entry * "<" | ::rawCodeAddress eq }' andif }' {
1 =containsScopeModifications
}
- { action CALL streq { 1 entry * ">" | ::rawCodeAddress eq }' andif }' {
+ { action CALL eq { 1 entry * ">" | ::rawCodeAddress eq }' andif }' {
1 =containsScopeModifications
}
] conds
@@ -182,7 +182,7 @@
[ NOP ] ==last
[ logic { ==entry 0 entry * ==action
[
- { action CALL streq { 1 entry * "|" | ::rawCodeAddress eq }' andif { 0 last * PUSH streq }' andif }' {
+ { action CALL eq { 1 entry * "|" | ::rawCodeAddress eq }' andif { 0 last * PUSH eq }' andif }' {
1 last * ::rawObject ==constant
constant executingScope sys .resolveInfo {
@@ -211,7 +211,7 @@
[ NOP ] ==last
[ logic { ==entry 0 entry * ==action
[
- { action CALL streq { 1 entry * "=" | ::rawCodeAddress eq }' andif { 0 last * PUSH streq }' andif }' {
+ { action CALL eq { 1 entry * "=" | ::rawCodeAddress eq }' andif { 0 last * PUSH eq }' andif }' {
1 last * ::rawObject ==constant
constant executingScope sys .resolveInfo {
@@ -239,10 +239,10 @@
{ _ ==logic
2 logic len range { ==i i logic * ==entry 0 entry * ==action i 1 sub logic * ==last i 2 sub logic * ==secondLast
[
- { action CALL streq
+ { action CALL eq
{ 1 entry * "." | ::rawCodeAddress eq }' andif
- { 0 last * PUSH streq }' andif
- { 0 secondLast * STATICTYPED streq }' andif
+ { 0 last * PUSH eq }' andif
+ { 0 secondLast * STATICTYPED eq }' andif
}' {
1 last * ::rawObject ==constant
4 secondLast * ==relevantScope
@@ -286,15 +286,15 @@
i 2 sub logic * ==secondLast
i 3 sub logic * ==thirdLast
- action CALL streq
+ action CALL eq
{ 1 entry * "*" | ::rawCodeAddress eq }' andif
- { 0 last * PUSH streq }' andif
+ { 0 last * PUSH eq }' andif
{ secondLast holdsInt }' andif
{ thirdLast holdsInt }' andif
{
[
{ 1 last * |add ::rawAddress eq
- { 0 secondLast * PUSH streq }' andif
+ { 0 secondLast * PUSH eq }' andif
{ 1 secondLast * 128 lt }' andif
}' {
1 secondLast * ==value
@@ -419,9 +419,9 @@
{ _ ==logic
1 logic len range { ==i i logic * ==entry 0 entry * ==action i 1 sub logic * ==last
[
- { action CALL streq
+ { action CALL eq
{ 1 entry * "*" | ::rawCodeAddress eq }' andif
- { 0 last * STATICTYPED streq }' andif
+ { 0 last * STATICTYPED eq }' andif
}' {
4 last * ==executedObject
executedObject sys .typed .type ==type
@@ -467,12 +467,12 @@
{ _ ==logic
3 logic len range { ==i i logic * ==entry 0 entry * ==action i 1 sub logic * ==last i 2 sub logic * ==secondLast i 3 sub logic * ==thirdLast
[
- { action CALL streq
+ { action CALL eq
{ 1 entry * "*" | ::rawCodeAddress eq }' andif
- { 0 last * CALL streq }' andif
+ { 0 last * CALL eq }' andif
{ 1 last * "?" | ::rawCodeAddress eq }' andif
- { 0 secondLast * PUSH streq }' andif
- { 0 thirdLast * PUSH streq }' andif
+ { 0 secondLast * PUSH eq }' andif
+ { 0 thirdLast * PUSH eq }' andif
{ 1 secondLast * ::rawObject sys .typed .type 5 eq }' andif
{ 1 thirdLast * ::rawObject sys .typed .type 5 eq }' andif
{ 1 secondLast * ::rawObject sys .typed .inputs len not }' andif # TODO: think about typed functions
@@ -495,7 +495,7 @@
[ NOP ] ==last
[ logic { ==entry 0 entry * ==action
[
- { action CALL streq { 1 entry * "?" | ::rawCodeAddress eq }' andif }' {
+ { action CALL eq { 1 entry * "?" | ::rawCodeAddress eq }' andif }' {
[ NATIVE [
/rcx :popqReg
/rdx :popqReg
@@ -508,17 +508,17 @@
/rdx :pushqReg
] ] =entry
}
- { action CALL streq { 1 entry * "_" | ::rawCodeAddress eq }' andif }' {
+ { action CALL eq { 1 entry * "_" | ::rawCodeAddress eq }' andif }' {
[ NATIVE [
0 /rsp :pushqMemDisp8
] ] =entry
}
- { action CALL streq { 1 entry * "--" | ::rawCodeAddress eq }' andif }' {
+ { action CALL eq { 1 entry * "--" | ::rawCodeAddress eq }' andif }' {
[ NATIVE [
8 /rsp :addqImm8Reg
] ] =entry
}
- { action CALL streq { 1 entry * "-" | ::rawCodeAddress eq }' andif { 0 last * PUSH streq }' andif }' {
+ { action CALL eq { 1 entry * "-" | ::rawCodeAddress eq }' andif { 0 last * PUSH eq }' andif }' {
1 last * ::rawObject ==constant
0 ==largestNumber
@@ -749,7 +749,7 @@
rewriteSimpleFunctions
{ =*entry 0 entry ==action
[
- { action PUSH streq }' {
+ { action PUSH eq }' {
[
1 entry /rax :movqImmReg
/rax :pushqReg
@@ -758,7 +758,7 @@
1 entry emitReference
}
- { action CALL streq }' {
+ { action CALL eq }' {
[
1 entry /rax :movqImmReg
/rax :callqReg
@@ -767,7 +767,7 @@
1 entry 16 sub emitReference
}
- { action CALLSCOPED streq }' {
+ { action CALLSCOPED eq }' {
[
8 /r15 :subqImm8Reg
/r14 /r15 :movqRegMem
@@ -784,7 +784,7 @@
2 entry emitReference
}
- { action [ STATIC STATICTYPED ] streq any }' {
+ { action [ STATIC STATICTYPED ] eq any }' {
[
2 entry {
16 /r14 /rax :movqMemDisp8Reg
@@ -811,7 +811,7 @@
] emitOpcodes
}
- { action STATICWRITE streq }' {
+ { action STATICWRITE eq }' {
[
2 entry {
16 /r14 /rax :movqMemDisp8Reg
@@ -838,7 +838,7 @@
] emitOpcodes
}
- { action STATICDOT streq }' {
+ { action STATICDOT eq }' {
[
/rax :popqReg
2 entry { 16 /rax /rax :movqMemDisp8Reg } rep
@@ -854,7 +854,7 @@
] emitOpcodes
}
- { action UNTYPEDSCOPEDSTAR streq }' {
+ { action UNTYPEDSCOPEDSTAR eq }' {
[
/rax :popqReg
8 /r15 :subqImm8Reg
@@ -868,7 +868,7 @@
] emitOpcodes
}
- { action UNTYPEDUNSCOPEDSTAR streq }' {
+ { action UNTYPEDUNSCOPEDSTAR eq }' {
[
/rax :popqReg
24 /rax /rax :movqMemDisp8Reg
@@ -877,7 +877,7 @@
] emitOpcodes
}
- { action ARRAYSTAR streq }' {
+ { action ARRAYSTAR eq }' {
[
/rsi :popqReg
/rax :popqReg
@@ -893,7 +893,7 @@
] emitOpcodes
}
- { action STRINGSTAR streq }' {
+ { action STRINGSTAR eq }' {
[
/rsi :popqReg
/rax :popqReg
@@ -909,11 +909,11 @@
] emitOpcodes
}
- { action NATIVE streq }' {
+ { action NATIVE eq }' {
1 entry emitOpcodes
}
- { action NOP streq }' {
+ { action NOP eq }' {
}
{ 1 }' {
diff --git a/elymas/lib/sys/so.ey b/elymas/lib/sys/so.ey
index 468ec0f..c7f2aa0 100644
--- a/elymas/lib/sys/so.ey
+++ b/elymas/lib/sys/so.ey
@@ -284,8 +284,8 @@
{
[
- { rets "" streq }' { }
- { rets "s" streq }' {
+ { rets "" eq }' { }
+ { rets "s" eq }' {
/rax :pushqReg
/rcx /rcx :xorqRegReg
/rax /rdi :movqRegReg
@@ -302,45 +302,45 @@
24 /rax /rdi :leaqMemDisp8Reg
:repnz :movsb
}
- { rets "i64" streq }' {
+ { rets "i64" eq }' {
wrapInteger
/rax :pushqReg
}
- { rets "i32" streq }' {
+ { rets "i32" eq }' {
/eax /rax :movsxlqRegReg # sign extend result
wrapInteger
/rax :pushqReg
}
- { rets "i16" streq }' {
+ { rets "i16" eq }' {
/ax /rax :movsxwqRegReg # sign extend result
wrapInteger
/rax :pushqReg
}
- { rets "i8" streq }' {
+ { rets "i8" eq }' {
/al /rax :movsxbqRegReg # sign extend result
wrapInteger
/rax :pushqReg
}
- { rets "u64" streq }' {
+ { rets "u64" eq }' {
wrapInteger
/rax :pushqReg
}
- { rets "u32" streq }' {
+ { rets "u32" eq }' {
/eax /eax :movlRegReg # zero extend result
63 /rax :btsqImm8Reg
/rax :pushqReg
}
- { rets "u16" streq }' {
+ { rets "u16" eq }' {
/ax /rax :movzxwqRegReg # zero extend result
63 /rax :btsqImm8Reg
/rax :pushqReg
}
- { rets "u8" streq }' {
+ { rets "u8" eq }' {
/al /rax :movzxbqRegReg # zero extend result
63 /rax :btsqImm8Reg
/rax :pushqReg
}
- { rets "p" streq }' {
+ { rets "p" eq }' {
wrapInteger
/rax :pushqReg
}
diff --git a/examples/working-compiler/grammar-pre.test b/examples/working-compiler/grammar-pre.test
index 6c9c8ca..eaaa41c 100644
--- a/examples/working-compiler/grammar-pre.test
+++ b/examples/working-compiler/grammar-pre.test
@@ -1,4 +1,4 @@
-[ "(" ")" "[" "]" "-" "|" ] { _ { streq }_ "'" -102 cat deff }' each
+[ "(" ")" "[" "]" "-" "|" ] { _ { eq }_ "'" -102 cat deff }' each
"[" '[ dump
"x" '[ dump
diff --git a/examples/working-loaded/httpServer.test b/examples/working-loaded/httpServer.test
index fdfce61..47ff274 100644
--- a/examples/working-loaded/httpServer.test
+++ b/examples/working-loaded/httpServer.test
@@ -3,10 +3,10 @@ net .alg .httpServer "+" via
{ ":" via
:url dump
[
- { :url "/" streq } {
+ { :url "/" eq } {
"<html><body>Hallo Welt!<a href=\"/test\">Test</a></body></html>"
"text/html" :ok
- } { :url "/test" streq } {
+ } { :url "/test" eq } {
"<html><body>Test!</body></html>"
"text/html" :ok
}
diff --git a/examples/working/macro.ey b/examples/working/macro.ey
index 10c7d3b..f09a7de 100644
--- a/examples/working/macro.ey
+++ b/examples/working/macro.ey
@@ -40,7 +40,7 @@
indent [ "\"" -102 "\"\n" ] |out each
} {
indent _ sym _ out
- "{" streq { 0 =cont |lol } { -- } ? *
+ "{" eq { 0 =cont |lol } { -- } ? *
"\n" out
} {
blk |walk each
diff --git a/examples/working/streq_autoloop.ey b/examples/working/streq_autoloop.ey
index d651e00..e83c672 100644
--- a/examples/working/streq_autoloop.ey
+++ b/examples/working/streq_autoloop.ey
@@ -1,2 +1,2 @@
-/a /a streq dump
-/d [ /a /b /c /d /e /f /g /h ] streq dump
+/a /a eq dump
+/d [ /a /b /c /d /e /f /g /h ] eq dump
diff --git a/interpreter/ElymasGlobal.pm b/interpreter/ElymasGlobal.pm
index 4e1593a..373f951 100644
--- a/interpreter/ElymasGlobal.pm
+++ b/interpreter/ElymasGlobal.pm
@@ -793,7 +793,6 @@ installGlobal2IntFunction('bnor', '~((0+$a) | (0+$b))');
installGlobal2IntFunction('bxor', '(0+$a) ^ (0+$b)');
installGlobal2IntFunction('bnxor', '~((0+$a) ^ (0+$b))');
-installGlobal2IntFunction('eq', '($a == $b)? 1: 0');
installGlobal2IntFunction('neq', '($a != $b)? 1: 0');
installGlobal2IntFunction('lt', '($a < $b)? 1: 0');
installGlobal2IntFunction('le', '($a <= $b)? 1: 0');
@@ -807,8 +806,18 @@ installGlobal1IntFunction('not', sub { return not $_[0] });
installGlobal1IntFunction('bnot', sub { return ~(0 + $_[0]) });
installGlobal1IntFunction('abs', sub { return abs $_[0] });
-# FIXME: this API is ugly
-installGlobal2StrFunction('streq', sub { return [($_[0] eq $_[1])? 1: 0, 'int'] });
+$globalScope->{'eq'} = [sub {
+ my ($data) = @_;
+
+ my $b = pop @$data;
+ if($data->[-1]->[1] eq 'string' or $b->[1] eq 'string') {
+ # auto conversion to string is not supported
+ # (but asserting against it here would just waste time in the end)
+ $data->[-1] = [($data->[-1]->[0] eq $b->[0])? 1: 0, 'int'];
+ } else {
+ $data->[-1] = [($data->[-1]->[0] == $b->[0])? 1: 0, 'int'];
+ }
+}, ['func', 'eq', ['scalar', 'scalar'], ['int']], 'active']; # TODO: why does this work correctly?
# J comparison (http://www.jsoftware.com/docs/help701/dictionary/vocabul.htm)
# = Self-Classify • Equal -> <TODO redundant> / eq
@@ -890,7 +899,7 @@ installGlobal2StrFunction('streq', sub { return [($_[0] eq $_[1])? 1: 0, 'int']
# }. Behead • Drop -> <TODO: implement without new primitives> / <TODO: implement without new primitives>
# }: Curtail • -> <TODO: implement without new primitives>
#
-# " Rank (m"n u"n m"v u"v) -> <FIXME: think about (function) type casts>
+# " Rank (m"n u"n m"v u"v) -> ''
# ". Do • Numbers -> <nope> / <FIXME: create (sscanf-style) parser>
# ": Default Format • Format -> <FIXME: create (printf-style) printer>
# ` Tie (Gerund) -> <implement as arrays of functions>
diff --git a/notes b/notes
index e819731..d442476 100644
--- a/notes
+++ b/notes
@@ -60,15 +60,6 @@ dup = _
-<digits> -> delete stack contents up to largest digit, recreate according to digits
-1 [ 2 3 ] add -> [ 3 4 ]
-[ [ 1 ] [ 2 ] ] length -> 2 # scanning for applicable base type from top
-
-A->int B->int add -> B->A->int
-A->int A->int add -> A->int
-
-# argument order to '' is from stack-top to stack-lower
-[ 1 2 3 ] [ /foo /bar /quux ] { defv }' [ "" 1 ] [ ] '' *
-
= Characters =
!: co-routines and threads
@@ -327,17 +318,40 @@ Main problem: How do we find out if the names mean what we believe they do?
= Musings about Types =
-[ /foo /bar ] [ 2 3 ] { "Key %s -> %d" format sys .out .writeall } [ "" "" ] [ ] typed *
-[ /a /b /c ] _ { cat } * # -> [ /aa /bb /cc ]
-[ /a /b /c ] _ { cat } [ "" "" ] [ "" ] typed * # -> [ /aa /bb /cc ]
-[ /a /b /c ] _ [ 0 ] [ "" ] typed cat # -> [ [ /aa /ba /ca ] [ /ab /bb /cb ] [ /ac /bc /cc ] ]
+1 [ 2 3 ] add -> [ 3 4 ]
+[ [ 1 ] [ 2 ] ] len -> 2 # scanning for applicable base type from top
+
+A->int B->int add -> B->A->int
+A->int A->int add -> A->int
+
+# argument order to '' is from stack-top to stack-lower
+[ 1 2 3 ] [ /foo /bar /quux ] { defv }' [ "" 1 ] [ ] '' *
+
+[ /foo /bar ] [ 2 3 ] { "Key %s -> %d" format sys .out .writeall } [ "" "" ] [ ] '' *
+[ /a /b /c ] _ { cat } * # -> [ /a /b /c /a /b /c ]
+[ /a /b /c ] _ { cat } [ 1 1 ] [ "" ] '' * # -> [ /aa /bb /cc ]
+[ /a /b /c ] _ [ 0 ] [ "" ] '' cat # -> [ [ /aa /ba /ca ] [ /ab /bb /cb ] [ /ac /bc /cc ] ]
[ /a /b /c ] _ |cat cross
Types are represented by concrete values of that type.
+Scalars (i.e. integers, strings, floats) are all represented by integers.
Co-iterability is decided by type-match and
-* integers: co-iterated type is bitwise and, if zero, no co-iteration
-* strings: co-iterated type is longest common substring, if epsilon, no co-iteration
+* integers: co-iteration only for equal non-zero integers
+
+Question: Is it better to handle scalars uniformly or handle strings (or floats) as a separate type?
+Question: How to deal with functions like eq, which can take all scalars?
+
+== Variant: Scalar-Type (implemented) ==
+
+eq [ sys .typed .SCALAR _ ] [ Int ] ''
+{ 1 eq } { "foo" eq } and # [ sys .typed .SCALAR ] [ Int ] # -- -- 0
+{ 1 eq } '1 { "foo" eq } '2 and # [ sys .typed .SCALAR _ ] [ Int ] # 1 eq -01 "foo" eq and
+
+== Variant: Type-Variables ==
+
+eq [ sys .typed .var _ ] [ Int ] ''
+{ 1 eq } { "foo" eq } and # [ $X $Y ] [ Int ] # 1 eq -01 "foo" eq and
= Musings about function composition operator =