1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openUtilopenEsubstopenConstropenGenlambda(** This file defines the lambda code generation phase of the native compiler *)typelambda=Nativevalues.tGenlambda.lambda(*s Constructors *)(** Simplification of lambda expression *)(* TODO: make the VM and native agree *)letcan_substlam=matchlamwith|Lrel_|Lvar_|Lconst_|Lval_|Lsort_|Lind_|Llam_|Levar_->true|_->falseletsimplifysubstlam=simplifycan_substsubstlamletis_valuelc=matchlcwith|Lval_|Lint_|Luint_|Lfloat_->true|_->falseletget_valuelc=matchlcwith|Lvalv->v|Linttag->Nativevalues.mk_inttag|Luinti->Nativevalues.mk_uinti|Lfloatf->Nativevalues.mk_floatf|_->raiseNot_foundletas_valuetagargs=ifArray.for_allis_valueargsthenletdummy_val=Obj.magic0inletargs=(* Don't simplify this to Array.map, cf. the related comment in
function eval_to_patch, file kernel/csymtable.ml *)leta=Array.make(Array.lengthargs)dummy_valinArray.iteri(funiv->a.(i)<-get_valuev)args;ainSome(Nativevalues.mk_blocktagargs)elseNoneletis_lazyt=matchConstr.kindtwith|App_|LetIn_|Case_|Proj_->true|_->falsemoduleVal=structopenDeclarationstypevalue=Nativevalues.tletas_value=as_valueletcheck_inductive__=()letget_constantknucb=matchcb.const_bodywith|Defbody->ifis_lazybodythenmkLappLforce[|Lconstknu|]elseLconstknu|Undef_|OpaqueDef_|Primitive_->assertfalseendmoduleLambda=Genlambda.Make(Val)letlambda_of_constrenvsigmac=letlam=Lambda.lambda_of_constrenvsigmacinsimplify(subs_id0)lam