小编qc1*_*1iu的帖子

LLVM-如何通过函数的真实/原始名称获取函数

最近,我使用llvm在LLVM-IR中插入call指令。问题是,如果我有一个名为 的函数add,我无法使用 getFuntion(string) 找到它,因为 IR 中的 add() 可能会_Z3addv_。我知道IR中的所有功能都有一个新名称,但我不知道新名称到底是什么。

  Module *m = f->getParent();
  IRBuilder<> builder(m->getContext());
  Function *call = m->getFunction("add");
  // call is NULL.
  std::vector<Value *> args;
  ......



Module *m = f->getParent();
IRBuilder<> builder(m->getContext());
Function *call = m->getFunction("_Z3addv");
// call is not NULL.
std::vector<Value *> args;
......
Run Code Online (Sandbox Code Playgroud)

如何使用其原始名称找到该函数?

c++ llvm clang

6
推荐指数
1
解决办法
3263
查看次数

为什么在Ocaml中使用模块类型?

我对Ocaml中的模块类型感到困惑.

我想知道在哪种情况下我们应该使用模块类型?

我通常在.mli中使用模块sig来公开一些细节,并在.ml中放置相应的实现模块结构.

例如:

.mli

module A:
 sig
   type t = T of string
 end
Run Code Online (Sandbox Code Playgroud)

.ml

module A =
 struct
   type t = T of string
 end
Run Code Online (Sandbox Code Playgroud)

出于这个原因,我认为Ocaml的模块就像C.中的.h和.c文件一样.

我知道,模块类型可以声明一个接口,但接口是不是因为Java的接口相同.

就像书中的一个例子:

open Core.Std

 module type ID = sig
  type t
   val of_string : string -> t
  val to_string : t -> string
 end

  module String_id = struct
   type t = string
    let of_string x = x
    let to_string x = x
  end

  module Username : ID = String_id …
Run Code Online (Sandbox Code Playgroud)

ocaml types functional-programming

3
推荐指数
1
解决办法
699
查看次数

标签 统计

c++ ×1

clang ×1

functional-programming ×1

llvm ×1

ocaml ×1

types ×1