Inline CGAbstractBindingMethod.getThis.

There's no good reason to keep this separate; it's only called once, and
inlining the function makes the code a little clearer.

This commit does not make any change to the generated code.
This commit is contained in:
Ms2ger 2014-04-24 23:52:25 +02:00
parent 82afae123e
commit a6a06e0ffc

View file

@ -2493,21 +2493,18 @@ class CGAbstractBindingMethod(CGAbstractExternMethod):
# we're someone's consequential interface. But for this-unwrapping, we # we're someone's consequential interface. But for this-unwrapping, we
# know that we're the real deal. So fake a descriptor here for # know that we're the real deal. So fake a descriptor here for
# consumption by FailureFatalCastableObjectUnwrapper. # consumption by FailureFatalCastableObjectUnwrapper.
unwrapThis = CGIndenter(CGGeneric( unwrapThis = str(CastableObjectUnwrapper(
"this = " + str(CastableObjectUnwrapper(
FakeCastableDescriptor(self.descriptor), FakeCastableDescriptor(self.descriptor),
"obj", self.unwrapFailureCode)) + ";\n")) "obj", self.unwrapFailureCode))
return CGList([ self.getThis(), unwrapThis, unwrapThis = CGIndenter(
self.generate_code() ], "\n").define()
def getThis(self):
return CGIndenter(
CGGeneric("let obj: *JSObject = JS_THIS_OBJECT(cx, vp as *mut JSVal);\n" CGGeneric("let obj: *JSObject = JS_THIS_OBJECT(cx, vp as *mut JSVal);\n"
"if obj.is_null() {\n" "if obj.is_null() {\n"
" return false as JSBool;\n" " return false as JSBool;\n"
"}\n" "}\n"
"\n" "\n"
"let this: JS<%s>;" % self.descriptor.concreteType)) "let this: JS<%s>;\n"
"this = %s;\n" % (self.descriptor.concreteType, unwrapThis)))
return CGList([ unwrapThis, self.generate_code() ], "\n").define()
def generate_code(self): def generate_code(self):
assert(False) # Override me assert(False) # Override me