mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-11-24 06:52:19 +03:00
Fixes from trying to compile idris with the refc backend
* fix doublequoting in constArray * substitute tildes in names * Add negate functions * Add string comparisons Several things remain, notably missing _argList functions.
This commit is contained in:
parent
b27001136b
commit
e49916cea9
@ -61,6 +61,7 @@ showcCleanStringChar '$' = ("_dollar" ++)
|
||||
showcCleanStringChar ',' = ("_comma" ++)
|
||||
showcCleanStringChar '#' = ("_number" ++)
|
||||
showcCleanStringChar '%' = ("_percent" ++)
|
||||
showcCleanStringChar '~' = ("_tilde" ++)
|
||||
showcCleanStringChar c
|
||||
= if c < chr 32 || c > chr 126
|
||||
then (("u" ++ pad (asHex (cast c))) ++)
|
||||
@ -202,7 +203,7 @@ plainOp op args = op ++ "(" ++ (showSep ", " args) ++ ")"
|
||||
|
||||
||| Generate scheme for a primitive function.
|
||||
cOp : PrimFn arity -> Vect arity String -> String
|
||||
cOp (Neg ty) [x] = "-" ++ x
|
||||
cOp (Neg ty) [x] = "negate_" ++ cConstant ty ++ "(" ++ x ++ ")"
|
||||
cOp StrLength [x] = "stringLength(" ++ x ++ ")"
|
||||
cOp StrHead [x] = "head(" ++ x ++ ")"
|
||||
cOp StrTail [x] = "tail(" ++ x ++ ")"
|
||||
@ -629,7 +630,7 @@ mutual
|
||||
makeNonIntSwitchStatementConst ((MkAConstAlt constant caseBody) :: alts) 1 constantArray "multiDoubleCompare"
|
||||
_ => pure ("ERROR_NOT_DOUBLE_OR_STRING", "ERROR_NOT_DOUBLE_OR_STRING")
|
||||
makeNonIntSwitchStatementConst ((MkAConstAlt constant caseBody) :: alts) k constantArray compareFct = do
|
||||
emit EmptyFC $ constantArray ++ "[" ++ show (k-1) ++ "] = \"" ++ extractConstant constant ++ "\";"
|
||||
emit EmptyFC $ constantArray ++ "[" ++ show (k-1) ++ "] = " ++ extractConstant constant ++ ";"
|
||||
makeNonIntSwitchStatementConst alts (k+1) constantArray compareFct
|
||||
|
||||
|
||||
|
@ -40,6 +40,19 @@ Value *sub_double(Value *x, Value *y)
|
||||
return (Value *)makeDouble(((Value_Double *)x)->d - ((Value_Double *)y)->d);
|
||||
}
|
||||
|
||||
/* negate */
|
||||
Value *negate_i32(Value *x)
|
||||
{
|
||||
return (Value *)makeInt32(-((Value_Int32 *)x)->i32);
|
||||
}
|
||||
Value *negate_i64(Value *x)
|
||||
{
|
||||
return (Value *)makeInt64(-((Value_Int64 *)x)->i64);
|
||||
}
|
||||
Value *negate_double(Value *x)
|
||||
{
|
||||
return (Value *)makeDouble(-((Value_Double *)x)->d);
|
||||
}
|
||||
/* mul */
|
||||
Value *mul_i32(Value *x, Value *y)
|
||||
{
|
||||
@ -174,6 +187,18 @@ Value *lt_char(Value *x, Value *y)
|
||||
}
|
||||
}
|
||||
|
||||
Value *lt_string(Value *x, Value *y)
|
||||
{
|
||||
if (strcmp(((Value_String *)x)->str, ((Value_String *)y)->str) < 0)
|
||||
{
|
||||
return (Value *)makeInt32(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Value *)makeInt32(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* gt */
|
||||
Value *gt_i32(Value *x, Value *y)
|
||||
{
|
||||
@ -220,6 +245,18 @@ Value *gt_char(Value *x, Value *y)
|
||||
}
|
||||
}
|
||||
|
||||
Value *gt_string(Value *x, Value *y)
|
||||
{
|
||||
if (strcmp(((Value_String *)x)->str, ((Value_String *)y)->str) > 0)
|
||||
{
|
||||
return (Value *)makeInt32(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Value *)makeInt32(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* eq */
|
||||
Value *eq_i32(Value *x, Value *y)
|
||||
{
|
||||
@ -323,6 +360,18 @@ Value *lte_char(Value *x, Value *y)
|
||||
}
|
||||
}
|
||||
|
||||
Value *lte_string(Value *x, Value *y)
|
||||
{
|
||||
if (strcmp(((Value_String *)x)->str, ((Value_String *)y)->str) <= 0)
|
||||
{
|
||||
return (Value *)makeInt32(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Value *)makeInt32(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* gte */
|
||||
Value *gte_i32(Value *x, Value *y)
|
||||
{
|
||||
@ -335,6 +384,7 @@ Value *gte_i32(Value *x, Value *y)
|
||||
return (Value *)makeInt32(0);
|
||||
}
|
||||
}
|
||||
|
||||
Value *gte_i64(Value *x, Value *y)
|
||||
{
|
||||
if (((Value_Int64 *)x)->i64 >= ((Value_Int64 *)y)->i64)
|
||||
@ -346,6 +396,7 @@ Value *gte_i64(Value *x, Value *y)
|
||||
return (Value *)makeInt32(0);
|
||||
}
|
||||
}
|
||||
|
||||
Value *gte_double(Value *x, Value *y)
|
||||
{
|
||||
if (((Value_Double *)x)->d >= ((Value_Double *)y)->d)
|
||||
@ -357,6 +408,7 @@ Value *gte_double(Value *x, Value *y)
|
||||
return (Value *)makeInt32(0);
|
||||
}
|
||||
}
|
||||
|
||||
Value *gte_char(Value *x, Value *y)
|
||||
{
|
||||
if (((Value_Char *)x)->c >= ((Value_Char *)y)->c)
|
||||
@ -368,3 +420,15 @@ Value *gte_char(Value *x, Value *y)
|
||||
return (Value *)makeInt32(0);
|
||||
}
|
||||
}
|
||||
|
||||
Value *gte_string(Value *x, Value *y)
|
||||
{
|
||||
if (strcmp(((Value_String *)x)->str, ((Value_String *)y)->str) >= 0)
|
||||
{
|
||||
return (Value *)makeInt32(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Value *)makeInt32(0);
|
||||
}
|
||||
}
|
@ -16,6 +16,11 @@ Value *sub_i32(Value *x, Value *y);
|
||||
Value *sub_i64(Value *x, Value *y);
|
||||
Value *sub_double(Value *x, Value *y);
|
||||
|
||||
/* negate */
|
||||
Value *negate_i32(Value *x);
|
||||
Value *negate_i64(Value *x);
|
||||
Value *negate_double(Value *x);
|
||||
|
||||
/* mul */
|
||||
Value *mul_i32(Value *x, Value *y);
|
||||
Value *mul_i64(Value *x, Value *y);
|
||||
@ -55,12 +60,14 @@ Value *lt_i32(Value *x, Value *y);
|
||||
Value *lt_i64(Value *x, Value *y);
|
||||
Value *lt_double(Value *x, Value *y);
|
||||
Value *lt_char(Value *x, Value *y);
|
||||
Value *lt_string(Value *x, Value *y);
|
||||
|
||||
/* gt */
|
||||
Value *gt_i32(Value *x, Value *y);
|
||||
Value *gt_i64(Value *x, Value *y);
|
||||
Value *gt_double(Value *x, Value *y);
|
||||
Value *gt_char(Value *x, Value *y);
|
||||
Value *gt_string(Value *x, Value *y);
|
||||
|
||||
/* eq */
|
||||
Value *eq_i32(Value *x, Value *y);
|
||||
@ -74,11 +81,12 @@ Value *lte_i32(Value *x, Value *y);
|
||||
Value *lte_i64(Value *x, Value *y);
|
||||
Value *lte_double(Value *x, Value *y);
|
||||
Value *lte_char(Value *x, Value *y);
|
||||
Value *lte_string(Value *x, Value *y);
|
||||
|
||||
/* gte */
|
||||
Value *gte_i32(Value *x, Value *y);
|
||||
Value *gte_i64(Value *x, Value *y);
|
||||
Value *gte_double(Value *x, Value *y);
|
||||
Value *gte_char(Value *x, Value *y);
|
||||
|
||||
Value *gte_string(Value *x, Value *y);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user