Skip to content

Commit

Permalink
Use name as identifier of primitives instead 'smartptr'
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure authored and samoht committed Jun 20, 2018
1 parent 3cfd9d4 commit 0a7ed65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion proto/lambda.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ message Primitive {
required string name = 1;
repeated Type arguments = 2;
required Type return = 3;
required int32 smartptr = 4;
}

enum Binop {
Expand Down
9 changes: 4 additions & 5 deletions src/protobuf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ open Lambda_protobuf
open Parsetree

module Gamma = Map.Make(String)
module Primitives = Map.Make(Int32)
module Primitives = Map.Make(String)

let typ_from ?(gamma = Gamma.empty) =
let rec go : Types.type_ -> Type.t = function
Expand Down Expand Up @@ -164,15 +164,14 @@ let expr_from
value v t pp eq
| Types.Prm { value = { name
; arguments
; return
; smartptr } } ->
; return } } ->
(try
primitive
name
(List.map (typ_from ?gamma) arguments)
(typ_from ?gamma return)
(Primitives.find smartptr primitives)
with Not_found -> Fmt.invalid_arg "Primitive %s:%ld not found" name smartptr)
(Primitives.find name primitives)
with Not_found -> Fmt.invalid_arg "Primitive %s not found" name)
| Types.Lst { typ; expr; } ->
list ?typ:(Option.map (typ_from ?gamma) typ) (List.map go expr)
| Types.Arr { typ; expr; } ->
Expand Down

0 comments on commit 0a7ed65

Please sign in to comment.