                         throw new Error "emitEjsvalTo not implemented for this case"
                         
                 
+        # this method assumes it's called in an opencoded context
         emitLoadSpecops: (obj) ->
-                if opencode_intrinsics and @options.target_pointer_size is 64
+                if @options.target_pointer_size is 64
                         # %1 = getelementptr inbounds %struct._EJSObject* %obj, i64 0, i32 1
                         # %specops_load = load %struct.EJSSpecOps** %1, align 8, !tbaa !0
                         specops_slot = ir.createInBoundsGetElementPointer obj, [(consts.int64 0), (consts.int32 1)], "specops_slot"

                                
                else if n.operator is "!"
                        arg_value =  @visitOrNull n.argument
                        if opencode_intrinsics and @options.target_pointer_size is 64 and arg_value._ejs_returns_ejsval_bool
                                cmp = ir.createICmpEq arg_value, (@loadBoolEjsValue true), "cmpresult"
                                rv = ir.createSelect cmp, (@loadBoolEjsValue false), (@loadBoolEjsValue true), "sel"
                                rv._ejs_returns_ejsval_bool = true

                else
                        @createCall @ejs_runtime.typeof_is_string, [@visitOrNull exp.arguments[0]], "is_string", false
                                
        handleTypeofIsNumber:    (exp, opencode) ->
                if opencode and @options.target_pointer_size is 64
                        cmp = ir.createICmpULt candidate, (consts.int64_lowhi 0xfff80001, 0x00000000), "cmpresult"
                        rv = ir.createSelect cmp, (@loadBoolEjsValue true), (@loadBoolEjsValue false), "sel"
                        rv._ejs_returns_ejsval_bool = true
                        rv
                else
                        @createCall @ejs_runtime.typeof_is_number,    [@visitOrNull exp.arguments[0]], "is_number", false
        handleTypeofIsUndefined: (exp, opencode) ->
                if opencode and @options.target_pointer_size is 64
                        cmp = ir.createICmpEq (@visitOrUndefined exp.arguments[0]), (consts.int64_lowhi 0xfff90000, 0x00000000), "cmpresult"
                        rv = ir.createSelect cmp, (@loadBoolEjsValue true), (@loadBoolEjsValue false), "sel"
                        rv._ejs_returns_ejsval_bool = true
                        rv
                else
                        @createCall @ejs_runtime.typeof_is_undefined, [@visitOrNull exp.arguments[0]], "is_undefined", false
                
        handleTypeofIsNull:      (exp) -> console.log "typeof_is_null"; @createCall @ejs_runtime.typeof_is_null,      [@visitOrNull exp.arguments[0]], "is_null", false
        handleTypeofIsBoolean:   (exp, opencode) ->
                if opencode and @options.target_pointer_size is 64
                        mask = ir.createAnd (@visitOrNull exp.arguments[0]), (consts.int64_lowhi 0xffff8000, 0x00000000), "mask.i"
                        cmp = ir.createICmpEq mask, (consts.int64_lowhi 0xfff98000, 0x00000000), "cmpresult"
                        rv = ir.createSelect cmp, (@loadBoolEjsValue true), (@loadBoolEjsValue false), "sel"
                        rv._ejs_returns_ejsval_bool = true
                        rv
                else
                        @createCall @ejs_runtime.typeof_is_boolean,   [@visitOrNull exp.arguments[0]], "is_boolean", false
        handleBuiltinUndefined:  (exp) -> @loadUndefinedEjsValue()

class AddFunctionsVisitor extends TreeTransformer
