mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-17 08:27:45 +03:00
refactor: Remove deps functions in ArrayTemplates (#1093)
This commit is contained in:
parent
470f0f827d
commit
861ba26f52
@ -102,9 +102,8 @@ templateEFilter = defineTypeParameterizedTemplate templateCreator path t docs
|
|||||||
_ -> declaration " ((($a*)a.data)[insertIndex++]) = (($a*)a.data)[i];" deleteCall
|
_ -> declaration " ((($a*)a.data)[insertIndex++]) = (($a*)a.data)[i];" deleteCall
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
( \(FuncTy [RefTy ft@(FuncTy fArgTys@[RefTy insideType _] BoolTy _) _, _] _ _) ->
|
( \(FuncTy [RefTy ft@(FuncTy fArgTys@[RefTy _ _] BoolTy _) _, _] _ _) ->
|
||||||
[defineFunctionTypeAlias ft, defineFunctionTypeAlias (FuncTy (lambdaEnvTy : fArgTys) BoolTy StaticLifetimeTy)]
|
[defineFunctionTypeAlias ft, defineFunctionTypeAlias (FuncTy (lambdaEnvTy : fArgTys) BoolTy StaticLifetimeTy)]
|
||||||
++ depsForDeleteFunc typeEnv env insideType
|
|
||||||
)
|
)
|
||||||
|
|
||||||
templatePushBack :: (String, Binder)
|
templatePushBack :: (String, Binder)
|
||||||
@ -329,9 +328,7 @@ templateAset = defineTypeParameterizedTemplate templateCreator path t docs
|
|||||||
"}"
|
"}"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
( \(FuncTy [_, _, insideTy] _ _) ->
|
(const [])
|
||||||
depsForDeleteFunc typeEnv env insideTy
|
|
||||||
)
|
|
||||||
|
|
||||||
templateAsetBang :: (String, Binder)
|
templateAsetBang :: (String, Binder)
|
||||||
templateAsetBang = defineTypeParameterizedTemplate templateCreator path t docs
|
templateAsetBang = defineTypeParameterizedTemplate templateCreator path t docs
|
||||||
@ -363,9 +360,7 @@ templateAsetBang = defineTypeParameterizedTemplate templateCreator path t docs
|
|||||||
"}"
|
"}"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
( \(FuncTy [RefTy arrayType _, _, _] _ _) ->
|
(const [])
|
||||||
depsForDeleteFunc typeEnv env arrayType
|
|
||||||
)
|
|
||||||
|
|
||||||
-- | This function can set uninitialized memory in an array (used together with 'allocate').
|
-- | This function can set uninitialized memory in an array (used together with 'allocate').
|
||||||
-- | It will NOT try to free the value that is already at location 'n'.
|
-- | It will NOT try to free the value that is already at location 'n'.
|
||||||
@ -406,14 +401,12 @@ templateLength = defineTypeParameterizedTemplate templateCreator path t docs
|
|||||||
t = FuncTy [RefTy (StructTy (ConcreteNameTy (SymPath [] "Array")) [VarTy "t"]) (VarTy "q")] IntTy StaticLifetimeTy
|
t = FuncTy [RefTy (StructTy (ConcreteNameTy (SymPath [] "Array")) [VarTy "t"]) (VarTy "q")] IntTy StaticLifetimeTy
|
||||||
docs = "gets the length of the array."
|
docs = "gets the length of the array."
|
||||||
templateCreator = TemplateCreator $
|
templateCreator = TemplateCreator $
|
||||||
\typeEnv env ->
|
\_ _ ->
|
||||||
Template
|
Template
|
||||||
t
|
t
|
||||||
(const (toTemplate "int $NAME (Array *a)"))
|
(const (toTemplate "int $NAME (Array *a)"))
|
||||||
(const (toTemplate "$DECL { return (*a).len; }"))
|
(const (toTemplate "$DECL { return (*a).len; }"))
|
||||||
( \(FuncTy [RefTy arrayType _] _ _) ->
|
(const [])
|
||||||
depsForDeleteFunc typeEnv env arrayType
|
|
||||||
)
|
|
||||||
|
|
||||||
templateAllocate :: (String, Binder)
|
templateAllocate :: (String, Binder)
|
||||||
templateAllocate = defineTypeParameterizedTemplate templateCreator path t docs
|
templateAllocate = defineTypeParameterizedTemplate templateCreator path t docs
|
||||||
@ -422,7 +415,7 @@ templateAllocate = defineTypeParameterizedTemplate templateCreator path t docs
|
|||||||
t = FuncTy [IntTy] (StructTy (ConcreteNameTy (SymPath [] "Array")) [VarTy "t"]) StaticLifetimeTy
|
t = FuncTy [IntTy] (StructTy (ConcreteNameTy (SymPath [] "Array")) [VarTy "t"]) StaticLifetimeTy
|
||||||
docs = "allocates an uninitialized array. You can initialize members using [`aset-uninitialized`](#aset-uninitialized)."
|
docs = "allocates an uninitialized array. You can initialize members using [`aset-uninitialized`](#aset-uninitialized)."
|
||||||
templateCreator = TemplateCreator $
|
templateCreator = TemplateCreator $
|
||||||
\typeEnv env ->
|
\_ _ ->
|
||||||
Template
|
Template
|
||||||
t
|
t
|
||||||
(const (toTemplate "Array $NAME (int n)"))
|
(const (toTemplate "Array $NAME (int n)"))
|
||||||
@ -441,9 +434,7 @@ templateAllocate = defineTypeParameterizedTemplate templateCreator path t docs
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
( \(FuncTy [_] arrayType _) ->
|
(const [])
|
||||||
depsForDeleteFunc typeEnv env arrayType
|
|
||||||
)
|
|
||||||
|
|
||||||
templateDeleteArray :: (String, Binder)
|
templateDeleteArray :: (String, Binder)
|
||||||
templateDeleteArray = defineTypeParameterizedTemplate templateCreator path t docs
|
templateDeleteArray = defineTypeParameterizedTemplate templateCreator path t docs
|
||||||
@ -461,9 +452,7 @@ templateDeleteArray = defineTypeParameterizedTemplate templateCreator path t doc
|
|||||||
++ deleteTy typeEnv env arrayType
|
++ deleteTy typeEnv env arrayType
|
||||||
++ [TokC "}\n"]
|
++ [TokC "}\n"]
|
||||||
)
|
)
|
||||||
( \(FuncTy [StructTy (ConcreteNameTy (SymPath [] "Array")) [insideType]] UnitTy _) ->
|
(const [])
|
||||||
depsForDeleteFunc typeEnv env insideType
|
|
||||||
)
|
|
||||||
|
|
||||||
deleteTy :: TypeEnv -> Env -> Ty -> [Token]
|
deleteTy :: TypeEnv -> Env -> Ty -> [Token]
|
||||||
deleteTy typeEnv env (StructTy _ [innerType]) =
|
deleteTy typeEnv env (StructTy _ [innerType]) =
|
||||||
|
Loading…
Reference in New Issue
Block a user