Skip to content

Commit

Permalink
Bugfixes in types and LLVM target
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk committed May 10, 2015
1 parent 8fb59a8 commit ecb6801
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/targets/llvm.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ AST.Call.prototype.compileIntrinsicInstanceMethodCall = function (ctx, blockCtx,
var receiverValue = exprCtx.value
argValues.unshift(receiverValue)
// Build the call
var retValue = ctx.builder.buildCall(nativeFn.getPtr(), argValues, '')
var retValue = ctx.builder.buildCall(nativeFn.getPtr(ctx), argValues, '')
tryUpdatingExpressionContext(exprCtx, this.type, retValue)
return retValue
}
Expand Down
7 changes: 4 additions & 3 deletions src/targets/llvm/native-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ NativeFunction.prototype.computeType = function () {
this.type = new LLVM.FunctionType(ret, args, false)
}
NativeFunction.prototype.defineExternal = function () {
var self = this
if (this.defined) {
throw new ICE('Cannot redefine external function')
}
Expand All @@ -49,9 +50,9 @@ NativeFunction.prototype.defineExternal = function () {
if (!ctx) {
throw new ICE('Missing context for defining external function')
}
this.computeType()
this.fn = NativeFunction.addExternalFunction(ctx, this.name, this.ret, this.args)
this.defined = true
self.computeType()
self.fn = NativeFunction.addExternalFunction(ctx, self.name, self.ret, self.args)
self.defined = true
}
}
NativeFunction.prototype.defineBody = function (ctx, cb) {
Expand Down
7 changes: 4 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export class Type {
this.isRoot = isRoot ? true : false
}
getTypeOfProperty(name: string, fromNode = null): Type {
var type = this.properties[name]
if (type) { return type }
throw new TypeError('Property not found on '+this.name+': '+name, fromNode)
if (!this.properties.hasOwnProperty(name)) {
throw new TypeError('Property not found on '+this.name+': '+name, fromNode)
}
return this.properties[name]
}
setTypeOfProperty(name: string, type: Type): void {
// TODO: Check that it's not overwriting properties
Expand Down

0 comments on commit ecb6801

Please sign in to comment.