on master help sign in
javascript: strHead & strTail primitives
5c51429raichoo
src/IRTS/CodegenJavaScript.hs+5
@@ -279,6 +279,11 @@ translateExpression _ (SOp op vars)
279 | LBGe <- op
279 | LBGe <- op
280 , (lhs:rhs:_) <- vars = translateBinaryOp ">=" lhs rhs
280 , (lhs:rhs:_) <- vars = translateBinaryOp ">=" lhs rhs
281
281
282+ | LStrHead <- op
283+ , (arg:_) <- vars = translateVariableName arg ++ "[0]"
284+ | LStrTail <- op
285+ , (arg:_) <- vars = let v = translateVariableName arg in
286+ v ++ ".substr(1," ++ v ++ ".length-1)"
282 | LStrConcat <- op
287 | LStrConcat <- op
283 , (lhs:rhs:_) <- vars = translateBinaryOp "+" lhs rhs
288 , (lhs:rhs:_) <- vars = translateBinaryOp "+" lhs rhs
284 | LStrEq <- op
289 | LStrEq <- op