From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p41ACOnc026588 for ; Sun, 1 May 2011 12:12:25 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FANkwvU3UGyoBlGdsb2JhbACEUZQBjUgUAQEBAQkLCQkUAyKlYo0Cj2iBKoNVgQEEkxIdiW4 X-IronPort-AV: E=Sophos;i="4.64,297,1301868000"; d="scan'208";a="82091520" Received: from smtp1-g21.free.fr ([212.27.42.1]) by mail3-smtp-sop.national.inria.fr with ESMTP; 01 May 2011 12:12:24 +0200 Received: from [192.168.0.3] (unknown [82.226.84.212]) by smtp1-g21.free.fr (Postfix) with ESMTP id 0B23A940154 for ; Sun, 1 May 2011 12:12:17 +0200 (CEST) From: redfire To: caml-list@inria.fr Content-Type: text/plain; charset="UTF-8" Date: Sun, 01 May 2011 12:10:54 +0200 Message-ID: <1304244654.4147.34.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: [Caml-list] Byte code generation for the Ocaml virtual machine (ZAM) Hello all, I'm currently doing a student project where I have to generate bytecode for the caml virtual machine. I convert a subset of the Scheme language. My main issue concerns the dynamic typing mechanism. My idea is to store every values I manipulate like this (type, value). But I have a problem with the generation of the data section. For the moment, I found on the Internet a snippet using the Obj module but I don't exactly know what this implies in the rest of the code (especially Obj.repr). The Obj.repr allows the possibility to mix datas of different type in the same table. Then I can do an output_value (Pervasives) on it and my data section seems to be correct. I have a problem to get back these information. With the snippet using Obj, I was hoping to get a block structure with field 0 -> type and field 1 -> value. But it doesn't seem to be the case. With a piece of code maybe it's going to be clearer. Example of data : (2, 5). 2 is for the type, so here we suppose that 2 means integer and 5 the value integer. For the moment, I store Obj.repr (2, 5) in a table (code from the snippet of the Internet), but it doesn't work. At generation time, I do a output_value oc t where t is the table containing all tuples. So what I'm looking for, is a way to get back a block of size 2 with a field 0 for the type and then field 1 for the value. Is it possible ? Thank you for your time ;-) Cheers. -- Jeremie Salvucci