package goja

func ( *Runtime) ( FunctionCall) Value {
	var  bool
	switch o := .This.(type) {
	case valueBool:
		 = bool()
		goto 
	case *Object:
		if ,  := .self.(*primitiveValueObject);  {
			if ,  := .pValue.(valueBool);  {
				 = bool()
				goto 
			}
		}
		if ,  := .self.(*objectGoReflect);  {
			if .class == classBoolean && .toString != nil {
				return .toString()
			}
		}
	}
	.typeErrorResult(true, "Method Boolean.prototype.toString is called on incompatible receiver")

:
	if  {
		return stringTrue
	}
	return stringFalse
}

func ( *Runtime) ( FunctionCall) Value {
	switch o := .This.(type) {
	case valueBool:
		return 
	case *Object:
		if ,  := .self.(*primitiveValueObject);  {
			if ,  := .pValue.(valueBool);  {
				return 
			}
		}
		if ,  := .self.(*objectGoReflect);  {
			if .class == classBoolean && .valueOf != nil {
				return .valueOf()
			}
		}
	}

	.typeErrorResult(true, "Method Boolean.prototype.valueOf is called on incompatible receiver")
	return nil
}

func ( *Runtime) () *Object {
	 := .global.BooleanPrototype
	if  == nil {
		 = .newPrimitiveObject(valueFalse, .global.ObjectPrototype, classBoolean)
		.global.BooleanPrototype = 
		 := .self
		._putProp("toString", .newNativeFunc(.booleanproto_toString, "toString", 0), true, false, true)
		._putProp("valueOf", .newNativeFunc(.booleanproto_valueOf, "valueOf", 0), true, false, true)
		._putProp("constructor", .getBoolean(), true, false, true)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Boolean
	if  == nil {
		 = &Object{runtime: }
		.global.Boolean = 
		 := .getBooleanPrototype()
		.newNativeFuncAndConstruct(, .builtin_Boolean,
			.wrapNativeConstruct(.builtin_newBoolean, , ), , "Boolean", intToValue(1))
	}
	return 
}