diff options
author | Zahary Karadjov <zahary@gmail.com> | 2011-12-11 11:26:50 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2011-12-11 11:26:50 +0200 |
commit | 67bc23bb60dda2895c47ae0747d106b6075c6a90 (patch) | |
tree | 4f4c66fad9ae5c42beefd31274091e295f31b639 /compiler/astalgo.nim | |
parent | d171a8b36f10f42d35e64a7ddefa57376b419908 (diff) | |
parent | af792da0bbee6e9587b8aafafcd8f898f8fe9fd4 (diff) | |
download | Nim-67bc23bb60dda2895c47ae0747d106b6075c6a90.tar.gz |
Merge branch 'master' of github.com:Araq/Nimrod into upstream
Diffstat (limited to 'compiler/astalgo.nim')
-rwxr-xr-x | compiler/astalgo.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 472a8d803..94046a723 100755 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -146,6 +146,30 @@ proc IITablePut*(t: var TIITable, key, val: int) # implementation +proc SameValue*(a, b: PNode): bool = + result = false + case a.kind + of nkCharLit..nkInt64Lit: + if b.kind in {nkCharLit..nkInt64Lit}: result = a.intVal == b.intVal + of nkFloatLit..nkFloat64Lit: + if b.kind in {nkFloatLit..nkFloat64Lit}: result = a.floatVal == b.floatVal + of nkStrLit..nkTripleStrLit: + if b.kind in {nkStrLit..nkTripleStrLit}: result = a.strVal == b.strVal + else: + InternalError(a.info, "SameValue") + +proc leValue*(a, b: PNode): bool = + # a <= b? + result = false + case a.kind + of nkCharLit..nkInt64Lit: + if b.kind in {nkCharLit..nkInt64Lit}: result = a.intVal <= b.intVal + of nkFloatLit..nkFloat64Lit: + if b.kind in {nkFloatLit..nkFloat64Lit}: result = a.floatVal <= b.floatVal + of nkStrLit..nkTripleStrLit: + if b.kind in {nkStrLit..nkTripleStrLit}: result = a.strVal <= b.strVal + else: InternalError(a.info, "leValue") + proc lookupInRecord(n: PNode, field: PIdent): PSym = result = nil case n.kind |