value.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  1. package goja
  2. import (
  3. "math"
  4. "reflect"
  5. "regexp"
  6. "strconv"
  7. )
  8. var (
  9. valueFalse Value = valueBool(false)
  10. valueTrue Value = valueBool(true)
  11. _null Value = valueNull{}
  12. _NaN Value = valueFloat(math.NaN())
  13. _positiveInf Value = valueFloat(math.Inf(+1))
  14. _negativeInf Value = valueFloat(math.Inf(-1))
  15. _positiveZero Value
  16. _negativeZero Value = valueFloat(math.Float64frombits(0 | (1 << 63)))
  17. _epsilon = valueFloat(2.2204460492503130808472633361816e-16)
  18. _undefined Value = valueUndefined{}
  19. )
  20. var (
  21. reflectTypeInt = reflect.TypeOf(int64(0))
  22. reflectTypeBool = reflect.TypeOf(false)
  23. reflectTypeNil = reflect.TypeOf(nil)
  24. reflectTypeFloat = reflect.TypeOf(float64(0))
  25. reflectTypeMap = reflect.TypeOf(map[string]interface{}{})
  26. reflectTypeArray = reflect.TypeOf([]interface{}{})
  27. reflectTypeString = reflect.TypeOf("")
  28. )
  29. var intCache [256]Value
  30. type Value interface {
  31. ToInteger() int64
  32. ToString() valueString
  33. String() string
  34. ToFloat() float64
  35. ToNumber() Value
  36. ToBoolean() bool
  37. ToObject(*Runtime) *Object
  38. SameAs(Value) bool
  39. Equals(Value) bool
  40. StrictEquals(Value) bool
  41. Export() interface{}
  42. ExportType() reflect.Type
  43. assertInt() (int64, bool)
  44. assertString() (valueString, bool)
  45. assertFloat() (float64, bool)
  46. baseObject(r *Runtime) *Object
  47. }
  48. type valueInt int64
  49. type valueFloat float64
  50. type valueBool bool
  51. type valueNull struct{}
  52. type valueUndefined struct {
  53. valueNull
  54. }
  55. type valueUnresolved struct {
  56. r *Runtime
  57. ref string
  58. }
  59. type memberUnresolved struct {
  60. valueUnresolved
  61. }
  62. type valueProperty struct {
  63. value Value
  64. writable bool
  65. configurable bool
  66. enumerable bool
  67. accessor bool
  68. getterFunc *Object
  69. setterFunc *Object
  70. }
  71. func propGetter(o Value, v Value, r *Runtime) *Object {
  72. if v == _undefined {
  73. return nil
  74. }
  75. if obj, ok := v.(*Object); ok {
  76. if _, ok := obj.self.assertCallable(); ok {
  77. return obj
  78. }
  79. }
  80. r.typeErrorResult(true, "Getter must be a function: %s", v.ToString())
  81. return nil
  82. }
  83. func propSetter(o Value, v Value, r *Runtime) *Object {
  84. if v == _undefined {
  85. return nil
  86. }
  87. if obj, ok := v.(*Object); ok {
  88. if _, ok := obj.self.assertCallable(); ok {
  89. return obj
  90. }
  91. }
  92. r.typeErrorResult(true, "Setter must be a function: %s", v.ToString())
  93. return nil
  94. }
  95. func (i valueInt) ToInteger() int64 {
  96. return int64(i)
  97. }
  98. func (i valueInt) ToString() valueString {
  99. return asciiString(i.String())
  100. }
  101. func (i valueInt) String() string {
  102. return strconv.FormatInt(int64(i), 10)
  103. }
  104. func (i valueInt) ToFloat() float64 {
  105. return float64(int64(i))
  106. }
  107. func (i valueInt) ToBoolean() bool {
  108. return i != 0
  109. }
  110. func (i valueInt) ToObject(r *Runtime) *Object {
  111. return r.newPrimitiveObject(i, r.global.NumberPrototype, classNumber)
  112. }
  113. func (i valueInt) ToNumber() Value {
  114. return i
  115. }
  116. func (i valueInt) SameAs(other Value) bool {
  117. if otherInt, ok := other.assertInt(); ok {
  118. return int64(i) == otherInt
  119. }
  120. return false
  121. }
  122. func (i valueInt) Equals(other Value) bool {
  123. if o, ok := other.assertInt(); ok {
  124. return int64(i) == o
  125. }
  126. if o, ok := other.assertFloat(); ok {
  127. return float64(i) == o
  128. }
  129. if o, ok := other.assertString(); ok {
  130. return o.ToNumber().Equals(i)
  131. }
  132. if o, ok := other.(valueBool); ok {
  133. return int64(i) == o.ToInteger()
  134. }
  135. if o, ok := other.(*Object); ok {
  136. return i.Equals(o.self.toPrimitiveNumber())
  137. }
  138. return false
  139. }
  140. func (i valueInt) StrictEquals(other Value) bool {
  141. if otherInt, ok := other.assertInt(); ok {
  142. return int64(i) == otherInt
  143. } else if otherFloat, ok := other.assertFloat(); ok {
  144. return float64(i) == otherFloat
  145. }
  146. return false
  147. }
  148. func (i valueInt) assertInt() (int64, bool) {
  149. return int64(i), true
  150. }
  151. func (i valueInt) assertFloat() (float64, bool) {
  152. return 0, false
  153. }
  154. func (i valueInt) assertString() (valueString, bool) {
  155. return nil, false
  156. }
  157. func (i valueInt) baseObject(r *Runtime) *Object {
  158. return r.global.NumberPrototype
  159. }
  160. func (i valueInt) Export() interface{} {
  161. return int64(i)
  162. }
  163. func (i valueInt) ExportType() reflect.Type {
  164. return reflectTypeInt
  165. }
  166. func (o valueBool) ToInteger() int64 {
  167. if o {
  168. return 1
  169. }
  170. return 0
  171. }
  172. func (o valueBool) ToString() valueString {
  173. if o {
  174. return stringTrue
  175. }
  176. return stringFalse
  177. }
  178. func (o valueBool) String() string {
  179. if o {
  180. return "true"
  181. }
  182. return "false"
  183. }
  184. func (o valueBool) ToFloat() float64 {
  185. if o {
  186. return 1.0
  187. }
  188. return 0
  189. }
  190. func (o valueBool) ToBoolean() bool {
  191. return bool(o)
  192. }
  193. func (o valueBool) ToObject(r *Runtime) *Object {
  194. return r.newPrimitiveObject(o, r.global.BooleanPrototype, "Boolean")
  195. }
  196. func (o valueBool) ToNumber() Value {
  197. if o {
  198. return valueInt(1)
  199. }
  200. return valueInt(0)
  201. }
  202. func (o valueBool) SameAs(other Value) bool {
  203. if other, ok := other.(valueBool); ok {
  204. return o == other
  205. }
  206. return false
  207. }
  208. func (b valueBool) Equals(other Value) bool {
  209. if o, ok := other.(valueBool); ok {
  210. return b == o
  211. }
  212. if b {
  213. return other.Equals(intToValue(1))
  214. } else {
  215. return other.Equals(intToValue(0))
  216. }
  217. }
  218. func (o valueBool) StrictEquals(other Value) bool {
  219. if other, ok := other.(valueBool); ok {
  220. return o == other
  221. }
  222. return false
  223. }
  224. func (o valueBool) assertInt() (int64, bool) {
  225. return 0, false
  226. }
  227. func (o valueBool) assertFloat() (float64, bool) {
  228. return 0, false
  229. }
  230. func (o valueBool) assertString() (valueString, bool) {
  231. return nil, false
  232. }
  233. func (o valueBool) baseObject(r *Runtime) *Object {
  234. return r.global.BooleanPrototype
  235. }
  236. func (o valueBool) Export() interface{} {
  237. return bool(o)
  238. }
  239. func (o valueBool) ExportType() reflect.Type {
  240. return reflectTypeBool
  241. }
  242. func (n valueNull) ToInteger() int64 {
  243. return 0
  244. }
  245. func (n valueNull) ToString() valueString {
  246. return stringNull
  247. }
  248. func (n valueNull) String() string {
  249. return "null"
  250. }
  251. func (u valueUndefined) ToString() valueString {
  252. return stringUndefined
  253. }
  254. func (u valueUndefined) String() string {
  255. return "undefined"
  256. }
  257. func (u valueUndefined) ToNumber() Value {
  258. return _NaN
  259. }
  260. func (u valueUndefined) SameAs(other Value) bool {
  261. _, same := other.(valueUndefined)
  262. return same
  263. }
  264. func (u valueUndefined) StrictEquals(other Value) bool {
  265. _, same := other.(valueUndefined)
  266. return same
  267. }
  268. func (u valueUndefined) ToFloat() float64 {
  269. return math.NaN()
  270. }
  271. func (n valueNull) ToFloat() float64 {
  272. return 0
  273. }
  274. func (n valueNull) ToBoolean() bool {
  275. return false
  276. }
  277. func (n valueNull) ToObject(r *Runtime) *Object {
  278. r.typeErrorResult(true, "Cannot convert undefined or null to object")
  279. return nil
  280. //return r.newObject()
  281. }
  282. func (n valueNull) ToNumber() Value {
  283. return intToValue(0)
  284. }
  285. func (n valueNull) SameAs(other Value) bool {
  286. _, same := other.(valueNull)
  287. return same
  288. }
  289. func (n valueNull) Equals(other Value) bool {
  290. switch other.(type) {
  291. case valueUndefined, valueNull:
  292. return true
  293. }
  294. return false
  295. }
  296. func (n valueNull) StrictEquals(other Value) bool {
  297. _, same := other.(valueNull)
  298. return same
  299. }
  300. func (n valueNull) assertInt() (int64, bool) {
  301. return 0, false
  302. }
  303. func (n valueNull) assertFloat() (float64, bool) {
  304. return 0, false
  305. }
  306. func (n valueNull) assertString() (valueString, bool) {
  307. return nil, false
  308. }
  309. func (n valueNull) baseObject(r *Runtime) *Object {
  310. return nil
  311. }
  312. func (n valueNull) Export() interface{} {
  313. return nil
  314. }
  315. func (n valueNull) ExportType() reflect.Type {
  316. return reflectTypeNil
  317. }
  318. func (p *valueProperty) ToInteger() int64 {
  319. return 0
  320. }
  321. func (p *valueProperty) ToString() valueString {
  322. return stringEmpty
  323. }
  324. func (p *valueProperty) String() string {
  325. return ""
  326. }
  327. func (p *valueProperty) ToFloat() float64 {
  328. return math.NaN()
  329. }
  330. func (p *valueProperty) ToBoolean() bool {
  331. return false
  332. }
  333. func (p *valueProperty) ToObject(r *Runtime) *Object {
  334. return nil
  335. }
  336. func (p *valueProperty) ToNumber() Value {
  337. return nil
  338. }
  339. func (p *valueProperty) assertInt() (int64, bool) {
  340. return 0, false
  341. }
  342. func (p *valueProperty) assertFloat() (float64, bool) {
  343. return 0, false
  344. }
  345. func (p *valueProperty) assertString() (valueString, bool) {
  346. return nil, false
  347. }
  348. func (p *valueProperty) isWritable() bool {
  349. return p.writable || p.setterFunc != nil
  350. }
  351. func (p *valueProperty) get(this Value) Value {
  352. if p.getterFunc == nil {
  353. if p.value != nil {
  354. return p.value
  355. }
  356. return _undefined
  357. }
  358. call, _ := p.getterFunc.self.assertCallable()
  359. return call(FunctionCall{
  360. This: this,
  361. })
  362. }
  363. func (p *valueProperty) set(this, v Value) {
  364. if p.setterFunc == nil {
  365. p.value = v
  366. return
  367. }
  368. call, _ := p.setterFunc.self.assertCallable()
  369. call(FunctionCall{
  370. This: this,
  371. Arguments: []Value{v},
  372. })
  373. }
  374. func (p *valueProperty) SameAs(other Value) bool {
  375. if otherProp, ok := other.(*valueProperty); ok {
  376. return p == otherProp
  377. }
  378. return false
  379. }
  380. func (p *valueProperty) Equals(other Value) bool {
  381. return false
  382. }
  383. func (p *valueProperty) StrictEquals(other Value) bool {
  384. return false
  385. }
  386. func (n *valueProperty) baseObject(r *Runtime) *Object {
  387. r.typeErrorResult(true, "BUG: baseObject() is called on valueProperty") // TODO error message
  388. return nil
  389. }
  390. func (n *valueProperty) Export() interface{} {
  391. panic("Cannot export valueProperty")
  392. }
  393. func (n *valueProperty) ExportType() reflect.Type {
  394. panic("Cannot export valueProperty")
  395. }
  396. func (f valueFloat) ToInteger() int64 {
  397. switch {
  398. case math.IsNaN(float64(f)):
  399. return 0
  400. case math.IsInf(float64(f), 1):
  401. return int64(math.MaxInt64)
  402. case math.IsInf(float64(f), -1):
  403. return int64(math.MinInt64)
  404. }
  405. return int64(f)
  406. }
  407. func (f valueFloat) ToString() valueString {
  408. return asciiString(f.String())
  409. }
  410. var matchLeading0Exponent = regexp.MustCompile(`([eE][\+\-])0+([1-9])`) // 1e-07 => 1e-7
  411. func (f valueFloat) String() string {
  412. value := float64(f)
  413. if math.IsNaN(value) {
  414. return "NaN"
  415. } else if math.IsInf(value, 0) {
  416. if math.Signbit(value) {
  417. return "-Infinity"
  418. }
  419. return "Infinity"
  420. } else if f == _negativeZero {
  421. return "0"
  422. }
  423. exponent := math.Log10(math.Abs(value))
  424. if exponent >= 21 || exponent < -6 {
  425. return matchLeading0Exponent.ReplaceAllString(strconv.FormatFloat(value, 'g', -1, 64), "$1$2")
  426. }
  427. return strconv.FormatFloat(value, 'f', -1, 64)
  428. }
  429. func (f valueFloat) ToFloat() float64 {
  430. return float64(f)
  431. }
  432. func (f valueFloat) ToBoolean() bool {
  433. return float64(f) != 0.0 && !math.IsNaN(float64(f))
  434. }
  435. func (f valueFloat) ToObject(r *Runtime) *Object {
  436. return r.newPrimitiveObject(f, r.global.NumberPrototype, "Number")
  437. }
  438. func (f valueFloat) ToNumber() Value {
  439. return f
  440. }
  441. func (f valueFloat) SameAs(other Value) bool {
  442. if o, ok := other.assertFloat(); ok {
  443. this := float64(f)
  444. if math.IsNaN(this) && math.IsNaN(o) {
  445. return true
  446. } else {
  447. ret := this == o
  448. if ret && this == 0 {
  449. ret = math.Signbit(this) == math.Signbit(o)
  450. }
  451. return ret
  452. }
  453. } else if o, ok := other.assertInt(); ok {
  454. this := float64(f)
  455. ret := this == float64(o)
  456. if ret && this == 0 {
  457. ret = !math.Signbit(this)
  458. }
  459. return ret
  460. }
  461. return false
  462. }
  463. func (f valueFloat) Equals(other Value) bool {
  464. if o, ok := other.assertFloat(); ok {
  465. return float64(f) == o
  466. }
  467. if o, ok := other.assertInt(); ok {
  468. return float64(f) == float64(o)
  469. }
  470. if _, ok := other.assertString(); ok {
  471. return float64(f) == other.ToFloat()
  472. }
  473. if o, ok := other.(valueBool); ok {
  474. return float64(f) == o.ToFloat()
  475. }
  476. if o, ok := other.(*Object); ok {
  477. return f.Equals(o.self.toPrimitiveNumber())
  478. }
  479. return false
  480. }
  481. func (f valueFloat) StrictEquals(other Value) bool {
  482. if o, ok := other.assertFloat(); ok {
  483. return float64(f) == o
  484. } else if o, ok := other.assertInt(); ok {
  485. return float64(f) == float64(o)
  486. }
  487. return false
  488. }
  489. func (f valueFloat) assertInt() (int64, bool) {
  490. return 0, false
  491. }
  492. func (f valueFloat) assertFloat() (float64, bool) {
  493. return float64(f), true
  494. }
  495. func (f valueFloat) assertString() (valueString, bool) {
  496. return nil, false
  497. }
  498. func (f valueFloat) baseObject(r *Runtime) *Object {
  499. return r.global.NumberPrototype
  500. }
  501. func (f valueFloat) Export() interface{} {
  502. return float64(f)
  503. }
  504. func (f valueFloat) ExportType() reflect.Type {
  505. return reflectTypeFloat
  506. }
  507. func (o *Object) ToInteger() int64 {
  508. return o.self.toPrimitiveNumber().ToNumber().ToInteger()
  509. }
  510. func (o *Object) ToString() valueString {
  511. return o.self.toPrimitiveString().ToString()
  512. }
  513. func (o *Object) String() string {
  514. return o.self.toPrimitiveString().String()
  515. }
  516. func (o *Object) ToFloat() float64 {
  517. return o.self.toPrimitiveNumber().ToFloat()
  518. }
  519. func (o *Object) ToBoolean() bool {
  520. return true
  521. }
  522. func (o *Object) ToObject(r *Runtime) *Object {
  523. return o
  524. }
  525. func (o *Object) ToNumber() Value {
  526. return o.self.toPrimitiveNumber().ToNumber()
  527. }
  528. func (o *Object) SameAs(other Value) bool {
  529. if other, ok := other.(*Object); ok {
  530. return o == other
  531. }
  532. return false
  533. }
  534. func (o *Object) Equals(other Value) bool {
  535. if other, ok := other.(*Object); ok {
  536. return o == other || o.self.equal(other.self)
  537. }
  538. if _, ok := other.assertInt(); ok {
  539. return o.self.toPrimitive().Equals(other)
  540. }
  541. if _, ok := other.assertFloat(); ok {
  542. return o.self.toPrimitive().Equals(other)
  543. }
  544. if other, ok := other.(valueBool); ok {
  545. return o.Equals(other.ToNumber())
  546. }
  547. if _, ok := other.assertString(); ok {
  548. return o.self.toPrimitive().Equals(other)
  549. }
  550. return false
  551. }
  552. func (o *Object) StrictEquals(other Value) bool {
  553. if other, ok := other.(*Object); ok {
  554. return o == other || o.self.equal(other.self)
  555. }
  556. return false
  557. }
  558. func (o *Object) assertInt() (int64, bool) {
  559. return 0, false
  560. }
  561. func (o *Object) assertFloat() (float64, bool) {
  562. return 0, false
  563. }
  564. func (o *Object) assertString() (valueString, bool) {
  565. return nil, false
  566. }
  567. func (o *Object) baseObject(r *Runtime) *Object {
  568. return o
  569. }
  570. func (o *Object) Export() interface{} {
  571. return o.self.export()
  572. }
  573. func (o *Object) ExportType() reflect.Type {
  574. return o.self.exportType()
  575. }
  576. func (o *Object) Get(name string) Value {
  577. return o.self.getStr(name)
  578. }
  579. func (o *Object) Keys() (keys []string) {
  580. for item, f := o.self.enumerate(false, false)(); f != nil; item, f = f() {
  581. keys = append(keys, item.name)
  582. }
  583. return
  584. }
  585. // DefineDataProperty is a Go equivalent of Object.defineProperty(o, name, {value: value, writable: writable,
  586. // configurable: configurable, enumerable: enumerable})
  587. func (o *Object) DefineDataProperty(name string, value Value, writable, configurable, enumerable Flag) error {
  588. return tryFunc(func() {
  589. o.self.defineOwnProperty(newStringValue(name), propertyDescr{
  590. Value: value,
  591. Writable: writable,
  592. Configurable: configurable,
  593. Enumerable: enumerable,
  594. }, true)
  595. })
  596. }
  597. // DefineAccessorProperty is a Go equivalent of Object.defineProperty(o, name, {get: getter, set: setter,
  598. // configurable: configurable, enumerable: enumerable})
  599. func (o *Object) DefineAccessorProperty(name string, getter, setter Value, configurable, enumerable Flag) error {
  600. return tryFunc(func() {
  601. o.self.defineOwnProperty(newStringValue(name), propertyDescr{
  602. Getter: getter,
  603. Setter: setter,
  604. Configurable: configurable,
  605. Enumerable: enumerable,
  606. }, true)
  607. })
  608. }
  609. func (o *Object) Set(name string, value interface{}) error {
  610. return tryFunc(func() {
  611. o.self.putStr(name, o.runtime.ToValue(value), true)
  612. })
  613. }
  614. // MarshalJSON returns JSON representation of the Object. It is equivalent to JSON.stringify(o).
  615. // Note, this implements json.Marshaler so that json.Marshal() can be used without the need to Export().
  616. func (o *Object) MarshalJSON() ([]byte, error) {
  617. ctx := _builtinJSON_stringifyContext{
  618. r: o.runtime,
  619. }
  620. ex := o.runtime.vm.try(func() {
  621. if !ctx.do(o) {
  622. ctx.buf.WriteString("null")
  623. }
  624. })
  625. if ex != nil {
  626. return nil, ex
  627. }
  628. return ctx.buf.Bytes(), nil
  629. }
  630. func (o valueUnresolved) throw() {
  631. o.r.throwReferenceError(o.ref)
  632. }
  633. func (o valueUnresolved) ToInteger() int64 {
  634. o.throw()
  635. return 0
  636. }
  637. func (o valueUnresolved) ToString() valueString {
  638. o.throw()
  639. return nil
  640. }
  641. func (o valueUnresolved) String() string {
  642. o.throw()
  643. return ""
  644. }
  645. func (o valueUnresolved) ToFloat() float64 {
  646. o.throw()
  647. return 0
  648. }
  649. func (o valueUnresolved) ToBoolean() bool {
  650. o.throw()
  651. return false
  652. }
  653. func (o valueUnresolved) ToObject(r *Runtime) *Object {
  654. o.throw()
  655. return nil
  656. }
  657. func (o valueUnresolved) ToNumber() Value {
  658. o.throw()
  659. return nil
  660. }
  661. func (o valueUnresolved) SameAs(other Value) bool {
  662. o.throw()
  663. return false
  664. }
  665. func (o valueUnresolved) Equals(other Value) bool {
  666. o.throw()
  667. return false
  668. }
  669. func (o valueUnresolved) StrictEquals(other Value) bool {
  670. o.throw()
  671. return false
  672. }
  673. func (o valueUnresolved) assertInt() (int64, bool) {
  674. o.throw()
  675. return 0, false
  676. }
  677. func (o valueUnresolved) assertFloat() (float64, bool) {
  678. o.throw()
  679. return 0, false
  680. }
  681. func (o valueUnresolved) assertString() (valueString, bool) {
  682. o.throw()
  683. return nil, false
  684. }
  685. func (o valueUnresolved) baseObject(r *Runtime) *Object {
  686. o.throw()
  687. return nil
  688. }
  689. func (o valueUnresolved) Export() interface{} {
  690. o.throw()
  691. return nil
  692. }
  693. func (o valueUnresolved) ExportType() reflect.Type {
  694. o.throw()
  695. return nil
  696. }
  697. func init() {
  698. for i := 0; i < 256; i++ {
  699. intCache[i] = valueInt(i - 128)
  700. }
  701. _positiveZero = intToValue(0)
  702. }