Skip to content

Commit 77afa2f

Browse files
author
Micha Reiser
authored
Merge pull request #62 from ovr/double-float-ptr-type
Feature: Support getFloatPtrTy/getDoublePtrTy
2 parents b984a1a + 98a9327 commit 77afa2f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

llvm-node.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ declare namespace llvm {
409409

410410
static getInt32PtrTy(context: LLVMContext, AS?: number): PointerType;
411411

412+
static getDoublePtrTy(context: LLVMContext, AS?: number): PointerType;
413+
414+
static getFloatPtrTy(context: LLVMContext, AS?: number): PointerType;
415+
412416
static getHalfTy(context: LLVMContext): Type;
413417

414418
protected constructor();

src/ir/type.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ Nan::Persistent<v8::FunctionTemplate> &TypeWrapper::typeTemplate()
260260
Nan::SetMethod(typeTemplate, "getInt1PtrTy", &getPointerType<&llvm::Type::getInt1PtrTy>);
261261
Nan::SetMethod(typeTemplate, "getInt8PtrTy", &getPointerType<&llvm::Type::getInt8PtrTy>);
262262
Nan::SetMethod(typeTemplate, "getInt32PtrTy", &getPointerType<&llvm::Type::getInt32PtrTy>);
263+
Nan::SetMethod(typeTemplate, "getFloatPtrTy", &getPointerType<&llvm::Type::getFloatPtrTy>);
264+
Nan::SetMethod(typeTemplate, "getDoublePtrTy", &getPointerType<&llvm::Type::getDoublePtrTy>);
263265

264266
Nan::SetPrototypeMethod(typeTemplate, "equals", &equals);
265267
Nan::SetPrototypeMethod(typeTemplate, "isVoidTy", &isOfType<&llvm::Type::isVoidTy>);

test/ir/type.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ describe("ir/type", () => {
128128
expect(ty.isVoidTy()).toBe(false);
129129
});
130130

131+
test("getDoublePtrTy returns a type for which isPointerTy is true", () => {
132+
const ty = llvm.Type.getDoublePtrTy(context);
133+
134+
expect(ty).toBeInstanceOf(llvm.Type);
135+
expect(ty.isPointerTy()).toBe(true);
136+
expect(ty.isVoidTy()).toBe(false);
137+
});
138+
139+
test("getFloatPtrTy returns a type for which isPointerTy is true", () => {
140+
const ty = llvm.Type.getFloatPtrTy(context);
141+
142+
expect(ty).toBeInstanceOf(llvm.Type);
143+
expect(ty.isPointerTy()).toBe(true);
144+
expect(ty.isVoidTy()).toBe(false);
145+
});
146+
131147
test("equals returns true if the two types are equal", () => {
132148
expect(llvm.Type.getInt32Ty(context).equals(llvm.Type.getInt32Ty(context))).toBe(true);
133149
});

0 commit comments

Comments
 (0)